Initial peer to connect to in the format host:port. This is used by leechers to connect to their first seed or peer.Format: <host>:<port> where:
host can be an IP address (e.g., 192.168.1.100) or hostname (e.g., localhost, 127.0.0.1)
port must be a valid port number
Default: If not specified, the node will only accept incoming connections and wait for other peers to connect.Examples:
# Connect to local seednode src/peer.js --port 6882 --file output.mkv --peer 127.0.0.1:6881# Connect to remote peernode src/peer.js --port 6883 --file file.zip --peer 192.168.1.50:6881
The peer address is parsed in src/peer.js:39-50:
if (peerAddress) { const sepIndex = peerAddress.lastIndexOf(':'); if (sepIndex === -1) { console.error('Formato de --peer inválido. Use host:puerto'); process.exit(1); } peerHost = peerAddress.substring(0, sepIndex); peerPort = parseInt(peerAddress.substring(sepIndex+1), 10); if (!peerPort) { console.error('Formato de --peer inválido. Puerto no válido.'); process.exit(1); }}
For leechers without an initial peer, the node will print a warning:
Advertencia: Este nodo no tiene el archivo y ningún peer inicial fue proporcionado. El nodo esperará a que algún seed se conecte.
# Share a file on port 6881node src/peer.js --port 6881 --file "/path/to/file.ext"
Expected output:
Nodo P2P iniciado. ID: ab12cd34ef56, escuchando en puerto 6881.Archivo disponible para compartir: "file.ext" (1048576 bytes). Esperando conexiones de pares...