Exemplo n.º 1
0
 def __init__(self, dnconfig, sip_logger):
     self.workers = {}
     self.clim = Cli_server_tcp(self.recv_dnotify, dnconfig.in_address)
     self.clim.accept_list = []
     self.dest_sprefix = dnconfig.dest_sprefix
     self.in_address = dnconfig.in_address
     self.sip_logger = sip_logger
Exemplo n.º 2
0
class DNRelay(object):
    clim = None
    workers = None
    dest_sprefix = None
    in_address = None
    sip_logger = None

    def __init__(self, dnconfig, sip_logger):
        self.workers = {}
        self.clim = Cli_server_tcp(self.recv_dnotify, dnconfig.in_address)
        self.clim.accept_list = []
        self.dest_sprefix = dnconfig.dest_sprefix
        self.in_address = dnconfig.in_address
        self.sip_logger = sip_logger

    def recv_dnotify(self, clim, dnstring):
        #print 'DNRelay.recv_dnotify(%s)' % dnstring
        if clim.raddr != None:
            self.sip_logger.write('Disconnect notification from %s received on %s: "%s"' \
              % (str(clim.raddr), str(self.in_address), dnstring))
        else:
            self.sip_logger.write('Disconnect notification received on %s: "%s"' \
              % (str(self.in_address), dnstring))
        ssufx, dnstring = dnstring.split(None, 1)
        spath = self.dest_sprefix + ssufx
        dnw = self.workers.get(spath, None)
        if dnw == None:
            dnw = _DNRLWorker(spath, self.sip_logger)
            self.workers[spath] = dnw
        self.sip_logger.write(' forwarding notification to "%s": "%s"' %
                              (spath, dnstring))
        dnw.send_dnotify(dnstring)

    def shutdown(self):
        for dnw in self.workers.itervalues():
            dnw.send_dnotify(None)
            dnw.join()
        self.clim.shutdown()
        self.sip_logger = None

    def cmpconfig(self, dnconfig):
        if dnconfig.dest_sprefix != self.dest_sprefix:
            return False
        if dnconfig.in_address != self.in_address:
            return False
        return True

    def allow_from(self, address):
        self.clim.accept_list.append(address[0])

    def disallow_from(self, address):
        self.clim.accept_list.remove(address[0])

    def get_allow_list(self):
        return tuple(self.clim.accept_list)

    def set_allow_list(self, accept_list):
        self.clim.accept_list = list(accept_list)
Exemplo n.º 3
0
class DNRelay(object):
    clim = None
    workers = None
    dest_sprefix = None
    in_address = None
    sip_logger = None

    def __init__(self, dnconfig, sip_logger):
        self.workers = {}
        self.clim = Cli_server_tcp(self.recv_dnotify, dnconfig.in_address)
        self.clim.accept_list = []
        self.dest_sprefix = dnconfig.dest_sprefix
        self.in_address = dnconfig.in_address
        self.sip_logger = sip_logger

    def recv_dnotify(self, clim, dnstring):
        #print 'DNRelay.recv_dnotify(%s)' % dnstring
        if clim.raddr != None:
            self.sip_logger.write('Disconnect notification from %s received on %s: "%s"' \
              % (str(clim.raddr), str(self.in_address), dnstring))
        else:
            self.sip_logger.write('Disconnect notification received on %s: "%s"' \
              % (str(self.in_address), dnstring))
        ssufx, dnstring = dnstring.split(None, 1)
        spath = self.dest_sprefix + ssufx
        dnw = self.workers.get(spath, None)
        if dnw == None:
            dnw = _DNRLWorker(spath, self.sip_logger)
            self.workers[spath] = dnw
        self.sip_logger.write(' forwarding notification to "%s": "%s"' % (spath, dnstring))
        dnw.send_dnotify(dnstring)

    def shutdown(self):
        for dnw in self.workers.itervalues():
            dnw.send_dnotify(None)
            dnw.join()
        self.clim.shutdown()
        self.sip_logger = None

    def cmpconfig(self, dnconfig):
        if dnconfig.dest_sprefix != self.dest_sprefix:
            return False
        if dnconfig.in_address != self.in_address:
            return False
        return True

    def allow_from(self, address):
        self.clim.accept_list.append(address[0])

    def disallow_from(self, address):
        self.clim.accept_list.remove(address[0])

    def get_allow_list(self):
        return tuple(self.clim.accept_list)

    def set_allow_list(self, accept_list):
        self.clim.accept_list = list(accept_list)
Exemplo n.º 4
0
 def __init__(self, dnconfig, sip_logger):
     self.workers = {}
     self.clim = Cli_server_tcp(self.recv_dnotify, dnconfig.in_address)
     self.clim.accept_list = []
     self.dest_sprefix = dnconfig.dest_sprefix
     self.in_address = dnconfig.in_address
     self.sip_logger = sip_logger