Exemplo n.º 1
0
 def stopSIP(self):
     from shtoom.nat import getMapper
     log.msg("stopping SIP, and unmapping it (%r)"%(self._NATMapping,))
     if self._NATMapping:
         d = getMapper()
         d.addCallback(self._cb_unmapSipPort).addErrback(log.err)
         return d
     else:
         self._cb_unmapSipPort(None)
Exemplo n.º 2
0
 def connectSIP(self):
     from twisted.internet import reactor
     from shtoom import sip
     from shtoom.nat import getMapper
     p = sip.SipProtocol(self)
     self.sip = p
     lport = self.getPref('listenport')
     if lport is None:
         lport = 5060
     self.sipListener = reactor.listenUDP(lport, p)
     listenport = self.sipListener.getHost().port
     if lport == 0:
         self.getOptions().setValue('listenport', listenport, dynamic=True)
     log.msg('sip listener installed on %d'%(listenport), system='app')
     if self._NATMapping:
         getMapper().addCallback(self._cb_mapSipPort)
     else:
         self._cb_mapSipPort(None)
Exemplo n.º 3
0
def main():
    from twisted.internet import defer
    from shtoom.upnp import getUPnP
    from shtoom.stun import getSTUN
    from shtoom.nat import getLocalIPAddress, getMapper
    ud = getUPnP()
    sd = getSTUN()
    ld = getLocalIPAddress()
    md = getMapper()
    dl = defer.DeferredList([ud, sd, ld, md])
    dl.addCallback(gotResults).addErrback(didntGetResults)
Exemplo n.º 4
0
def main():
    from twisted.internet import defer
    from shtoom.upnp import getUPnP
    from shtoom.stun import getSTUN
    from shtoom.nat import getLocalIPAddress, getMapper
    ud = getUPnP()
    sd = getSTUN()
    ld = getLocalIPAddress()
    md = getMapper()
    dl = defer.DeferredList([ud, sd, ld, md])
    dl.addCallback(gotResults).addErrback(didntGetResults)
Exemplo n.º 5
0
 def natMapping(self):
     ''' Uses STUN to discover the external address for the RTP/RTCP
         ports. deferred is a Deferred to be triggered when STUN is
         complete.
     '''
     # See above comment about port translation.
     # We have to do STUN for both RTP and RTCP, and hope we get a sane
     # answer.
     from shtoom.nat import getMapper
     d = getMapper()
     d.addCallback(self._cb_gotMapper)
     return d
Exemplo n.º 6
0
 def natMapping(self):
     ''' Uses STUN to discover the external address for the RTP/RTCP
         ports. deferred is a Deferred to be triggered when STUN is
         complete.
     '''
     # See above comment about port translation.
     # We have to do STUN for both RTP and RTCP, and hope we get a sane
     # answer.
     from shtoom.nat import getMapper
     d = getMapper()
     d.addCallback(self._cb_gotMapper)
     return d
Exemplo n.º 7
0
 def unmapRTP(self):
     from shtoom.nat import getMapper
     if self.needSTUN is False:
         return defer.succeed(None)
     # Currently removing an already-fired trigger doesn't hurt,
     # but this seems likely to change.
     try:
         reactor.removeSystemEventTrigger(self._shutdownHook)
     except:
         pass
     d = getMapper()
     d.addCallback(self._cb_unmap_gotMapper)
     return d
Exemplo n.º 8
0
 def unmapRTP(self):
     from shtoom.nat import getMapper
     if self.needSTUN is False:
         return defer.succeed(None)
     # Currently removing an already-fired trigger doesn't hurt,
     # but this seems likely to change.
     try:
         reactor.removeSystemEventTrigger(self._shutdownHook)
     except:
         pass
     d = getMapper()
     d.addCallback(self._cb_unmap_gotMapper)
     return d