Add new TO_TYPE - STAT
This commit is contained in:
parent
37581ec8b6
commit
b251cee899
@ -315,6 +315,8 @@ def rule_timer_loop():
|
|||||||
else:
|
else:
|
||||||
if _system['SYSTEM'][0:3] != 'OBP':
|
if _system['SYSTEM'][0:3] != 'OBP':
|
||||||
_bridge_used = True
|
_bridge_used = True
|
||||||
|
else if _system['SYSTEM'][0:3] == 'OBP' and _system['TO_TYPE'] == 'STAT':
|
||||||
|
_bridge_used = True
|
||||||
logger.debug('(ROUTER) Conference Bridge NO ACTION: System: %s, Bridge: %s, TS: %s, TGID: %s', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID']))
|
logger.debug('(ROUTER) Conference Bridge NO ACTION: System: %s, Bridge: %s, TS: %s, TGID: %s', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID']))
|
||||||
|
|
||||||
if _bridge_used == False:
|
if _bridge_used == False:
|
||||||
|
@ -5,33 +5,54 @@ from time import time
|
|||||||
|
|
||||||
class Proxy(DatagramProtocol):
|
class Proxy(DatagramProtocol):
|
||||||
|
|
||||||
def __init__(self,ListenPort,connTrack,Timeout):
|
def __init__(self,ListenPort,connTrack,Timeout,Debug):
|
||||||
self.connTrack = connTrack
|
self.connTrack = connTrack
|
||||||
self.timeout = Timeout
|
self.timeout = Timeout
|
||||||
|
self.debug = Debug
|
||||||
|
|
||||||
def datagramReceived(self, data, addr):
|
def datagramReceived(self, data, addr):
|
||||||
host,port = addr
|
host,port = addr
|
||||||
|
|
||||||
|
Debug = self.debug
|
||||||
|
|
||||||
|
#If the packet comes from the master
|
||||||
if host == '127.0.0.1' and port in self.connTrack:
|
if host == '127.0.0.1' and port in self.connTrack:
|
||||||
if int(self.connTrack[port]['time'])+self.timeout > time():
|
if int(self.connTrack[port]['time'])+self.timeout > time():
|
||||||
self.transport.write(data,(self.connTrack[port]['host'],self.connTrack[port]['sport']))
|
self.transport.write(data,(self.connTrack[port]['host'],self.connTrack[port]['sport']))
|
||||||
|
#if master refuses login, remove tracking and block for timeout seconds
|
||||||
|
if data == b'MSTNAK\x00#\xbf"':
|
||||||
|
self.connTrack[port]['time'] = False
|
||||||
|
self.connTrack[port]['nacktime'] = time()+self.timeout
|
||||||
|
if Debug:
|
||||||
|
print(data)
|
||||||
return
|
return
|
||||||
|
|
||||||
for dport in self.connTrack:
|
for dport in self.connTrack:
|
||||||
|
#If blocked from refused login, ignore the packet if its been less than nacktime
|
||||||
|
if int(self.connTrack[dport]['nacktime']) + self.timeout > time():
|
||||||
|
if Debug:
|
||||||
|
print("NACK\n")
|
||||||
|
return
|
||||||
|
#If we have a conntrack for this connect and the timeout has not expired, forward to tracked port
|
||||||
if self.connTrack[dport]['host'] == host and self.connTrack[dport]['sport'] == port and (int(self.connTrack[dport]['time'])+self.timeout > time()):
|
if self.connTrack[dport]['host'] == host and self.connTrack[dport]['sport'] == port and (int(self.connTrack[dport]['time'])+self.timeout > time()):
|
||||||
self.connTrack[dport]['time'] = time()
|
self.connTrack[dport]['time'] = time()
|
||||||
self.connTrack[dport]['host'] = host
|
self.connTrack[dport]['host'] = host
|
||||||
self.connTrack[dport]['sport'] = port
|
self.connTrack[dport]['sport'] = port
|
||||||
self.transport.write(data, ('127.0.0.1',dport))
|
self.transport.write(data, ('127.0.0.1',dport))
|
||||||
self.connTrack[dport]['time'] = time()
|
self.connTrack[dport]['time'] = time()
|
||||||
|
if Debug:
|
||||||
|
print(data)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
#Find free port to map for new connection
|
||||||
for dport in self.connTrack:
|
for dport in self.connTrack:
|
||||||
if (self.connTrack[dport]['time'] == False or (int(self.connTrack[dport]['time'])+self.timeout < time())):
|
if (self.connTrack[dport]['time'] == False or (int(self.connTrack[dport]['time'])+self.timeout < time())):
|
||||||
self.connTrack[dport]['sport'] = port
|
self.connTrack[dport]['sport'] = port
|
||||||
self.connTrack[dport]['host'] = host
|
self.connTrack[dport]['host'] = host
|
||||||
self.connTrack[dport]['time'] = time()
|
self.connTrack[dport]['time'] = time()
|
||||||
self.transport.write(data, ('127.0.0.1',dport))
|
self.transport.write(data, ('127.0.0.1',dport))
|
||||||
|
if Debug:
|
||||||
|
print(data)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
@ -41,10 +62,11 @@ if __name__ == '__main__':
|
|||||||
#*** CONFIG HERE ***
|
#*** CONFIG HERE ***
|
||||||
|
|
||||||
ListenPort = 62031
|
ListenPort = 62031
|
||||||
DestportStart = 50000
|
DestportStart = 54001
|
||||||
DestPortEnd = 50500
|
DestPortEnd = 54002
|
||||||
Timeout = 35
|
Timeout = 35
|
||||||
Stats = True
|
Stats = True
|
||||||
|
Debug = False
|
||||||
|
|
||||||
#*******************
|
#*******************
|
||||||
|
|
||||||
@ -52,9 +74,9 @@ if __name__ == '__main__':
|
|||||||
CONNTRACK = {}
|
CONNTRACK = {}
|
||||||
|
|
||||||
for port in range(DestportStart,DestPortEnd,1):
|
for port in range(DestportStart,DestPortEnd,1):
|
||||||
CONNTRACK[port] = {'host': False,'time': False,'sport':False}
|
CONNTRACK[port] = {'host': False,'time': False,'sport':False, 'nacktime': False}
|
||||||
|
|
||||||
reactor.listenUDP(ListenPort,Proxy(ListenPort,CONNTRACK,Timeout))
|
reactor.listenUDP(ListenPort,Proxy(ListenPort,CONNTRACK,Timeout,Debug))
|
||||||
|
|
||||||
def loopingErrHandle(failure):
|
def loopingErrHandle(failure):
|
||||||
print('(GLOBAL) STOPPING REACTOR TO AVOID MEMORY LEAK: Unhandled error in timed loop.\n {}'.format(failure))
|
print('(GLOBAL) STOPPING REACTOR TO AVOID MEMORY LEAK: Unhandled error in timed loop.\n {}'.format(failure))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user