Commit d496e4b8 authored by Joanne Hugé's avatar Joanne Hugé

Remove backwards compatibility and set min_protocol to 7

parent ba573ab7
...@@ -548,10 +548,6 @@ class RegistryServer(object): ...@@ -548,10 +548,6 @@ class RegistryServer(object):
msg = self._queryAddress(peer) msg = self._queryAddress(peer)
if msg is None: if msg is None:
return return
# Remove country for old nodes
if self.getPeerProtocol(cn) < 7:
msg = ';'.join(','.join(a.split(',')[:3])
for a in msg.split(';'))
cert = self.getCert(cn) cert = self.getCert(cn)
msg = "%s %s" % (peer, msg) msg = "%s %s" % (peer, msg)
logging.info("Sending bootstrap peer: %s", msg) logging.info("Sending bootstrap peer: %s", msg)
......
...@@ -195,7 +195,6 @@ class BaseTunnelManager(object): ...@@ -195,7 +195,6 @@ class BaseTunnelManager(object):
'babel_hmac_sign', 'encrypt', 'babel_hmac_sign', 'encrypt',
'hello', 'ipv4', 'ipv4_sublen')) 'hello', 'ipv4', 'ipv4_sublen'))
_geoiplookup = None
_forward = None _forward = None
_next_rina = True _next_rina = True
...@@ -229,16 +228,6 @@ class BaseTunnelManager(object): ...@@ -229,16 +228,6 @@ class BaseTunnelManager(object):
} == address_dict: } == address_dict:
address_dict = cache_dict address_dict = cache_dict
db = os.getenv('GEOIP2_MMDB')
if db:
from geoip2 import database, errors
country = database.Reader(db).country
def geoiplookup(ip):
try:
return country(ip).country.iso_code.encode()
except errors.AddressNotFoundError:
return
self._geoiplookup = geoiplookup
if cache.same_country: if cache.same_country:
self._country = {} self._country = {}
...@@ -392,7 +381,6 @@ class BaseTunnelManager(object): ...@@ -392,7 +381,6 @@ class BaseTunnelManager(object):
msg = peer.decode(msg) msg = peer.decode(msg)
if type(msg) is tuple: if type(msg) is tuple:
seqno, msg, protocol = msg seqno, msg, protocol = msg
def handleHello(peer, seqno, msg, retry):
if seqno == 2: if seqno == 2:
i = len(msg) // 2 i = len(msg) // 2
h = msg[:i] h = msg[:i]
...@@ -419,8 +407,6 @@ class BaseTunnelManager(object): ...@@ -419,8 +407,6 @@ class BaseTunnelManager(object):
if serial in self.cache.crl: if serial in self.cache.crl:
raise ValueError("revoked") raise ValueError("revoked")
except (x509.VerifyError, ValueError), e: except (x509.VerifyError, ValueError), e:
if retry:
return True
logging.debug('ignored invalid certificate from %r (%s)', logging.debug('ignored invalid certificate from %r (%s)',
address, e.args[-1]) address, e.args[-1])
return return
...@@ -442,12 +428,6 @@ class BaseTunnelManager(object): ...@@ -442,12 +428,6 @@ class BaseTunnelManager(object):
msg = peer.hello0(self.cert.cert) msg = peer.hello0(self.cert.cert)
if msg and self._sendto(to, msg): if msg and self._sendto(to, msg):
peer.hello0Sent() peer.hello0Sent()
if handleHello(peer, seqno, msg, seqno):
# It is possible to reconstruct the original message because
# the serialization of the protocol version is always unique.
msg = utils.packInteger(protocol) + msg
protocol = 0
handleHello(peer, seqno, msg, False)
elif msg: elif msg:
# We got a valid and non-empty message. Always reply # We got a valid and non-empty message. Always reply
# something so that the sender knows we're still connected. # something so that the sender knows we're still connected.
...@@ -471,11 +451,6 @@ class BaseTunnelManager(object): ...@@ -471,11 +451,6 @@ class BaseTunnelManager(object):
return return
self._makeTunnel(peer, msg) self._makeTunnel(peer, msg)
else: else:
if peer:
# Don't send country to old nodes
if self._getPeer(peer).protocol < 7:
return ';'.join(','.join(a.split(',')[:3]) for a in
';'.join(self._address.itervalues()).split(';'))
return ';'.join(self._address.itervalues()) return ';'.join(self._address.itervalues())
elif not code: # network version elif not code: # network version
if peer: if peer:
...@@ -886,12 +861,13 @@ class TunnelManager(BaseTunnelManager): ...@@ -886,12 +861,13 @@ class TunnelManager(BaseTunnelManager):
if x[2] in self._disable_proto: if x[2] in self._disable_proto:
continue continue
if same_country: if same_country:
if len(x) < 4:
continue
family, ip = resolve(*x[:3]) family, ip = resolve(*x[:3])
my_country = self._country.get(family, self._conf_country) my_country = self._country.get(family, self._conf_country)
if my_country: if my_country:
for ip in ip: for ip in ip:
# Use geoip if there is no country in the address country = x[3]
country = x[3] if len(x) > 3 else self._geoiplookup(ip)
if country and (country != my_country if country and (country != my_country
if my_country in same_country else if my_country in same_country else
country in same_country): country in same_country):
......
...@@ -233,7 +233,7 @@ def ipFromBin(ip, suffix=''): ...@@ -233,7 +233,7 @@ def ipFromBin(ip, suffix=''):
def dump_address(address): def dump_address(address):
return ';'.join(map(','.join, address)) return ';'.join(map(','.join, address))
# Yield ip, port, protocol, and country if it is in the address # Yield ip, port, protocol, and country
def parse_address(address_list): def parse_address(address_list):
for address in address_list.split(';'): for address in address_list.split(';'):
try: try:
......
...@@ -32,8 +32,8 @@ if dirty: ...@@ -32,8 +32,8 @@ if dirty:
# they are intended to the network admin. # they are intended to the network admin.
# Only 'protocol' is important and it must be increased whenever they would be # Only 'protocol' is important and it must be increased whenever they would be
# a wish to force an update of nodes. # a wish to force an update of nodes.
protocol = 7 protocol = 8
min_protocol = 1 min_protocol = 7
if __name__ == "__main__": if __name__ == "__main__":
print version print version
...@@ -229,8 +229,6 @@ class Peer(object): ...@@ -229,8 +229,6 @@ class Peer(object):
def hello0(self, cert): def hello0(self, cert):
if self._hello < time.time(): if self._hello < time.time():
try: try:
# Always assume peer is not old, in case it has just upgraded,
# else we would be stuck with the old protocol.
msg = ('\0\0\0\1' msg = ('\0\0\0\1'
+ PACKED_PROTOCOL + PACKED_PROTOCOL
+ fingerprint(self.cert).digest()) + fingerprint(self.cert).digest())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment