Proyecto de investigación
SU USO DE LOS GUIONES ES BAJO SU PROPIO RIESGO
El proyecto contiene 2 guiones:
Ambos scripts son compatibles con Python3 y usan FFprobe y FFmpeg.
Instálelo antes de usarlo:
Simplemente puede ejecutar los siguientes ejemplos para ver cómo funciona:
python3 multicast-checker.py --playlist playlist.m3u
donde playlist.m3u es un archivo M3U donde se enumeran todos los canales UDP
Ejemplo de archivo M3U:
#EXTM3U
#EXTINF:2,Info channel #1
udp://@233.99.65.1:1234
#EXTINF:2,Info channel #2
udp://@233.99.65.2:5500
#EXTINF:2,Info channel #3
udp://@233.99.65.3:1234
#EXTINF:2,Info channel #4
udp://@233.99.65.4:5500
#EXTINF:2,Info channel #5
udp://@233.99.65.5:1234
El script escaneará todos los canales en playlist.m3u usando subprocesos múltiples y devolverá los resultados. El campo de metadatos nombre_servicio de la transmisión UDP se capturará de antemano.
Ejemplo de salida:
[*] Email parameters are not defined.
[*] Run the script with -h parameter for the details.
[*] Channel Info channel #2 is not working
[*] Channel Info channel #4 is not working
[*] Channel Info channel #3 is not working
[*] Channel Info channel #5 is not working
[*] OK >>> Channel is working! >>> "Info channel #1" >>> No stream name found
[*] The following channel(s) are not working:
233.99.65.2:5500 - Info channel #2
233.99.65.4:5500 - Info channel #4
233.99.65.3:1234 - Info channel #3
233.99.65.5:1234 - Info channel #5
[*] Finished in 7.0 second(s)
python3 multicast-scanner.py --range 233.99.65.1/30
El script escaneará el rango de IP UDP dado usando subprocesos múltiples y devolverá los resultados. El campo de metadatos nombre_servicio de la secuencia UDP se capturará de antemano. Si no se encuentra ningún nombre_servicio, se capturará la muestra de 10 segundos.
Ejemplo de salida:
[*] IP range to scan: 233.99.65.0/30
[*] IPs to scan: 4
[*] Ports to scan for each IP: 1
[*] List of the port(s) to scan: 1234
[*] Timeout for UDP stream reply: 5 sec(s)
[*] Timeout for stream data collection: 10 sec(s)
[*] Sample lenght in seconds: 60 sec(s)
[*] Totals:
[*] Total items to scan: 4
[*] Total number of /32 subnets to scan (# of threads): 4
[*] Total number of hosts for each subnet to scan: 1
[*] Estimated maximum time to complete the task: 50 seconds
[*] 0 day(s) 0 hour(s) 0 minute(s) 50 second(s)
[*] Found opened port 1234 for 233.99.65.1
[*] Scanning for 233.99.65.0/32 completed!
[*] Scanning for 233.99.65.2/32 completed!
[*] Scanning for 233.99.65.3/32 completed!
[*] !!! No channel name found for 233.99.65.1:1234 !!!
[*] !!! Channel added to the playlist. 233.99.65.1:1234 >>> 1 !!!
[*] Scanning for 233.99.65.1/32 completed!
[*] Recording the samples for unnamed channels...
[*] !!! Sample for 233.99.65.1:1234 captured !!!
[*] Finished in 14.0 second(s)
[*] 0.0 day(s) 0.0 hour(s) 0.0 minute(s) 14.0 second(s)
[*] Channels found: 1
[*] Resulting file: scan_results_range_233.99.65.0-30.m3u
Los scripts se probaron en Linux (Ubuntu 20.04) y MacOS (Big Sur, 11.2.2)
Puede encontrar todos los parámetros de los scripts usando lo siguiente:
python3 multicast-checker.py -h
--playlist "Playlist *.m3u file with UDP streams" required: True
--nic "network interface IP address with UDP stream" required: False default: '0.0.0.0'
--udp_timeout "Time to wait in seconds for the UPD port reply" required: False default: 5
--info_timeout "Time to wait in seconds for the stream's info" required: False default: 10
--smtp_server "SMTP server to send an email" required: False
--smtp_port "Port for SMTP server" required: False default: 25
--sender "email address for email sender" required: False
--receivers "emails of the receivers (space separated)" required: False
python3 multicast-scanner.py -h
--range "Range of IPs to scan." required: True
--size "Size of the subnets to divide." required: False default: '32'
--playlist "Playlist *.m3u file with UDP streams" required: False
--nic "network interface IP address with UDP stream" required: False default: '0.0.0.0'
--udp_timeout "Time to wait in seconds for the UPD port reply" required: False default: 5
--port "addtional UDP port to scan. Default: 1234" required: False default: '1234'
--sample_sec "Sample lenght in seconds" required: False default: 60
--info_timeout "Time to wait in seconds for the stream's info" required: False default: 10
--smtp_server "SMTP server to send an email" required: False
--smtp_port "Port for SMTP server" required: False default: 25
--sender "email address for email sender" required: False
--receivers "emails of the receivers (space separated)" required: False
El proyecto multicast-checker.py se creó como una herramienta para monitorear la red IPTV del ISP y enviar alertas en caso de cortes de canales.
El proyecto multicast-scanner.py fue creado como una herramienta para descubrir todos los canales de IPTV disponibles en la red del ISP.
No dude en comentar/culpar/sugerir el desarrollo futuro.
Datos utilizados:
El código de este proyecto tiene la licencia MIT.