Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
scrapper-portabilidad
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Javier
scrapper-portabilidad
Commits
b56f7b72
Commit
b56f7b72
authored
Apr 20, 2022
by
Javier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Módulo PBX
parent
4c381dd1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
12 deletions
+69
-12
cli.py
cli.py
+1
-1
main.py
main.py
+12
-11
__init__.py
pbx/__init__.py
+0
-0
utils.py
pbx/utils.py
+56
-0
No files found.
cli.py
View file @
b56f7b72
...
@@ -238,7 +238,7 @@ def import_cdr(account: str = typer.Argument(None), only_charged: bool = typer.A
...
@@ -238,7 +238,7 @@ def import_cdr(account: str = typer.Argument(None), only_charged: bool = typer.A
@app.command
()
@app.command
()
def
sync
rh
onize
():
def
sync
hr
onize
():
start_time
=
datetime
.
now
()
start_time
=
datetime
.
now
()
# Verificación de SIP en Nueva Plataforma
# Verificación de SIP en Nueva Plataforma
...
...
main.py
View file @
b56f7b72
...
@@ -43,23 +43,24 @@ app = FastAPI(
...
@@ -43,23 +43,24 @@ app = FastAPI(
class
Rate
(
str
,
Enum
):
class
Rate
(
str
,
Enum
):
ESTANDAR
=
"Tarifa Estándar"
ESTANDAR
=
"Estandar"
EMPRESAS
=
"Tarifa Empresas"
EMPRESAS
=
"Empresas"
PLANA_1000
=
"Tarifa Plana 1000 Minutos"
PLANA_1000
=
"Plana1000"
PLANA_2000
=
"Tarifa Plana 2000 Minutos"
PLANA_2000
=
"Plana2000"
PLANA_EUROPA_1000
=
"PlanaEuropa1000"
class
Tax
(
str
,
Enum
):
class
Tax
(
str
,
Enum
):
GENERAL
=
'
IVA General (21
%
)
'
GENERAL
=
'
General
'
EXENTA
=
'
Operación Exenta de Impuestos
'
EXENTA
=
'
Exento
'
class
Refill
(
str
,
Enum
):
class
Refill
(
str
,
Enum
):
AUTOMATICA
=
'
Recarga Automá
tica'
AUTOMATICA
=
'
Automa
tica'
LIQUIDACION
=
'Liquidaci
ón Mensual de consumos Postpago
'
LIQUIDACION
=
'Liquidaci
on
'
MANUAL
=
'
Recarga solicitada por el Cliente
'
MANUAL
=
'
Manual
'
TRASPASO
=
'Traspaso
de Fondos desde A2Billing
'
TRASPASO
=
'Traspaso'
INICIAL
=
'
Recarga
Inicial'
INICIAL
=
'Inicial'
class
Account
(
BaseModel
):
class
Account
(
BaseModel
):
...
...
pbx/__init__.py
0 → 100644
View file @
b56f7b72
pbx/utils.py
0 → 100644
View file @
b56f7b72
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'
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment