Skip to content

Commit

Permalink
Remove net.isIP() check for TLS servername (#312)
Browse files Browse the repository at this point in the history
Fixes #308.
  • Loading branch information
TooTallNate committed Apr 6, 2024
1 parent 28104d2 commit 5908e84
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
7 changes: 7 additions & 0 deletions .changeset/seven-camels-check.md
@@ -0,0 +1,7 @@
---
"https-proxy-agent": patch
"pac-proxy-agent": patch
"socks-proxy-agent": patch
---

Remove `net.isIP()` check for TLS `servername`
5 changes: 2 additions & 3 deletions packages/https-proxy-agent/src/index.ts
Expand Up @@ -96,8 +96,7 @@ export class HttpsProxyAgent<Uri extends string> extends Agent {
this.connectOpts.servername || this.connectOpts.host;
socket = tls.connect({
...this.connectOpts,
servername:
servername && net.isIP(servername) ? undefined : servername,
servername,
});
} else {
debug('Creating `net.Socket`: %o', this.connectOpts);
Expand Down Expand Up @@ -151,7 +150,7 @@ export class HttpsProxyAgent<Uri extends string> extends Agent {
return tls.connect({
...omit(opts, 'host', 'path', 'port'),
socket,
servername: net.isIP(servername) ? undefined : servername,
servername,
});
}

Expand Down
5 changes: 1 addition & 4 deletions packages/pac-proxy-agent/src/index.ts
Expand Up @@ -240,10 +240,7 @@ export class PacProxyAgent<Uri extends string> extends Agent {
const servername = opts.servername || opts.host;
socket = tls.connect({
...opts,
servername:
!servername || net.isIP(servername)
? undefined
: servername,
servername,
});
} else {
socket = net.connect(opts);
Expand Down
2 changes: 1 addition & 1 deletion packages/socks-proxy-agent/src/index.ts
Expand Up @@ -175,7 +175,7 @@ export class SocksProxyAgent extends Agent {
const tlsSocket = tls.connect({
...omit(opts, 'host', 'path', 'port'),
socket,
servername: net.isIP(servername) ? undefined : servername,
servername,
});

tlsSocket.once('error', (error) => {
Expand Down

0 comments on commit 5908e84

Please sign in to comment.