-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsip-server.py
executable file
·42 lines (31 loc) · 1.04 KB
/
sip-server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
# Osman Yuksel < yuxel {{|AT|}} sonsuzdongu |-| com >
port = 9090
import time
import sys
import json
sys.path.append('gen-py')
from sip import *
from sip.ttypes import *
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from thrift.server import TServer
class SipHandler:
def time(self):
timeStamp = time.time()
return str(timeStamp)
def send(self, packet):
print('Packet@{} {}->{} {}'.format(packet.utc_time,
packet.ip_src,
packet.ip_dst,
packet.sip_method
))
handler = SipHandler()
processor = signalling.Processor(handler)
transport = TSocket.TServerSocket(port=port)
tfactory = TTransport.TBufferedTransportFactory()
pfactory = TBinaryProtocol.TBinaryProtocolFactory()
server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)
print("Starting server")
server.serve()