progress removing onionr.py

This commit is contained in:
Kevin Froman 2019-08-05 12:57:25 -05:00
parent 6bf8bb1db6
commit 2bc908deb6
4 changed files with 14 additions and 7 deletions

View File

@ -78,7 +78,7 @@ def announce_node(daemon):
daemon.announceCache[peer] = data['random'] daemon.announceCache[peer] = data['random']
if not announceFail: if not announceFail:
logger.info('Announcing node to ' + url) logger.info('Announcing node to ' + url)
if basicrequests.do_post_request(url, data, port=daemon.shared_state.get(NetController)) == 'Success': if basicrequests.do_post_request(url, data, port=daemon.shared_state.get(NetController).socksPort) == 'Success':
logger.info('Successfully introduced node to ' + peer, terminal=True) logger.info('Successfully introduced node to ' + peer, terminal=True)
retData = True retData = True
keydb.transportinfo.set_address_info(peer, 'introduced', 1) keydb.transportinfo.set_address_info(peer, 'introduced', 1)

View File

@ -52,7 +52,7 @@ def connect_new_peer_to_communicator(comm_inst, peer='', useBootstrap=False):
if len(peerList) == 0 or useBootstrap: if len(peerList) == 0 or useBootstrap:
# Avoid duplicating bootstrap addresses in peerList # Avoid duplicating bootstrap addresses in peerList
bootstrappeers.add_bootstrap_list_to_peer_list(comm_inst, peerList) bootstrappeers.add_bootstrap_list_to_peer_list(comm_inst, peerList)
print(peerList)
for address in peerList: for address in peerList:
if not config.get('tor.v3onions') and len(address) == 62: if not config.get('tor.v3onions') and len(address) == 62:
continue continue

View File

@ -18,13 +18,14 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
''' '''
import base64 import base64
from flask import Response from flask import Response, g
import deadsimplekv import deadsimplekv
import logger import logger
from etc import onionrvalues from etc import onionrvalues
from onionrutils import stringvalidators, bytesconverter from onionrutils import stringvalidators, bytesconverter
from utils import gettransports from utils import gettransports
import onionrcrypto as crypto, filepaths import onionrcrypto as crypto, filepaths
from communicator import OnionrCommunicatorDaemon
def handle_announce(request): def handle_announce(request):
''' '''
accept announcement posts, validating POW accept announcement posts, validating POW
@ -57,9 +58,14 @@ def handle_announce(request):
if powHash.startswith('0' * onionrvalues.OnionrValues().announce_pow): if powHash.startswith('0' * onionrvalues.OnionrValues().announce_pow):
newNode = bytesconverter.bytes_to_str(newNode) newNode = bytesconverter.bytes_to_str(newNode)
announce_queue = deadsimplekv.DeadSimpleKV(filepaths.announce_cache) announce_queue = deadsimplekv.DeadSimpleKV(filepaths.announce_cache)
if stringvalidators.validate_transport(newNode) and not newNode in announce_queue.get('new_peers'): announce_queue_list = announce_queue.get('new_peers')
clientAPI.onionrInst.communicatorInst.newPeers.append(newNode) if announce_queue_list is None:
announce_queue.put('new_peers', announce_queue.get('new_peers').append(newNode)) announce_queue_list = []
if stringvalidators.validate_transport(newNode) and not newNode in announce_queue_list:
#clientAPI.onionrInst.communicatorInst.newPeers.append(newNode)
g.shared_state.get(OnionrCommunicatorDaemon).newPeers.append(newNode)
announce_queue.put('new_peers', announce_queue_list.append(newNode))
announce_queue.flush() announce_queue.flush()
resp = 'Success' resp = 'Success'
else: else:

View File

@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
''' '''
from flask import Response, Blueprint, request, send_from_directory, abort from flask import Response, Blueprint, request, send_from_directory, abort, g
from . import getblocks, upload, announce from . import getblocks, upload, announce
from coredb import keydb from coredb import keydb
import config import config
@ -69,6 +69,7 @@ class PublicEndpoints:
@public_endpoints_bp.route('/announce', methods=['post']) @public_endpoints_bp.route('/announce', methods=['post'])
def accept_announce(): def accept_announce():
'''Accept announcements with pow token to prevent spam''' '''Accept announcements with pow token to prevent spam'''
g.shared_state = public_api._too_many
resp = announce.handle_announce(request) resp = announce.handle_announce(request)
return resp return resp