Skip to content

Commit 992b002

Browse files
Fix bug with ipv6 conversion in ipToBuffer (#101)
1 parent 99633ae commit 992b002

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "socks",
33
"private": false,
4-
"version": "2.8.1",
4+
"version": "2.8.2",
55
"description": "Fully featured SOCKS proxy client supporting SOCKSv4, SOCKSv4a, and SOCKSv5. Includes Bind and Associate functionality.",
66
"main": "build/index.js",
77
"typings": "typings/index.d.ts",

src/common/helpers.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,9 @@ export function ipToBuffer(ip: string): Buffer {
236236
} else if (net.isIPv6(ip)) {
237237
// Handle IPv6 addresses
238238
const address = new Address6(ip);
239-
return Buffer.from(address.toByteArray());
239+
return Buffer.from(address.canonicalForm().split(":").map(segment => segment.padStart(4, '0')).join(''), 'hex');
240240
} else {
241241
throw new Error('Invalid IP address format');
242242
}
243243
}
244+

0 commit comments

Comments
 (0)