# Path: src/foolscap/furl.py
# class BadFURLError(Exception):
#     pass


import os.path, weakref, binascii, re
import six
from warnings import warn
from zope.interface import implementer
from twisted.internet import (reactor, defer, protocol, error, interfaces,
                              endpoints)
from twisted.application import service
from twisted.python.failure import Failure
from twisted.python.deprecate import deprecated
from twisted.python.versions import Version
from foolscap import ipb, base32, negotiate, broker, eventual, storage
from foolscap import connection, util, info
from foolscap.connections import tcp
from foolscap.referenceable import SturdyRef
from .furl import BadFURLError
from foolscap.tokens import PBError, BananaError, WrongTubIdError, \
     WrongNameError, NoLocationError
from foolscap.reconnector import Reconnector
from foolscap.logging import log as flog
from foolscap.logging import log
from foolscap.logging import publish as flog_publish
from foolscap.logging.log import UNUSUAL
from foolscap import crypto
        if isinstance(what, six.string_types) and re.search(r"^\d+$", what):
            warn("Tub.listenOn('12345') was deprecated "
                 "in Foolscap 0.12.0; please use qualified endpoint "
                 "descriptions like 'tcp:12345'",
                 DeprecationWarning, stacklevel=2)
            what = "tcp:%s" % what

        l = Listener(self, what, _test_options, self.negotiationClass)
        self.listeners.append(l)
        l.setServiceParent(self)
        return l

    def stopListeningOn(self, l):
        # this returns a Deferred when the port is shut down
        self.listeners.remove(l)
        return l.disownServiceParent()

    def getListeners(self):
        """Return the set of Listener objects that allow the outside world to
        connect to this Tub."""
        return self.listeners[:]

    def getTubID(self):
        return self.tubID
    def getShortTubID(self):
        return self.tubID[:4]

    def getConnectionInfoForFURL(self, furl):
        try:
            tubref = SturdyRef(furl).getTubRef()

# Path: src/foolscap/furl.py
# class BadFURLError(Exception):
#     pass


# Path: src/foolscap/pb.py
import os.path, weakref, binascii, re
import six
from warnings import warn
from zope.interface import implementer
from twisted.internet import (reactor, defer, protocol, error, interfaces,
                              endpoints)
from twisted.application import service
from twisted.python.failure import Failure
from twisted.python.deprecate import deprecated
from twisted.python.versions import Version
from foolscap import ipb, base32, negotiate, broker, eventual, storage
from foolscap import connection, util, info
from foolscap.connections import tcp
from foolscap.referenceable import SturdyRef
from .furl import BadFURLError
from foolscap.tokens import PBError, BananaError, WrongTubIdError, \
     WrongNameError, NoLocationError
from foolscap.reconnector import Reconnector
from foolscap.logging import log as flog
from foolscap.logging import log
from foolscap.logging import publish as flog_publish
from foolscap.logging.log import UNUSUAL
from foolscap import crypto

        if isinstance(what, six.string_types) and re.search(r"^\d+$", what):
            warn("Tub.listenOn('12345') was deprecated "
                 "in Foolscap 0.12.0; please use qualified endpoint "
                 "descriptions like 'tcp:12345'",
                 DeprecationWarning, stacklevel=2)
            what = "tcp:%s" % what

        l = Listener(self, what, _test_options, self.negotiationClass)
        self.listeners.append(l)
        l.setServiceParent(self)
        return l

    def stopListeningOn(self, l):
        # this returns a Deferred when the port is shut down
        self.listeners.remove(l)
        return l.disownServiceParent()

    def getListeners(self):
        """Return the set of Listener objects that allow the outside world to
        connect to this Tub."""
        return self.listeners[:]

    def getTubID(self):
        return self.tubID
    def getShortTubID(self):
        return self.tubID[:4]

    def getConnectionInfoForFURL(self, furl):
        try:
            tubref = SturdyRef(furl).getTubRef()

        except (ValueError, BadFURLError):