Skip to content

Commit

Permalink
Fix bug with ipv6 conversion in ipToBuffer (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshGlazebrook authored Apr 9, 2024
1 parent 99633ae commit 992b002
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "socks",
"private": false,
"version": "2.8.1",
"version": "2.8.2",
"description": "Fully featured SOCKS proxy client supporting SOCKSv4, SOCKSv4a, and SOCKSv5. Includes Bind and Associate functionality.",
"main": "build/index.js",
"typings": "typings/index.d.ts",
Expand Down
3 changes: 2 additions & 1 deletion src/common/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,9 @@ export function ipToBuffer(ip: string): Buffer {
} else if (net.isIPv6(ip)) {
// Handle IPv6 addresses
const address = new Address6(ip);
return Buffer.from(address.toByteArray());
return Buffer.from(address.canonicalForm().split(":").map(segment => segment.padStart(4, '0')).join(''), 'hex');
} else {
throw new Error('Invalid IP address format');
}
}

0 comments on commit 992b002

Please sign in to comment.