X-Git-Url: https://git.distorted.org.uk/~mdw/tripe/blobdiff_plain/f688828b41c1125b07f4f2f57ec536b8f5229582..102fa2f087554901001abcd106160a4ea0668206:/svc/connect.in diff --git a/svc/connect.in b/svc/connect.in index 607a6561..b6ec4b8c 100644 --- a/svc/connect.in +++ b/svc/connect.in @@ -296,12 +296,15 @@ class Peer (object): a FILTER function is given then apply it to the information from the database before returning it. """ - attr = me.__dict__.get(key, default) - if attr is _magic: - raise T.TripeJobError('malformed-peer', me.name, 'missing-key', key) - elif filter is not None: - attr = filter(attr) - return attr + try: + attr = me.__dict__[key] + except KeyError: + if default is _magic: + raise T.TripeJobError('malformed-peer', me.name, 'missing-key', key) + return default + else: + if filter is not None: attr = filter(attr) + return attr def has(me, key): """ @@ -722,14 +725,13 @@ def addpeer(peer, addr): if peer.name in S.list(): S.kill(peer.name) try: - booltrue = ['t', 'true', 'y', 'yes', 'on'] S.add(peer.name, - tunnel = peer.get('tunnel', None), - keepalive = peer.get('keepalive', None), - key = peer.get('key', None), - priv = peer.get('priv', None), - mobile = peer.get('mobile', 'nil') in booltrue, - cork = peer.get('cork', 'nil') in booltrue, + tunnel = peer.get('tunnel', default = None), + keepalive = peer.get('keepalive', default = None), + key = peer.get('key', default = None), + priv = peer.get('priv', default = None), + mobile = peer.get('mobile', filter = boolean, default = False), + cork = peer.get('cork', filter = boolean, default = False), *addr) except T.TripeError, exc: raise T.TripeJobError(*exc.args)