NodeJSでSOCKS5プロキシを介してUDPパケットを送信する方法はありますか?
同様に、UDP ソケットを特定の localAddress にバインドすることは可能ですか?
クライアントから UDP パケットを送信するには、クライアントの接続要求のフィールド 2 に値 0x03 を指定する必要があります。クライアントの接続要求のフィールドを参照してください。
field 1: SOCKS version number, 1 byte (must be 0x05 for this version)
field 2: command code, 1 byte:
0x01 = establish a TCP/IP stream connection
0x02 = establish a TCP/IP port binding
0x03 = associate a UDP port
field 3: reserved, must be 0x00
field 4: address type, 1 byte:
0x01 = IPv4 address
0x03 = Domain name
0x04 = IPv6 address
field 5: destination address of
4 bytes for IPv4 address
1 byte of name length followed by the name for Domain name
16 bytes for IPv6 address
field 6: port number in a network byte order, 2 bytes
たとえば、参照されているライブラリのコード行を 0x01 から 0x03 に変更する必要があります。
buffer.push(0x01); // Command code: establish a TCP/IP stream connection
特定のローカル アドレスにバインドする方法がわかりません。
The SOCKS5 protocol supports UDP connections, however most libraries for SOCKS5 only support TCP since UDP isn't very frequently used on the web (except for DNS). The protocol itself isn't very complicated, so it shouldn't be to hard to rewrite an existing library (maybe this one?) to suit your needs.
http://www.ietf.org/rfc/rfc1928.txtおよびhttp://en.wikipedia.org/wiki/SOCKS#SOCKS5によると、UDP は実際には Socks5 でサポートされているはずです。
ただし、一部の SOCKS5 実装を見ると、実装で UDP がサポートされていないことがわかります。例: https://gist.github.com/telamon/1127459またはhttps://gist.github.com/robertpitt/3203203 (.
したがって、それをサポートするライブラリ (UDP バインディング) が見つからない限り、短い答えは NO です。