Commit 889fde3b authored by Julien Muchembled's avatar Julien Muchembled

Drop support for Python 2.6

Commit 40d4e496 is not reverted
because Python 3 will also require to keep the distinction between
blob and text.
parent c8b11bf3
...@@ -52,7 +52,7 @@ easily scalable to tens of thousand of nodes. ...@@ -52,7 +52,7 @@ easily scalable to tens of thousand of nodes.
Requirements Requirements
============ ============
- Python 2.6 or 2.7 - Python 2.7
- OpenSSL binary and development libraries - OpenSSL binary and development libraries
- OpenVPN >= 2.4 - OpenVPN >= 2.4
- Babel_ (with Nexedi patches) - Babel_ (with Nexedi patches)
......
...@@ -166,7 +166,7 @@ def main(): ...@@ -166,7 +166,7 @@ def main():
config.disable_proto = () config.disable_proto = ()
if config.default: if config.default:
# Make sure we won't tunnel over re6st. # Make sure we won't tunnel over re6st.
config.disable_proto = tuple(set(('tcp6', 'udp6')).union( config.disable_proto = tuple({'tcp6', 'udp6'}.union(
config.disable_proto)) config.disable_proto))
address = [] address = []
server_tunnels = {} server_tunnels = {}
......
...@@ -262,7 +262,7 @@ class Babel(object): ...@@ -262,7 +262,7 @@ class Babel(object):
def handle_dump(self, interfaces, neighbours, xroutes, routes): def handle_dump(self, interfaces, neighbours, xroutes, routes):
# neighbours = {neigh_prefix: (neighbour, {dst_prefix: route})} # neighbours = {neigh_prefix: (neighbour, {dst_prefix: route})}
n = dict(((n.address, n.ifindex), (n, {})) for n in neighbours) n = {(n.address, n.ifindex): (n, {}) for n in neighbours}
unidentified = set(n) unidentified = set(n)
self.neighbours = neighbours = {} self.neighbours = neighbours = {}
a = len(self.network) a = len(self.network)
...@@ -307,7 +307,7 @@ class Babel(object): ...@@ -307,7 +307,7 @@ class Babel(object):
neighbours[None] = None, routes neighbours[None] = None, routes
logging.trace("Routes via unidentified neighbours. %r", logging.trace("Routes via unidentified neighbours. %r",
neighbours) neighbours)
self.interfaces = dict((i.index, name) for i, name in interfaces) self.interfaces = {i.index: name for i, name in interfaces}
self.handler.babel_dump() self.handler.babel_dump()
def handle_set_cost_multiplier(self, flags): def handle_set_cost_multiplier(self, flags):
......
...@@ -213,8 +213,7 @@ class RegistryServer(object): ...@@ -213,8 +213,7 @@ class RegistryServer(object):
not_after = None not_after = None
old = time.time() - GRACE_PERIOD old = time.time() - GRACE_PERIOD
q = self.db.execute q = self.db.execute
with self.lock: with self.lock, self.db:
with self.db:
q("BEGIN") q("BEGIN")
for token, x in q("SELECT token, date FROM token"): for token, x in q("SELECT token, date FROM token"):
if x <= old: if x <= old:
...@@ -539,8 +538,7 @@ class RegistryServer(object): ...@@ -539,8 +538,7 @@ class RegistryServer(object):
@rpc_private @rpc_private
def revoke(self, cn_or_serial): def revoke(self, cn_or_serial):
with self.lock: with self.lock, self.db:
with self.db:
q = self.db.execute q = self.db.execute
try: try:
serial = int(cn_or_serial) serial = int(cn_or_serial)
...@@ -570,8 +568,7 @@ class RegistryServer(object): ...@@ -570,8 +568,7 @@ class RegistryServer(object):
@rpc_private @rpc_private
def updateHMAC(self): def updateHMAC(self):
with self.lock: with self.lock, self.db:
with self.db:
hmac = [self.getConfig(BABEL_HMAC[i], None) for i in (0,1,2)] hmac = [self.getConfig(BABEL_HMAC[i], None) for i in (0,1,2)]
if hmac[0]: if hmac[0]:
if hmac[1]: if hmac[1]:
...@@ -595,8 +592,7 @@ class RegistryServer(object): ...@@ -595,8 +592,7 @@ class RegistryServer(object):
@rpc_private @rpc_private
def getNodePrefix(self, email): def getNodePrefix(self, email):
with self.lock: with self.lock, self.db:
with self.db:
try: try:
cert, = self.db.execute("SELECT cert FROM cert WHERE email = ?", cert, = self.db.execute("SELECT cert FROM cert WHERE email = ?",
(email,)).next() (email,)).next()
...@@ -636,10 +632,10 @@ class RegistryServer(object): ...@@ -636,10 +632,10 @@ class RegistryServer(object):
def versions(self): def versions(self):
with self.peers_lock: with self.peers_lock:
self.request_dump() self.request_dump()
peers = set(prefix peers = {prefix
for neigh_routes in self.ctl.neighbours.itervalues() for neigh_routes in self.ctl.neighbours.itervalues()
for prefix in neigh_routes[1] for prefix in neigh_routes[1]
if prefix) if prefix}
peers.add(self.prefix) peers.add(self.prefix)
peer_dict = {} peer_dict = {}
s = self.sock, s = self.sock,
...@@ -686,7 +682,7 @@ class RegistryServer(object): ...@@ -686,7 +682,7 @@ class RegistryServer(object):
self.sendto(utils.binFromSubnet(peers.popleft()), 5) self.sendto(utils.binFromSubnet(peers.popleft()), 5)
elif not r: elif not r:
break break
return json.dumps(dict((k, list(v)) for k, v in graph.iteritems())) return json.dumps({k: list(v) for k, v in graph.iteritems()})
class RegistryClient(object): class RegistryClient(object):
......
...@@ -239,9 +239,9 @@ class BaseTunnelManager(object): ...@@ -239,9 +239,9 @@ class BaseTunnelManager(object):
elif cache.same_country: elif cache.same_country:
sys.exit("Can not respect 'same_country' network configuration" sys.exit("Can not respect 'same_country' network configuration"
" (GEOIP2_MMDB not set)") " (GEOIP2_MMDB not set)")
self._address = dict((family, utils.dump_address(address)) self._address = {family: utils.dump_address(address)
for family, address in address_dict.iteritems() for family, address in address_dict.iteritems()
if address) if address}
self.sock = socket.socket(socket.AF_INET6, self.sock = socket.socket(socket.AF_INET6,
socket.SOCK_DGRAM | socket.SOCK_CLOEXEC) socket.SOCK_DGRAM | socket.SOCK_CLOEXEC)
...@@ -903,10 +903,10 @@ class TunnelManager(BaseTunnelManager): ...@@ -903,10 +903,10 @@ class TunnelManager(BaseTunnelManager):
logging.debug('Analyze routes ...') logging.debug('Analyze routes ...')
neighbours = self.ctl.neighbours neighbours = self.ctl.neighbours
# Collect all nodes known by Babel # Collect all nodes known by Babel
peers = set(prefix peers = {prefix
for neigh_routes in neighbours.itervalues() for neigh_routes in neighbours.itervalues()
for prefix in neigh_routes[1] for prefix in neigh_routes[1]
if prefix) if prefix}
# Keep only distant peers. # Keep only distant peers.
distant_peers[:] = peers.difference(neighbours) distant_peers[:] = peers.difference(neighbours)
distant_peers.sort(key=self._newTunnelScore) distant_peers.sort(key=self._newTunnelScore)
......
...@@ -51,7 +51,6 @@ Environment :: Console ...@@ -51,7 +51,6 @@ Environment :: Console
License :: OSI Approved :: GNU General Public License (GPL) License :: OSI Approved :: GNU General Public License (GPL)
Natural Language :: English Natural Language :: English
Operating System :: POSIX :: Linux Operating System :: POSIX :: Linux
Programming Language :: Python :: 2.6
Programming Language :: Python :: 2.7 Programming Language :: Python :: 2.7
Topic :: Internet Topic :: Internet
Topic :: System :: Networking Topic :: System :: Networking
......
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