Changes in SOCKS and onion handling in connectionchooser
- onion addresses have a priority of 1 when SOCKS is on - don't connect to private/loopback addresses when SOCKS is on
This commit is contained in:
parent
7b470d4b66
commit
ab458531e8
|
@ -3,6 +3,7 @@ import random
|
||||||
|
|
||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
import knownnodes
|
import knownnodes
|
||||||
|
import protocol
|
||||||
from queues import portCheckerQueue
|
from queues import portCheckerQueue
|
||||||
import state
|
import state
|
||||||
|
|
||||||
|
@ -38,8 +39,15 @@ def chooseConnection(stream):
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print "Error in %s" % (peer)
|
print "Error in %s" % (peer)
|
||||||
rating = 0
|
rating = 0
|
||||||
if haveOnion and peer.host.endswith('.onion') and rating > 0:
|
if haveOnion:
|
||||||
rating *= 10
|
# onion addresses have a higher priority when SOCKS
|
||||||
|
if peer.host.endswith('.onion') and rating > 0:
|
||||||
|
rating = 1
|
||||||
|
else:
|
||||||
|
encodedAddr = protocol.encodeHost(peer.host)
|
||||||
|
# don't connect to local IPs when using SOCKS
|
||||||
|
if not protocol.checkIPAddress(encodedAddr, False):
|
||||||
|
continue
|
||||||
if rating > 1:
|
if rating > 1:
|
||||||
rating = 1
|
rating = 1
|
||||||
try:
|
try:
|
||||||
|
|
Reference in New Issue
Block a user