Пример #1
0
 def getRegistrationInfo(self, caller):
     registered = False
     if self.physicalURL is not None:
         now = time.time()
         if now < self.expiryTime.asPOSIXTimestamp():
             registered = True
     if registered:
         return [(sip.parseURL(self.physicalURL), int(self.expiryTime.asPOSIXTimestamp() - now))]
     elif self.altcontact:
         return [(sip.parseURL(self.altcontact), -1)]
     else:
         return defer.fail(sip.RegistrationError(480))
Пример #2
0
 def getRegistrationInfo(self, caller):
     registered = False
     if self.physicalURL is not None:
         now = time.time()
         if now < self.expiryTime.asPOSIXTimestamp():
             registered = True
     if registered:
         return [(sip.parseURL(self.physicalURL),
                  int(self.expiryTime.asPOSIXTimestamp() - now))]
     elif self.altcontact:
         return [(sip.parseURL(self.altcontact), -1)]
     else:
         return defer.fail(sip.RegistrationError(480))
Пример #3
0
    def startService(self):
        tacPath = sibpath(sine.__file__, "media.tac")
        self.mediaController = batch.ProcessController(
            "rtp-transceiver",
            useragent.LocalControlProtocol(False),
            tacPath=tacPath)

        if self.pstn:
            pstnurl = sip.parseURL(self.pstn)
            portal = PSTNPortalWrapper(Portal(self.userbase, [self.userbase]),
                                       pstnurl.host, pstnurl.port)
        else:
            portal = Portal(self.userbase, [self.userbase])
        self.proxy = sip.Proxy(portal)
        self.dispatcher = sip.SIPDispatcher(portal, self.proxy)
        regs = list(self.store.query(Registration,
                                     Registration.parent == self))
        if regs:
            rc = sip.RegistrationClient()
            self.proxy.installRegistrationClient(rc)
            for reg in regs:
                if not (reg.username and reg.domain):
                    raise SIPConfigurationError(
                        "Bad registration URL:",
                        "You need both a username and a domain to register")
                rc.register(reg.username, reg.password, reg.domain)
                self.proxy.addProxyAuthentication(reg.username, reg.domain,
                                                  reg.password)
        self.transport = sip.SIPTransport(self.dispatcher,
                                          getHostnames(self.store),
                                          self.portno)
        self.port = reactor.listenUDP(self.portno, self.transport)
Пример #4
0
    def startService(self):
        tacPath = sibpath(sine.__file__, "media.tac")
        self.mediaController = batch.ProcessController(
            "rtp-transceiver",
            useragent.LocalControlProtocol(False),
            tacPath=tacPath)

        if self.pstn:
            pstnurl = sip.parseURL(self.pstn)
            portal = PSTNPortalWrapper(Portal(self.userbase, [self.userbase]), pstnurl.host, pstnurl.port)
        else:
            portal = Portal(self.userbase, [self.userbase])
        self.proxy = sip.Proxy(portal)
        self.dispatcher = sip.SIPDispatcher(portal, self.proxy)
        regs = list(self.store.query(Registration, Registration.parent==self))
        if regs:
            rc = sip.RegistrationClient()
            self.proxy.installRegistrationClient(rc)
            for reg in regs:
                if not (reg.username and reg.domain):
                    raise SIPConfigurationError("Bad registration URL:", "You need both a username and a domain to register")
                rc.register(reg.username, reg.password, reg.domain)
                self.proxy.addProxyAuthentication(reg.username, reg.domain, reg.password)
        self.transport = sip.SIPTransport(self.dispatcher, getHostnames(self.store), self.portno)
        self.port = reactor.listenUDP(self.portno, self.transport)
Пример #5
0
 def parseURLorPhoneNum(self, val):
     pstn = self.original.store.parent.findUnique(SIPServer).pstn
     if '@' in val:
         if not val.startswith("sip:"):
             val = "sip:" + val
         return sip.parseURL(val)
     elif pstn:
         pstnurl = sip.parseURL(pstn)
         num = ''.join([c for c in val if c.isdigit()])
         pstn = self.original.store.parent.findUnique(SIPServer).pstn
         if len(num) == 10:
             return sip.URL(host=pstnurl.host, username="******"+num, port=pstnurl.port)
         elif len(num) == 11 and num[0] == '1':
             return sip.URL(host=pstnurl.host, username=num, port=pstnurl.port)
         else:
             raise liveform.InvalidInput("Please enter a SIP URL or a North American ten-digit phone number.")
     else:
         raise liveform.InvalidInput("Please enter a SIP URL.")
Пример #6
0
 def parseURLorPhoneNum(self, val):
     pstn = self.original.store.parent.findUnique(SIPServer).pstn
     if '@' in val:
         if not val.startswith("sip:"):
             val = "sip:" + val
         return sip.parseURL(val)
     elif pstn:
         pstnurl = sip.parseURL(pstn)
         num = ''.join([c for c in val if c.isdigit()])
         pstn = self.original.store.parent.findUnique(SIPServer).pstn
         if len(num) == 10:
             return sip.URL(host=pstnurl.host,
                            username="******" + num,
                            port=pstnurl.port)
         elif len(num) == 11 and num[0] == '1':
             return sip.URL(host=pstnurl.host,
                            username=num,
                            port=pstnurl.port)
         else:
             raise liveform.InvalidInput(
                 "Please enter a SIP URL or a North American ten-digit phone number."
             )
     else:
         raise liveform.InvalidInput("Please enter a SIP URL.")
Пример #7
0
 def unregisterAddress(self, physicalURL):
     storedURL = sip.parseURL(self.physicalURL)
     if storedURL != physicalURL:
         raise ValueError, "what"
     self.physicalURL = None
     return [(physicalURL, 0)]
Пример #8
0
 def unregisterAddress(self, physicalURL):
     storedURL = sip.parseURL(self.physicalURL)
     if storedURL != physicalURL:
         raise ValueError, "what"
     self.physicalURL = None
     return [(physicalURL, 0)]