Пример #1
0
    my_socket.send(bytes(LINE_REGIST, "utf-8") + b"\r\n")
    Log().Log(UA["log_path"], "send", PROXY, LINE_REGIST)
    try:
        data = my_socket.recv(1024)
        datadec = data.decode("utf-8")
        Log().Log(UA["log_path"], "receive", PROXY, datadec)
        if OPTION == 0:
            Log().Log(UA["log_path"], "init/end", " ", "Finishing...")
    except socket.error:
        SOCKET_ERROR = UA["regproxy_ip"] + " PORT:" + UA["regproxy_puerto"]
        Log().Log(UA["log_path"], "error", " ", SOCKET_ERROR)
        sys.exit("Error: No server listening at " + PROXY)
# Envío de ACK
elif rec[0:3] == ["SIP/2.0 100 Trying", "SIP/2.0 180 Ring", "SIP/2.0 200 OK"]:
    LINE_ACK = "ACK sip:" + OPTION + " SIP/2.0\r\n\r\n"
    print("Enviando: " + LINE_ACK)
    my_socket.send(bytes(LINE_ACK, "utf-8") + b"\r\n")
    rcv_Ip = datadec.split("o=")[1].split(" ")[1].split("s")[0]
    rcv_Port = datadec.split("m=")[1].split(" ")[1]
    ejecutar = Thread_CVLC(rcv_Port, rcv_Ip, UA["audio_path"])
    ejecutar.start()
    ejecutar.join()
    print("Ha terminado la ejecución de fichero de audio")
    Log().Log(UA["log_path"], "send", PROXY, LINE_ACK)
elif datadec == "Acceso denegado: password is incorrect\r\n\r\n":
    print("Usage: The Password is incorrect")
else:
    sys.exit(datadec)
# Cerramos todo
my_socket.close()
Пример #2
0
                Datos_Log(PATH_LOG, Evento, IP_PROXY, PORT_PROXY, '')
                sys.exit("Error: No server listening")
            # Escribimos en el log los datos que enviamos
            Evento = ' Send to '
            Datos_Log(PATH_LOG, Evento, IP_PROXY, PORT_PROXY, LINEACK)

            # RTP
            Line_restante = data_decod.split('\r\n')[12]
            IP_RECEPT = Line_restante.split(' ')[1]
            Line_Port = data_decod.split('\r\n')[15]
            PORT_RECEPT = Line_Port.split(' ')[1]
            # Escribimos el mensage de comienzo RTP en el log
            Event = ' Terminando el envío RTP '
            Datos_Log(PATH_LOG, Event, '', '', '')
            # Ejecutamos el Thread
            hilo = Thread_CVLC(PORT_RECEPT, IP_RECEPT, PATH_AUDIO)
            hilo.start()
            hilo.join()
            os.system('killall vlc')
            # Escribimos el mensage de fin RTP en el log
            Event = ' Terminando el envío RTP '
            Datos_Log(PATH_LOG, Event, '', '', '')
            data = my_socket.recv(1024)
        elif Not_Aut == 'SIP/2.0 401 Unauthorized':
            m = hashlib.md5()
            Nonce_Salto_Linea = data_decod.split('nonce="')[1]
            Nonce = Nonce_Salto_Linea.split('"')[0]
            m.update(bytes(PASSWD + Nonce, 'utf-8'))
            RESPONSE = m.hexdigest()
            LINE_REGIST = Line_Sip + USER_NAME + ":" + UASERVER_PORT
            LINE_REGIST += " SIP/2.0\r\n" + "Expires: " + OPTION + "\r\n"
Пример #3
0
    my_socket.send(bytes(LINE_REGIST, 'utf-8') + b'\r\n')
    Log().Log(UA['log_path'], 'send', PROXY, LINE_REGIST)
    try:
        data = my_socket.recv(1024)
        datadec = data.decode('utf-8')
        Log().Log(UA['log_path'], 'receive', PROXY, datadec)
        if OPTION == 0:
            Log().Log(UA['log_path'], 'init/end', ' ', 'Finishing...')
    except socket.error:
        SOCKET_ERROR = UA['regproxy_ip'] + " PORT:" + UA['regproxy_puerto']
        Log().Log(UA['log_path'], 'error', ' ', SOCKET_ERROR)
        sys.exit("Error: No server listening at " + PROXY)
#Envío de ACK
elif rec[0:3] == ['SIP/2.0 100 Trying', 'SIP/2.0 180 Ring', 'SIP/2.0 200 OK']:
    LINE_ACK = "ACK sip:" + OPTION + " SIP/2.0\r\n\r\n"
    print("Enviando: " + LINE_ACK)
    my_socket.send(bytes(LINE_ACK, 'utf-8') + b'\r\n')
    rcv_Ip = datadec.split("o=")[1].split(" ")[1].split("s")[0]
    rcv_Port = datadec.split("m=")[1].split(" ")[1]
    ejecutar = Thread_CVLC(rcv_Port, rcv_Ip, UA['audio_path'])
    ejecutar.start()
    ejecutar.join()
    print("Ha terminado la ejecución de fichero de audio")
    Log().Log(UA['log_path'], 'send', PROXY, LINE_ACK)
elif datadec == "Acceso denegado: password is incorrect\r\n\r\n":
    print("Usage: The Password is incorrect")
else:
    sys.exit(datadec)
# Cerramos todo
my_socket.close()