meejah / txtorcon

Twisted-based asynchronous Tor control protocol implementation. Includes unit-tests, examples, state-tracking code and configuration abstraction.
http://fjblvrw2jrxnhtg67qpbzi45r7ofojaoo3orzykesly2j3c2m3htapid.onion/
MIT License
250 stars 72 forks source link

Microdescriptor parsing (expecting `s', but receiving `a')? #47

Closed peer-zero closed 11 years ago

peer-zero commented 11 years ago

Running the included launch_tor.py script yields:

$ python launch_tor.py 
10%: Finishing handshake with directory server
15%: Establishing an encrypted directory connection
20%: Asking for networkstatus consensus
25%: Loading networkstatus consensus
40%: Loading authority key certs
45%: Asking for relay descriptors
50%: Loading relay descriptors
53%: Loading relay descriptors
56%: Loading relay descriptors
59%: Loading relay descriptors
63%: Loading relay descriptors
66%: Loading relay descriptors
69%: Loading relay descriptors
73%: Loading relay descriptors
76%: Loading relay descriptors
76%: Loading relay descriptors
80%: Connecting to the Tor network
85%: Finishing handshake with first hop
90%: Establishing a Tor circuit
100%: Done
setup complete: <txtorcon.torconfig.TorProcessProtocol instance at 0x2902dd0>
Building a TorState
Unhandled Error
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/twisted/python/log.py", line 84, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/lib64/python2.7/site-packages/twisted/python/log.py", line 69, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/lib64/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/lib64/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/usr/lib64/python2.7/site-packages/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
    why = selectable.doRead()
  File "/usr/lib64/python2.7/site-packages/twisted/internet/tcp.py", line 203, in doRead
    return self._dataReceived(data)
  File "/usr/lib64/python2.7/site-packages/twisted/internet/tcp.py", line 209, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "/usr/lib64/python2.7/site-packages/twisted/internet/endpoints.py", line 86, in dataReceived
    return self._wrappedProtocol.dataReceived(data)
  File "/usr/lib64/python2.7/site-packages/twisted/protocols/basic.py", line 455, in dataReceived
    self.lineReceived(line)
  File "/usr/lib/python2.7/site-packages/txtorcon-0.7-py2.7.egg/txtorcon/torcontrolprotocol.py", line 492, in lineReceived
    self.fsm.process(line)
  File "/usr/lib/python2.7/site-packages/txtorcon-0.7-py2.7.egg/txtorcon/spaghetti.py", line 28, in process
    next_state = self.state.process(data)
  File "/usr/lib/python2.7/site-packages/txtorcon-0.7-py2.7.egg/txtorcon/spaghetti.py", line 57, in process
    r = t.process(data)
  File "/usr/lib/python2.7/site-packages/txtorcon-0.7-py2.7.egg/txtorcon/spaghetti.py", line 127, in process
    return self.handle(data)
  File "/usr/lib/python2.7/site-packages/txtorcon-0.7-py2.7.egg/txtorcon/spaghetti.py", line 116, in handle
    state = self.handler(data)
  File "/usr/lib/python2.7/site-packages/txtorcon-0.7-py2.7.egg/txtorcon/torcontrolprotocol.py", line 706, in _accumulate_multi_response
    self.command[2](line)
  File "/usr/lib/python2.7/site-packages/txtorcon-0.7-py2.7.egg/txtorcon/spaghetti.py", line 28, in process
    next_state = self.state.process(data)
  File "/usr/lib/python2.7/site-packages/txtorcon-0.7-py2.7.egg/txtorcon/spaghetti.py", line 57, in process
    r = t.process(data)
  File "/usr/lib/python2.7/site-packages/txtorcon-0.7-py2.7.egg/txtorcon/spaghetti.py", line 127, in process
    return self.handle(data)
  File "/usr/lib/python2.7/site-packages/txtorcon-0.7-py2.7.egg/txtorcon/spaghetti.py", line 116, in handle
    state = self.handler(data)
  File "/usr/lib/python2.7/site-packages/txtorcon-0.7-py2.7.egg/txtorcon/torstate.py", line 194, in __call__
    raise RuntimeError(self.msg % tuple(args))
exceptions.RuntimeError: Expected "s " while parsing routers not "a [x:x:x:x::x]:x"

where x is a placeholder.

meejah commented 11 years ago

Thank you, I have re-created this with a new Tor.

(Perhaps time to leverage Stem?)

meejah commented 11 years ago

That should fix your issue for now, needs a little more thinking API-wise at least...

peer-zero commented 11 years ago

Thank you for the interim fix.