Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/utils/socksProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ function hexToNumber(hex: string): number {
}

function ipToSocksAddress(address: string): number[] {
// Node.js may return IPv4-mapped IPv6 addresses (e.g. "::ffff:10.0.0.1") from
// socket.localAddress on dual-stack systems. Unwrap them to plain IPv4.
const ipv4Mapped = /^::ffff:(\d+\.\d+\.\d+\.\d+)$/i.exec(address);
if (ipv4Mapped)
address = ipv4Mapped[1];
if (net.isIPv4(address)) {
return [
0x01, // IPv4
Expand Down
Loading