Opened 2 years ago

Closed 2 years ago

#16174 closed defect (fixed)

stem + ipv6 (+ python3 ?) = " Nickname in the circuit path is malformed (%s)' % nickname"

Reported by: toralf Owned by: atagar
Priority: Medium Milestone:
Component: Core Tor/Stem Version:
Severity: Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

I got with stem-1.4.1 and ipv6 enabled Tor exit relay :

tfoerste@tor-relay ~ $ Exception in thread Event Notifier:
Traceback (most recent call last):
  File "/usr/lib64/python3.3/site-packages/stem/response/events.py", line 844, in _parse
    stem.control._parse_circ_entry(self.endpoint)
  File "/usr/lib64/python3.3/site-packages/stem/control.py", line 3601, in _parse_circ_entry
    raise stem.ProtocolError('Nickname in the circuit path is malformed (%s)' % nickname)
stem.ProtocolError: Nickname in the circuit path is malformed (2607:ff58::d053:df22:52773)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.3/threading.py", line 901, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.3/threading.py", line 858, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib64/python3.3/site-packages/stem/control.py", line 882, in _event_loop
    self._handle_event(event_message)
  File "/usr/lib64/python3.3/site-packages/stem/control.py", line 3474, in _handle_event
    stem.response.convert('EVENT', event_message, arrived_at = time.time())
  File "/usr/lib64/python3.3/site-packages/stem/response/__init__.py", line 135, in convert
    message._parse_message(**kwargs)
  File "/usr/lib64/python3.3/site-packages/stem/response/events.py", line 66, in _parse_message
    self._parse()
  File "/usr/lib64/python3.3/site-packages/stem/response/events.py", line 852, in _parse
    raise stem.ProtocolError("ORCONN's endpoint location's port is invalid: %s" % self)
stem.ProtocolError: ORCONN's endpoint location's port is invalid: ORCONN 2607:ff58::d053:df22:52773 NEW ID=937797

for :

#!/usr/bin/python3 -u
#

#   Toralf Foerster
#   Hamburg
#   Germany

# collect data wrt to https://trac.torproject.org/projects/tor/ticket/13603
#

import time
import functools

#       https://stem.torproject.org/index.html
#
from stem import ORStatus, ORClosureReason
from stem.control import EventType, Controller


def main():
  class Cnt(object):
    def __init__(self, done=0, closed=0, ioerror=0):
      self.done = done
      self.closed = closed
      self.ioerror = ioerror

  c = Cnt()

  with Controller.from_port() as controller:
    controller.authenticate()

    orconn_listener = functools.partial(orconn_event, controller, c)
    controller.add_event_listener(orconn_listener, EventType.ORCONN)

    while True:
      time.sleep(1)

def orconn_event(controller, c, event):
  if event.status == ORStatus.CLOSED:
    c.closed += 1

    if event.reason == ORClosureReason.DONE:
      c.done += 1

    if event.reason == ORClosureReason.IOERROR:
      c.ioerror += 1
      fingerprint = event.endpoint_fingerprint

      try:
        relay = controller.get_network_status(fingerprint)
        print (" %i %i %i %i %s %s %15s %5i %s %s" % (c.closed, c.done, c.ioerror, event.arrived_at, time.ctime(event.arrived_at), fingerprint, relay.address, relay.or_port, controller.get_info("ip-to-country/%s" % relay.address, 'unknown'), relay.nickname))
      except Exception:
        print (" %i %i %i %i %s %s"                % (c.closed, c.done, c.ioerror, event.arrived_at, time.ctime(event.arrived_at), fingerprint))

if __name__ == '__main__':
  main()

Child Tickets

Change History (1)

comment:1 Changed 2 years ago by atagar

Resolution: fixed
Status: newclosed

Hi toralf, great catch! I made this error quite a number of times throughout the codebase, fixed.

Don't hesitate to let me know if I missed anything and thanks for letting me know!

Note: See TracTickets for help on using tickets.