diff --git a/onionr/communicator.py b/onionr/communicator.py
index d018a53a..602f7277 100755
--- a/onionr/communicator.py
+++ b/onionr/communicator.py
@@ -19,11 +19,11 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see .
'''
-import sys, os, core, config, json, requests, time, logger, threading, base64, onionr, uuid, binascii
-from dependencies import secrets
+import sys, os, time
+import core, config, logger, onionr
import onionrexceptions, onionrpeers, onionrevents as events, onionrplugins as plugins, onionrblockapi as block
from communicatorutils import onionrdaemontools, servicecreator, onionrcommunicatortimers
-from communicatorutils import proxypicker, downloadblocks, lookupblocks, lookupadders
+from communicatorutils import downloadblocks, lookupblocks, lookupadders
from communicatorutils import servicecreator, connectnewpeers, uploadblocks
from communicatorutils import daemonqueuehandler
import onionrservices, onionr, onionrproofs
diff --git a/onionr/core.py b/onionr/core.py
index 3c04ceb4..4246f7fe 100755
--- a/onionr/core.py
+++ b/onionr/core.py
@@ -17,7 +17,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see .
'''
-import sqlite3, os, sys, time, math, base64, tarfile, nacl, logger, json, netcontroller, math, config, uuid
+import sqlite3, os, sys, time, json, uuid
+import logger, netcontroller, config
from onionrblockapi import Block
import deadsimplekv as simplekv
import onionrutils, onionrcrypto, onionrproofs, onionrevents as events, onionrexceptions
@@ -160,11 +161,11 @@ class Core:
Add an address to the address database (only tor currently)
'''
- if address == config.get('i2p.ownAddr', None) or address == self.hsAddress:
- return False
if type(address) is None or len(address) == 0:
return False
if self._utils.validateID(address):
+ if address == config.get('i2p.ownAddr', None) or address == self.hsAddress:
+ return False
conn = sqlite3.connect(self.addressDB, timeout=30)
c = conn.cursor()
# check if address is in database
@@ -226,6 +227,8 @@ class Core:
conn.close()
dataSize = sys.getsizeof(onionrstorage.getData(self, block))
self._utils.storageCounter.removeBytes(dataSize)
+ else:
+ raise onionrexceptions.InvalidHexHash
def createAddressDB(self):
'''
@@ -797,7 +800,7 @@ class Core:
logger.error(allocationReachedMessage)
retData = False
else:
- # Tell the api server through localCommand to wait for the daemon to upload this block to make stastical analysis more difficult
+ # Tell the api server through localCommand to wait for the daemon to upload this block to make statistical analysis more difficult
if self._utils.localCommand('/ping', maxWait=10) == 'pong!':
self._utils.localCommand('/waitforshare/' + retData, post=True, maxWait=5)
self.daemonQueueAdd('uploadBlock', retData)
@@ -815,27 +818,8 @@ class Core:
'''
Introduces our node into the network by telling X many nodes our HS address
'''
-
- if(self._utils.isCommunicatorRunning(timeout=30)):
- announceAmount = 2
- nodeList = self.listAdders()
-
- if len(nodeList) == 0:
- for i in self.bootstrapList:
- if self._utils.validateID(i):
- self.addAddress(i)
- nodeList.append(i)
-
- if announceAmount > len(nodeList):
- announceAmount = len(nodeList)
-
- for i in range(announceAmount):
- self.daemonQueueAdd('announceNode', nodeList[i])
-
- events.event('introduction', onionr = None)
-
- return True
+ if self._utils.localCommand('/ping', maxWait=10) == 'pong!':
+ self.daemonQueueAdd('announceNode')
+ logger.info('Introduction command will be processed.')
else:
- logger.error('Onionr daemon is not running.')
- return False
- return
+ logger.warn('No running node detected. Cannot introduce.')
\ No newline at end of file
diff --git a/onionr/onionr.py b/onionr/onionr.py
index 402b7bd0..a12250cc 100755
--- a/onionr/onionr.py
+++ b/onionr/onionr.py
@@ -25,8 +25,7 @@ MIN_PY_VERSION = 6
if sys.version_info[0] == 2 or sys.version_info[1] < MIN_PY_VERSION:
sys.stderr.write('Error, Onionr requires Python 3.%s+' % (MIN_PY_VERSION,))
sys.exit(1)
-import os, base64, random, getpass, shutil, time, platform, datetime, re, json, getpass, sqlite3
-import webbrowser, uuid, signal
+import os, base64, random, shutil, time, platform, signal
from threading import Thread
import api, core, config, logger, onionrplugins as plugins, onionrevents as events
import onionrutils
@@ -34,7 +33,6 @@ import netcontroller
from netcontroller import NetController
from onionrblockapi import Block
import onionrproofs, onionrexceptions, communicator, setupconfig
-from onionrusers import onionrusers
import onionrcommands as commands # Many command definitions are here
try:
diff --git a/onionr/onionrcrypto.py b/onionr/onionrcrypto.py
index 4b5a72e1..ddff1993 100755
--- a/onionr/onionrcrypto.py
+++ b/onionr/onionrcrypto.py
@@ -17,7 +17,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see .
'''
-import nacl.signing, nacl.encoding, nacl.public, nacl.hash, nacl.pwhash, nacl.utils, nacl.secret, os, binascii, base64, hashlib, logger, onionrproofs, time, math, sys, hmac
+import os, binascii, base64, hashlib, time, sys, hmac
+import nacl.signing, nacl.encoding, nacl.public, nacl.hash, nacl.pwhash, nacl.utils, nacl.secret
+import logger, onionrproofs
import onionrexceptions, keymanager, core
# secrets module was added into standard lib in 3.6+
if sys.version_info[0] == 3 and sys.version_info[1] < 6:
diff --git a/onionr/onionrproofs.py b/onionr/onionrproofs.py
index 287ba30f..20e10403 100755
--- a/onionr/onionrproofs.py
+++ b/onionr/onionrproofs.py
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see .
'''
-import multiprocessing, nacl.encoding, nacl.hash, nacl.utils, time, math, threading, binascii, sys, base64, json
+import multiprocessing, nacl.encoding, nacl.hash, nacl.utils, time, math, threading, binascii, sys, json
import core, onionrutils, config, logger, onionrblockapi
def getDifficultyModifier(coreOrUtilsInst=None):
diff --git a/onionr/onionrutils.py b/onionr/onionrutils.py
index 9ab1dfa3..31521059 100755
--- a/onionr/onionrutils.py
+++ b/onionr/onionrutils.py
@@ -18,10 +18,11 @@
along with this program. If not, see .
'''
# Misc functions that do not fit in the main api, but are useful
-import getpass, sys, requests, os, socket, hashlib, logger, sqlite3, config, binascii, time, base64, json, glob, shutil, math, json, re, urllib.parse, string
+import sys, os, sqlite3, binascii, time, base64, json, glob, shutil, math, re, urllib.parse, string
+import requests
import nacl.signing, nacl.encoding
from onionrblockapi import Block
-import onionrexceptions
+import onionrexceptions, config, logger
from onionr import API_VERSION
import onionrevents
import storagecounter
diff --git a/onionr/serializeddata.py b/onionr/serializeddata.py
index 1587e74e..3efe150a 100644
--- a/onionr/serializeddata.py
+++ b/onionr/serializeddata.py
@@ -18,7 +18,7 @@
along with this program. If not, see .
'''
-import core, api, uuid, json
+import core, json
class SerializedData:
def __init__(self, coreInst):
diff --git a/onionr/subprocesspow.py b/onionr/subprocesspow.py
index 6df08ca2..f1b23c7f 100755
--- a/onionr/subprocesspow.py
+++ b/onionr/subprocesspow.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
import subprocess, os
-import multiprocessing, threading, time, json, math
+import multiprocessing, threading, time, json
from multiprocessing import Pipe, Process
import core, onionrblockapi, config, onionrutils, logger, onionrproofs