Commit b56f7b72 by Javier

Módulo PBX

parent 4c381dd1
......@@ -238,7 +238,7 @@ def import_cdr(account: str = typer.Argument(None), only_charged: bool = typer.A
@app.command()
def syncrhonize():
def synchronize():
start_time = datetime.now()
# Verificación de SIP en Nueva Plataforma
......
......@@ -43,23 +43,24 @@ app = FastAPI(
class Rate(str, Enum):
ESTANDAR = "Tarifa Estándar"
EMPRESAS = "Tarifa Empresas"
PLANA_1000 = "Tarifa Plana 1000 Minutos"
PLANA_2000 = "Tarifa Plana 2000 Minutos"
ESTANDAR = "Estandar"
EMPRESAS = "Empresas"
PLANA_1000 = "Plana1000"
PLANA_2000 = "Plana2000"
PLANA_EUROPA_1000 = "PlanaEuropa1000"
class Tax(str, Enum):
GENERAL = 'IVA General (21%)'
EXENTA = 'Operación Exenta de Impuestos'
GENERAL = 'General'
EXENTA = 'Exento'
class Refill(str, Enum):
AUTOMATICA = 'Recarga Automática'
LIQUIDACION = 'Liquidación Mensual de consumos Postpago'
MANUAL = 'Recarga solicitada por el Cliente'
TRASPASO = 'Traspaso de Fondos desde A2Billing'
INICIAL = 'Recarga Inicial'
AUTOMATICA = 'Automatica'
LIQUIDACION = 'Liquidacion'
MANUAL = 'Manual'
TRASPASO = 'Traspaso'
INICIAL = 'Inicial'
class Account(BaseModel):
......
import sys
from datetime import datetime
from scapy.all import srp, Ether, ARP, ICMP, IP, sr1, conf, get_if_list
def arp_scan(interface : str, range : str = '192.168.2.0/24') -> 'list[str]':
"""Realiza una búsqueda de las IPs libres en el Rango indicado
Args:
interface (str): Interfaz que realiza el Escaneo.
range (str): Rango de Direcciones.
Returns:
list[str]: Listado de las direcciones IP disponibles.
"""
answered, unanswered = srp(
Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=range), timeout=3, iface=interface, inter=0.1
)
return [ipa.pdst for ipa in unanswered][40:-1]
def ping(address : str, timeout : float = 4) -> bool:
"""Realiza una prueba de Ping
Args:
address (str): Dirección Objetivo
timeout (float, optional): Tiempo de Espera. Defaults to 4.
Returns:
bool: True si está online
"""
packet = IP(dst=address, ttl=20)/ICMP()
reply = sr1(packet, timeout=timeout)
return not (reply is None)
def obtain_ip_address(interface: str, range: str = '192.168.2.0/24') -> str:
"""Obtiene una dirección IP libre
Se realizan dos pruebas, una ARP y otra ICMP para localizar direcciones\
IPs disponibles. Siempre es necesario una revisión manual posterior.
Args:
interface (str): Interfa
range (str, optional): _description_. Defaults to '192.168.2.0/24'.
Returns:
str: _description_
"""
for address in arp_scan(interface,range):
if not ping(address):
return address
if __name__ == "__main__":
print(obtain_ip_address('TP-LINK Gigabit Ethernet USB Adapter'))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment