Skip to content

Commit

Permalink
[pac-proxy-agent] Add servername to tls options when connecting in DI…
Browse files Browse the repository at this point in the history
…RECT (#159)
  • Loading branch information
mceIdo committed May 9, 2023
1 parent 63adbce commit bf20b04
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/stupid-queens-listen.md
@@ -0,0 +1,5 @@
---
'pac-proxy-agent': patch
---

Add `servername` to tls connection options when pac-proxy-agent results in DIRECT connection
10 changes: 9 additions & 1 deletion packages/pac-proxy-agent/src/index.ts
Expand Up @@ -232,7 +232,15 @@ export class PacProxyAgent<Uri extends string> extends Agent {

if (type === 'DIRECT') {
// Direct connection to the destination endpoint
socket = secureEndpoint ? tls.connect(opts) : net.connect(opts);
if (secureEndpoint) {
const servername = opts.servername || opts.host;
socket = tls.connect({
...opts,
servername: (!servername || net.isIP(servername)) ? undefined : servername,
});
} else {
socket = net.connect(opts);
}
} else if (type === 'SOCKS' || type === 'SOCKS5') {
// Use a SOCKSv5h proxy
agent = new SocksProxyAgent(`socks://${target}`, this.opts);
Expand Down

1 comment on commit bf20b04

@vercel
Copy link

@vercel vercel bot commented on bf20b04 May 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

proxy-agents – ./

proxy-agents-git-main-tootallnate.vercel.app
proxy-agents.vercel.app
proxy-agents-tootallnate.vercel.app

Please sign in to comment.