2019-07-30 05:19:22 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
'''
|
|
|
|
Onionr - Private P2P Communication
|
|
|
|
|
|
|
|
This file initializes Onionr when ran to be a daemon or with commands
|
|
|
|
|
|
|
|
Run with 'help' for usage.
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
'''
|
|
|
|
# Set the user's locale for encoding reasons
|
|
|
|
import locale
|
|
|
|
locale.setlocale(locale.LC_ALL, '')
|
|
|
|
|
|
|
|
# Import standard libraries
|
|
|
|
import sys
|
|
|
|
|
|
|
|
# 3rd party lib imports
|
|
|
|
# Ensure that PySocks is installed
|
|
|
|
try:
|
|
|
|
from urllib3.contrib.socks import SOCKSProxyManager
|
2019-08-13 22:28:53 +00:00
|
|
|
except ModuleNotFoundError:
|
|
|
|
raise ModuleNotFoundError("You need the PySocks module (for use with socks5 proxy to use Tor)")
|
2019-07-30 05:19:22 +00:00
|
|
|
|
|
|
|
# Onionr imports
|
|
|
|
from etc import onionrvalues # For different Onionr related constants such as versions
|
2019-07-30 18:13:10 +00:00
|
|
|
import setup
|
2019-07-30 05:19:22 +00:00
|
|
|
|
|
|
|
# Ensure we have at least the minimum python version
|
|
|
|
if sys.version_info[0] == 2 or sys.version_info[1] < onionrvalues.MIN_PY_VERSION:
|
|
|
|
sys.stderr.write('Error, Onionr requires Python 3.%s+\n' % (onionrvalues.MIN_PY_VERSION,))
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
# Ensure Python interpreter is not optimized TODO: Remove asserts and replace with ifs
|
|
|
|
from utils import detectoptimization
|
|
|
|
if detectoptimization.detect_optimization():
|
|
|
|
sys.stderr.write('Error, Onionr cannot be run with an optimized Python interpreter\n')
|
2019-07-30 18:13:10 +00:00
|
|
|
sys.exit(2)
|
2019-07-30 05:19:22 +00:00
|
|
|
|
|
|
|
# Create Onionr data directories, must be done before most imports
|
|
|
|
from utils import createdirs
|
|
|
|
createdirs.create_dirs()
|
|
|
|
|
2019-07-30 18:13:10 +00:00
|
|
|
from onionrcommands import parser
|
2019-08-04 04:52:57 +00:00
|
|
|
import onionrevents as events
|
2019-07-30 18:13:10 +00:00
|
|
|
|
2019-07-30 05:19:22 +00:00
|
|
|
setup.setup_config()
|
|
|
|
setup.setup_default_plugins()
|
|
|
|
|
|
|
|
def onionr_main():
|
2019-07-30 18:13:10 +00:00
|
|
|
parser.register()
|
2019-07-30 05:19:22 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
onionr_main()
|