Beispiel #1
0
class H2HComponent711(object):
    '''Host to Host Component (711)'''
    def __init__(self, server_id, xmpp_prof):
        self.msg = XMPPClient('vpn', {
            'user': config.H2HCOMPONENT,
            'pass': config.H2HCOMPONENT_PASS,
            'realm': config.MSG_SERVER,
        })
        self.h2h_handler = '{0}@{1}'.format(config.H2HHANDLER,
                                            config.MSG_SERVER)
        self.ip, _, p = config.SIGMA_PROXY.partition(':')
        self.port = int(p)
        self.msg.rexes = [
            (r'^{0}@{1}(/[^:]+)?:(?P<param>.+)$'.\
                    format(config.H2HHANDLER, config.MSG_SERVER),
                    self.handleCommand),
        ]
        self.rtn = RandomTerminalName()
        self.q = Queue()
        threading.Thread(target=self.tSendMsg).start()
    
    def handleCommand(self, msg):
        tr_id, user, passwd, prod_id, dest, profit = json.loads(msg['param'])
        y = {
            'transaction_id': tr_id,
            'userid': user,
            'password': passwd,
            'h2_product_id': prod_id,
            'msisdn_destination': dest,
            'profit': profit,
        }
        print y
        threading.Thread(target=self.tExecIso, args=(y,)).start()
    
    def tSendMsg(self):
        while True:
            to, msg = self.q.get()
            self.msg.send(to, msg)
    
    def tExecIso(self, msg):
        s = None
        for res in socket.getaddrinfo(self.ip, self.port, socket.AF_UNSPEC,
                                      socket.SOCK_STREAM):
            af, socktype, proto, canonname, sa = res
            try:
                s = socket.socket(af, socktype, proto)
            except socket.error, e:
                print e
                s = None
                continue
            try:
                s.connect(sa)
            except socket.error, e:
                print e
                s.close()
                s = None
                continue
            break
Beispiel #2
0
 def __init__(self, server_id, xmpp_prof):
     XMPPClient.__init__(self, server_id, xmpp_prof)
     self.im_acc = {}
     self.notify_dispatch = '{0}@{1}'.format(config.NOTIFYIN, config.MSG_SERVER)
     self.bus = dbus.SessionBus()
     self.obj = None
     self.purple = None
     self.connectPidginDBus()
     self.cb_init()
     self.map_im_accounts()
     self.frm = switchKeyValue(self.im_acc)
Beispiel #3
0
 def __init__(self):
     XMPPClient.__init__(self, lconf.SERVERNAME, {
         'user': lconf.LEAFSERVER,
         'pass': lconf.LEAFSERVER_PASS,
         'realm': lconf.MSG_SERVER,
     })
     self.log = mylogger('LeafController', 'leaf.log')
     self.shutdown = False
     self.notify_in = '{0}@{1}/{2}'.format(lconf.NOTIFYIN, lconf.MSG_SERVER,
                                           lconf.ROOT_SERVER_NAME)
     self.rexes.insert(0, (r'^{0}@{1}(/[^:]+)?:(?P<command>\w+)=(?P<param>'
         '[^,]*)$'.format(lconf.NOTIFYOUT, lconf.MSG_SERVER),
         self.handleLeafCommand))
     self.pdu = messaging.PDU()
     self.check_sms = False
     if 'linux' in sys.platform:
         p = '/home/szhan/Dev'
     else:
         p = sys.path[0]
     self.saengine = sqlalchemy.create_engine(lconf.DBCONN_URI)
     SABase.metadata.create_all(self.saengine)
     self.sasession = scoped_session(sessionmaker(bind=self.saengine))
     threading.Thread(target=self.sendMessageToCore).start()
Beispiel #4
0
 def __init__(self, server_id, xmpp_prof):
     self.msg = XMPPClient('vpn', {
         'user': config.H2HCOMPONENT,
         'pass': config.H2HCOMPONENT_PASS,
         'realm': config.MSG_SERVER,
     })
     self.h2h_handler = '{0}@{1}'.format(config.H2HHANDLER,
                                         config.MSG_SERVER)
     self.ip, _, p = config.SIGMA_PROXY.partition(':')
     self.port = int(p)
     self.msg.rexes = [
         (r'^{0}@{1}(/[^:]+)?:(?P<param>.+)$'.\
                 format(config.H2HHANDLER, config.MSG_SERVER),
                 self.handleCommand),
     ]
     self.rtn = RandomTerminalName()
     self.q = Queue()
     threading.Thread(target=self.tSendMsg).start()
Beispiel #5
0
 def __init__(self, server_id, xmpp_prof):
     XMPPClient.__init__(self, server_id, xmpp_prof)
     self.to = { 'ym': 'yahoo.{0}'.format(self.xmpp_prof['realm']) }
     self.frm = switchKeyValue(self.to)
     self.notify_dispatch = '{0}@{1}'.format(config.NOTIFYIN, config.MSG_SERVER)