Exemple #1
0
 def __init__(self, ip, port, password):
     ESLEvent.__init__(self, ip, port, password)
     if options.is_call.lower() not in ['yes']:
         self.__message_flow["recv call"]["result"] = True
     if options.ring_time == -1:
         self.__message_flow["ring"]["result"] = True
     if options.answer_time == -1:
         self.__message_flow["answer"]["result"] = True
     if options.hangup_time == -1:
         self.__message_flow["hangup"]["result"] = True
     pass
Exemple #2
0
    def __init__(self, ip, port, password, debug=False):
        try:
            ESLEvent.__init__(self, ip, port, password)
        except Exception as err:
            raise Exception(err)

        self.__call = {}
        self.__debug = debug

        # tcpdump抓包时,是开启子进程,这里需要监听kill命令,以便顺利结束掉已经开启的进程
        signal.signal(signal.SIGINT, self.__terminate)
        signal.signal(signal.SIGTERM, self.__terminate)
        signal.signal(signal.SIGABRT, self.__terminate)
        def __init__(self, ip, port, password):
            ESLEvent.__init__(self, ip, port, password)
            self.__A = {}
            self.__B = {}
            self.__message_flow = {\
             "recv A": {"sequence": 10, "result": False, "describe": "recv A calling"},
             "send B": {"sequence": 20, "result": False, "describe": "send B call"},
             "check RN": {"sequence": 30, "result": False, "describe": "check rn"},
             "check billing": {"sequence": 40, "result": False, "describe": "check billing"},
             "ring": {"sequence": 100, "result": False, "describe": "ring"},
             "answer": {"sequence": 200, "result": False, "describe": "answer"},
             "hangup": {"sequence": 300, "result": False, "describe": "hangup"},
             "hangup_ntf": {"sequence": 400, "result": False, "describe": "hangup notify"},
            }

            # 开启了cancel时间,表示可能不会有ring和answer
            if options.cancel_time != -1:
                self.__message_flow['ring']['result'] = True
                self.__message_flow['answer']['result'] = True
		def __init__(self, ip, port, password):
			ESLEvent.__init__(self, ip, port, password)
			self.__A = {}
			self.__B = {}
			self.__message_flow = {\
				"recv A": {"sequence": 10, "result": False, "describe": "recv A calling"},
				"send B": {"sequence": 20, "result": False, "describe": "send B call"},
				"check RN": {"sequence": 30, "result": False, "describe": "check rn"},
				"check billing": {"sequence": 40, "result": False, "describe": "check billing"},
				"ring": {"sequence": 100, "result": False, "describe": "ring"},
				"answer": {"sequence": 200, "result": False, "describe": "answer"},
				"hangup": {"sequence": 300, "result": False, "describe": "hangup"},
				"hangup_ntf": {"sequence": 400, "result": False, "describe": "hangup notify"},
			}

			# 有错误原因
			if options.reason_code != 0:
				self.__message_flow['send B']['result'] = True
				self.__message_flow['check RN']['result'] = True
				self.__message_flow['ring']['result'] = True
				self.__message_flow['answer']['result'] = True
				self.__message_flow['hangup_ntf']['result'] = True
Exemple #5
0
    def run(self, timeout=-1):
        """
		开始监听号码,并在识别到号码后呼叫建立时抓包
		 
		参数:
		  timeout - 监听时长
		返回值:
		  ESLEvent.run的返回值
		 
		异常:
		  无
		"""
        return ESLEvent.run(self, timeout)
Exemple #6
0
    def __terminate(self, *arg):
        """
		终止程序,停止相关抓包的子线程
		 
		参数:
		  arg - 参数
		返回值:
		  无
		 
		异常:
		  无
		"""
        ESLEvent.disconnect(self)
        for uuid, call in self.__call.items():
            pcap = call.get("pcap", None)
            if pcap:
                pcap.terminate()
                print("%s tcpdump end %s" %
                      (call.get("id", "0"), call.get("pcap_name", "")))
        else:
            if self.__debug:
                print("\n[end] all\n")
            pass
Exemple #7
0
                      dest='host',
                      help='FreeSWITCH server IP address')
    parser.add_option('-p',
                      '--port',
                      dest='port',
                      default='8021',
                      help='FreeSWITCH server event socket port')
    parser.add_option('-a',
                      '--password',
                      dest='password',
                      default='ClueCon',
                      help='ESL password')
    (options, args) = parser.parse_args()

    try:
        import neko
        from neko import ESLEvent
        event = ESLEvent(options.host, options.port, options.password)
        print((neko.__file__))
        if event and event.is_connected():
            print(("INFO:connect freeswitch ESL success. %s:%s@%s" %
                   (options.host, options.port, options.password)))
            print((0))
        else:
            print(("ERR :connect freeswitch ESL failed. %s:%s@%s" %
                   (options.host, options.port, options.password)))
            print((1))
    except Exception as err:
        print(("ERR: " + str(err)))
        print((1))
Exemple #8
0
 def __init__(self, ip, port, password):
     ESLEvent.__init__(self, ip, port, password)
     pass
Exemple #9
0
                      help='hangup time')
    # ring之后的cancel间隔时间(单位:秒),-1代表不cancel
    parser.add_option('--cancel_time',
                      dest='cancel_time',
                      type='int',
                      default=-1,
                      help='cancel time')

    (options, args) = parser.parse_args()

    run_path = os.path.split(os.path.realpath(sys.argv[0]))[0]
    sys.path.append(os.path.join(run_path, options.lib))
    from neko import ESLEvent

    # 初始化一个发起呼叫的ESL
    Call = ESLEvent(options.host, options.port, options.password)

    call_uuid = None

    # 接收呼叫信息ESL定义
    class CallerEvent(ESLEvent):
        def __init__(self, ip, port, password):
            ESLEvent.__init__(self, ip, port, password)
            pass

        def channel_event(self, event):
            event_name = event.getHeader("Event-Name")
            event_sub_name = event.getHeader("Event-Subclass")

            if event_name in ['CHANNEL_CREATE']:
                return self.channel_create(event)