示例#1
0
 def prepare(self, local_uri=None, logger=None):
     """Start a listening port specified by local_uri if there isn't one on that port/interface already.
     Add `local_uri' to the list of expected URIs, so that incoming connections featuring this URI won't be rejected.
     If `logger' is provided use it for this connection instead of the default one.
     """
     local_uri = local_uri or protocol.URI(port=2855)
     need_listen = True
     if local_uri.port:
         use_tls, listening_port = self.ports.get(local_uri.host, {}).get(
             local_uri.port, (None, None))
         if listening_port is not None:
             if use_tls == local_uri.use_tls:
                 need_listen = False
             else:
                 listening_port.stopListening()
                 sleep(
                     0
                 )  # make the reactor really stop listening, so that the next listen() call won't fail
                 self.ports.pop(local_uri.host,
                                {}).pop(local_uri.port, None)
     else:
         # caller does not care about port number
         for (use_tls, port) in self.ports[local_uri.host]:
             if local_uri.use_tls == use_tls:
                 local_uri.port = port.getHost().port
                 need_listen = False
     if need_listen:
         port = self._listen(local_uri, self.factory)
         self.ports.setdefault(local_uri.host,
                               {})[local_uri.port] = (local_uri.use_tls,
                                                      port)
     self.expected_local_uris[local_uri] = logger
     self.local_uri = local_uri
     return [local_uri]
示例#2
0
    def prepare(self, local_uri=None):
        """Start listening for an incoming MSRP connection using port and
        use_tls from local_uri if provided.

        Return full local path, suitable to put in SDP a:path attribute.
        Note, that `local_uri' may be updated in place.
        """
        local_uri = local_uri or protocol.URI(port=0)
        self.transport_event = coros.event()
        local_uri.host = gethostbyname(local_uri.host)
        factory = SpawnFactory(self.transport_event,
                               MSRPTransport,
                               local_uri,
                               logger=self.logger,
                               use_sessmatch=self.use_sessmatch)
        self.listening_port = self._listen(local_uri, factory)
        self.local_uri = local_uri
        return [local_uri]
示例#3
0
 def prepare(self, local_uri=None):
     self.local_uri = local_uri or protocol.URI(port=0)
     self.msrp = self._relay_connect_timeout()
     return self.msrp.full_local_path
示例#4
0
 def prepare(self, local_uri=None):
     local_uri = local_uri or protocol.URI(port=0)
     local_uri.port = local_uri.port or 2855
     self.local_uri = local_uri
     return [local_uri]
示例#5
0
 def uri_domain(self):
     return protocol.URI(host=self.domain,
                         port=self.port,
                         use_tls=self.use_tls,
                         session_id='')
示例#6
0
 def get_server_uri(self):
     return pr.URI(port=0,
                   use_tls=self.use_tls,
                   credentials=self.server_credentials)
示例#7
0
 def get_client_uri(self):
     return pr.URI(use_tls=self.use_tls)