2018-06-10 08:00:01 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
'''
|
|
|
|
Onionr - P2P Microblogging Platform & Social network.
|
|
|
|
|
|
|
|
This file contains both the OnionrCommunicate class for communcating with peers
|
|
|
|
and code to operate as a daemon, getting commands from the command queue database (see core.Core.daemonQueue)
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
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/>.
|
|
|
|
'''
|
2018-06-12 07:34:33 +00:00
|
|
|
import sys, core, config, onionrblockapi as block, requests
|
|
|
|
from defusedxml import minidom
|
|
|
|
|
2018-06-11 07:40:45 +00:00
|
|
|
class OnionrCommunicatorDaemon:
|
2018-06-10 08:00:01 +00:00
|
|
|
def __init__(self, debug, developmentMode):
|
|
|
|
self.timers = [] # list of tuples, function, time in seconds
|
2018-06-11 07:40:45 +00:00
|
|
|
self._core = core.Core()
|
|
|
|
|
2018-06-12 07:34:33 +00:00
|
|
|
self.nistSaltTimestamp = 0
|
|
|
|
self.powSalt = 0
|
2018-06-10 08:00:01 +00:00
|
|
|
return
|
2018-06-11 07:40:45 +00:00
|
|
|
|
|
|
|
|
2018-06-10 08:00:01 +00:00
|
|
|
|
|
|
|
shouldRun = False
|
|
|
|
debug = True
|
|
|
|
developmentMode = False
|
|
|
|
if config.get('devmode', True):
|
|
|
|
developmentMode = True
|
|
|
|
try:
|
|
|
|
if sys.argv[1] == 'run':
|
|
|
|
shouldRun = True
|
|
|
|
except IndexError:
|
|
|
|
pass
|
|
|
|
if shouldRun:
|
|
|
|
try:
|
2018-06-11 07:40:45 +00:00
|
|
|
OnionrCommunicatorDaemon(debug, developmentMode)
|
2018-06-10 08:00:01 +00:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
sys.exit(1)
|
|
|
|
pass
|