bugfix and bulletproof nodes
This commit is contained in:
parent
ca9c6fc091
commit
9e037f13c0
@ -49,4 +49,5 @@ Toxygen is powerful cross-platform [Tox](https://tox.chat/) client written in pu
|
|||||||
This hard-forked from https://github.com/toxygen-project/toxygen
|
This hard-forked from https://github.com/toxygen-project/toxygen
|
||||||
```next_gen``` branch.
|
```next_gen``` branch.
|
||||||
|
|
||||||
Work on this project is suspended until the MultiDevice problem is solved.
|
Work on this project is suspended until the
|
||||||
|
[MultiDevice](https://git.plastiras.org/emdee/tox_profile/wiki/MultiDevice-Announcements-POC) problem is solved. Fork me!
|
@ -810,10 +810,10 @@ class App:
|
|||||||
def _test_relays(self, lElts=None):
|
def _test_relays(self, lElts=None):
|
||||||
env = self._test_env()
|
env = self._test_env()
|
||||||
if lElts is None:
|
if lElts is None:
|
||||||
lElts = env['lElts']
|
lElts = self._settings['current_nodes_tcp']
|
||||||
# shuffle(env['lElts'])
|
shuffle(lElts)
|
||||||
LOG.debug(f"_test_relays {len(env['lElts'])}")
|
LOG.debug(f"_test_relays {len(env['lElts'])}")
|
||||||
for host,port,key in env['lElts'][:10]:
|
for host,port,key in lElts[:10]:
|
||||||
try:
|
try:
|
||||||
oRet = self._tox.add_tcp_relay(host, port, key)
|
oRet = self._tox.add_tcp_relay(host, port, key)
|
||||||
LOG.debug('add_tcp_relay to ' +host +':' +str(port) \
|
LOG.debug('add_tcp_relay to ' +host +':' +str(port) \
|
||||||
@ -842,12 +842,20 @@ class App:
|
|||||||
|
|
||||||
LOG.debug("test_net " +self._args.network)
|
LOG.debug("test_net " +self._args.network)
|
||||||
# bootstrap
|
# bootstrap
|
||||||
LOG.debug('Calling generate_nodes: ')
|
LOG.debug('Calling generate_nodes: udp')
|
||||||
lNodes = ts.generate_nodes(oArgs=self._args)
|
lNodes = ts.generate_nodes(oArgs=self._args,
|
||||||
if lNodes:
|
ipv='ipv4',
|
||||||
self._settings['current_nodes'] = lNodes
|
udp_not_tcp=True)
|
||||||
else:
|
self._settings['current_nodes_udp'] = lNodes
|
||||||
LOG.warn('empty generate_nodes: ')
|
if not lNodes:
|
||||||
|
LOG.warn('empty generate_nodes udp')
|
||||||
|
LOG.debug('Calling generate_nodes: tcp')
|
||||||
|
lNodes = ts.generate_nodes(oArgs=self._args,
|
||||||
|
ipv='ipv4',
|
||||||
|
udp_not_tcp=False)
|
||||||
|
self._settings['current_nodes_tcp'] = lNodes
|
||||||
|
if not lNodes:
|
||||||
|
LOG.warn('empty generate_nodes tcp')
|
||||||
|
|
||||||
# if oThread and oThread._stop_thread: return
|
# if oThread and oThread._stop_thread: return
|
||||||
LOG.debug("test_net network=" +self._args.network +' iMax=' +str(iMax))
|
LOG.debug("test_net network=" +self._args.network +' iMax=' +str(iMax))
|
||||||
@ -874,10 +882,10 @@ class App:
|
|||||||
# if oThread and oThread._stop_thread: return
|
# if oThread and oThread._stop_thread: return
|
||||||
i = i + 1
|
i = i + 1
|
||||||
LOG.debug(f"bootstrapping status # {i}")
|
LOG.debug(f"bootstrapping status # {i}")
|
||||||
self._test_bootstrap()
|
self._test_bootstrap(self._settings['current_nodes_udp'])
|
||||||
if hasattr(self._args, 'proxy_type') and self._args.proxy_type > 0:
|
if hasattr(self._args, 'proxy_type') and self._args.proxy_type > 0:
|
||||||
LOG.debug(f"relaying status # {i}")
|
LOG.debug(f"relaying status # {i}")
|
||||||
self._test_relays()
|
self._test_relays(self._settings['current_nodes_tcp'])
|
||||||
status = self._tox.self_get_connection_status()
|
status = self._tox.self_get_connection_status()
|
||||||
LOG.debug(f"connecting status # {i}" +' : ' +repr(status))
|
LOG.debug(f"connecting status # {i}" +' : ' +repr(status))
|
||||||
if status > 0:
|
if status > 0:
|
||||||
@ -891,41 +899,32 @@ class App:
|
|||||||
if 'proxy_type' not in _settings or _settings['proxy_type'] == 0 or \
|
if 'proxy_type' not in _settings or _settings['proxy_type'] == 0 or \
|
||||||
not _settings['proxy_host'] or not _settings['proxy_port']:
|
not _settings['proxy_host'] or not _settings['proxy_port']:
|
||||||
env = dict( prot = 'ipv4')
|
env = dict( prot = 'ipv4')
|
||||||
|
lElts = self._settings['current_nodes_udp']
|
||||||
elif _settings['proxy_type'] == 2:
|
elif _settings['proxy_type'] == 2:
|
||||||
env = dict(prot = 'socks5',
|
env = dict(prot = 'socks5',
|
||||||
https_proxy='', \
|
https_proxy='', \
|
||||||
socks_proxy='socks5://' \
|
socks_proxy='socks5://' \
|
||||||
+_settings['proxy_host'] +':' \
|
+_settings['proxy_host'] +':' \
|
||||||
+str(_settings['proxy_port']))
|
+str(_settings['proxy_port']))
|
||||||
|
lElts = self._settings['current_nodes_tcp']
|
||||||
elif _settings['proxy_type'] == 1:
|
elif _settings['proxy_type'] == 1:
|
||||||
env = dict(prot = 'https',
|
env = dict(prot = 'https',
|
||||||
socks_proxy='', \
|
socks_proxy='', \
|
||||||
https_proxy='http://' \
|
https_proxy='http://' \
|
||||||
+_settings['proxy_host'] +':' \
|
+_settings['proxy_host'] +':' \
|
||||||
+str(_settings['proxy_port']))
|
+str(_settings['proxy_port']))
|
||||||
if 'current_nodes' in _settings and _settings['current_nodes']:
|
lElts = _settings['current_nodes_tcp']
|
||||||
LOG.debug("Using current nodes "+' : ' +str(len(_settings['current_nodes'])))
|
|
||||||
lElts = _settings['current_nodes']
|
|
||||||
elif _settings['network'] in ['local', 'newlocal']:
|
|
||||||
lElts = lLOCAL
|
|
||||||
elif _settings['network'] in ['main', 'old']:
|
|
||||||
lElts = lGOOD
|
|
||||||
elif 'proxy_type' not in _settings or _settings['proxy_type'] == 0 or \
|
|
||||||
not _settings['proxy_host'] or not _settings['proxy_port']:
|
|
||||||
lElts = lGOOD
|
|
||||||
else:
|
|
||||||
lElts = lRELAYS
|
|
||||||
env['lElts'] = lElts
|
env['lElts'] = lElts
|
||||||
LOG.debug(f"test_env {len(env['lElts'])}")
|
LOG.debug(f"test_env {len(lElts)}")
|
||||||
return env
|
return env
|
||||||
|
|
||||||
def _test_bootstrap(self, lElts=None):
|
def _test_bootstrap(self, lElts=None):
|
||||||
env = self._test_env()
|
env = self._test_env()
|
||||||
if lElts is None:
|
if lElts is None:
|
||||||
lElts = env['lElts']
|
lElts = self._settings['current_nodes_udp']
|
||||||
#shuffle(env['lElts'])
|
shuffle(lElts)
|
||||||
LOG.debug(f"_test_bootstrap #Elts={len(lElts)}")
|
LOG.debug(f"_test_bootstrap #Elts={len(lElts)}")
|
||||||
LOG.trace(f"_test_bootstrap lElts={lElts[:10]}")
|
LOG.trace(f"_test_bootstrap lElts={lElts[:8]}")
|
||||||
shuffle(env['lElts'])
|
shuffle(env['lElts'])
|
||||||
for host,port,key in lElts[:8]:
|
for host,port,key in lElts[:8]:
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user