Copiar $ git checkout encrypted - udp
Creación de listener con las flags necesarias para realizar la conexión con el agente
Copiar $ curl localhost:5000/listeners/ -d '{"type": "udp", "bind_host": "127.0.0.1", "bind_port": 53, "target_host": "127.0.0.1", "target_port": 53, "sym_key": "c29tZSByYW5kb20ga2V5IQ=="}' -H 'Content-Type: application/json'
This module provides access to the BSD socket interface. It is available on all modern Unix systems, Windows, MacOS, and probably additional platforms.
Copiar import socket
sock = socket . socket (socket.AF_INET, socket.SOCK_DGRAM)
sock . bind ((self._host, self._port)
msg, addr = sock. recvfrom (NUMERO_COMPLETAMENTE_ARBITRARIO)
Copiar func CreateUdpClient (config * Config ) ( comm . Client , error ) {
keyExchange, err := createKeyExchange (config)
if err != nil {
return nil , err
}
udpClient, err := comm. NewUdpClient (config.Host, config.Port)
if err != nil {
return nil , err
}
encUdpClient := comm. NewEncryptedClient (udpClient, config.SymKey)
dhClient := comm. NewDHClient (keyExchange, encUdpClient)
return dhClient, nil
}
Copiar class UdpListener ( Listener ):
def __init__ ( self , api_url : str , host : str , port : int , sym_key : bytes ):
handler = ApiHandler (api_url)
handler = DHHandler ( KeyExchange (), handler)
handler = EncryptedHandler (sym_key, handler)
self . _handler = handler
self . _port = port
self . _host = host
@ classmethod
def new ( cls , api_url : str , host : str , port : int , sym_key : bytes ) -> 'Listener' :
return cls (api_url, host, port, sym_key)
@ classmethod
def type_name ( cls ) -> str :
return 'udp'
def run ( self ):
pass