chiark
/
gitweb
/
~mdw
/
tripe
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Allow different peer associations to use different private keys.
[tripe]
/
py
/
tripe.py.in
diff --git
a/py/tripe.py.in
b/py/tripe.py.in
index 2e21885b8797ba7e18c3a4af009ffd0a41d3a36a..c2b430be5e6e656b7bc7a6556b25054e0c4bc26b 100644
(file)
--- a/
py/tripe.py.in
+++ b/
py/tripe.py.in
@@
-128,7
+128,9
@@
class Coroutine (_Coroutine):
"""
def switch(me, *args, **kw):
assert _Coroutine.getcurrent() is rootcr
"""
def switch(me, *args, **kw):
assert _Coroutine.getcurrent() is rootcr
+ if _debug: print '* %s' % me
_Coroutine.switch(me, *args, **kw)
_Coroutine.switch(me, *args, **kw)
+ if _debug: print '* %s' % rootcr
###--------------------------------------------------------------------------
### Default places for things.
###--------------------------------------------------------------------------
### Default places for things.
@@
-610,9
+612,16
@@
def defer(func, *args, **kw):
"""Call FUNC(*ARGS, **KW) later, in the root coroutine."""
_deferq.append((func, args, kw))
"""Call FUNC(*ARGS, **KW) later, in the root coroutine."""
_deferq.append((func, args, kw))
+def funargstr(func, args, kw):
+ items = [repr(a) for a in args]
+ for k, v in kw.iteritems():
+ items.append('%s = %r' % (k, v))
+ return '%s(%s)' % (func.__name__, ', '.join(items))
+
def spawn(func, *args, **kw):
"""Call FUNC, passing ARGS and KW, in a fresh coroutine."""
def spawn(func, *args, **kw):
"""Call FUNC, passing ARGS and KW, in a fresh coroutine."""
- defer(lambda: Coroutine(func).switch(*args, **kw))
+ defer(lambda: (Coroutine(func, name = funargstr(func, args, kw))
+ .switch(*args, **kw)))
## Asides.
_asideq = Queue()
## Asides.
_asideq = Queue()
@@
-702,7
+711,9
@@
class TripeCommandDispatcher (TripeConnection):
global _deferq
assert _Coroutine.getcurrent() is rootcr
global _deferq
assert _Coroutine.getcurrent() is rootcr
- Coroutine(_runasides).switch()
+ Coroutine(_runasides, name = '_runasides').switch()
+ if quitp is None:
+ quitp = me.quitp
while not quitp():
while _deferq:
q = _deferq
while not quitp():
while _deferq:
q = _deferq
@@
-819,13
+830,16
@@
class TripeCommandDispatcher (TripeConnection):
def add(me, peer, *addr, **kw):
return _simple(me.command(bg = True,
*['ADD'] +
def add(me, peer, *addr, **kw):
return _simple(me.command(bg = True,
*['ADD'] +
- _kwopts(kw, ['tunnel', 'keepalive', 'cork']) +
+ _kwopts(kw, ['tunnel', 'keepalive',
+ 'key', 'priv', 'cork',
+ 'mobile']) +
[peer] +
list(addr)))
def addr(me, peer):
return _oneline(me.command('ADDR', peer))
[peer] +
list(addr)))
def addr(me, peer):
return _oneline(me.command('ADDR', peer))
- def algs(me):
- return _keyvals(me.command('ALGS'))
+ def algs(me, peer = None):
+ return _keyvals(me.command('ALGS',
+ *((peer is not None and [peer]) or [])))
def checkchal(me, chal):
return _simple(me.command('CHECKCHAL', chal))
def daemon(me):
def checkchal(me, chal):
return _simple(me.command('CHECKCHAL', chal))
def daemon(me):