Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to proxy DNS requests when using a proxy-agent #344

Open
sheldhur opened this issue Nov 18, 2024 · 0 comments
Open

Unable to proxy DNS requests when using a proxy-agent #344

sheldhur opened this issue Nov 18, 2024 · 0 comments

Comments

@sheldhur
Copy link

sheldhur commented Nov 18, 2024

#324

I have the same problem when I use proxy-agent. In this package socks5h works like socks5

import url from 'url';
import https from 'https';
import { ProxyAgent } from 'proxy-agent';
import { SocksProxyAgent } from 'socks-proxy-agent';

const proxy = 'socks5h://127.0.0.1:9050';
const endpoint = 'https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion';

function sendHttpRequest(endpoint, agent) {
  const options = url.parse(endpoint);
  options.agent = agent;

  const outgoing = https.get(options);

  return new Promise((resolve, reject) => {
    outgoing.on('response', (res) => resolve(res));
    outgoing.on('error', (err) => reject(err));
  });
}

(async () => {
  try {
    const res = await sendHttpRequest(endpoint, new SocksProxyAgent(proxy));
    console.log('onion via socks-proxy-agent', res.statusCode);
  } catch (err) {
    console.error('onion via socks-proxy-agent', err);
  }


  try {
    const res = await sendHttpRequest(endpoint, new ProxyAgent(proxy));
    console.log('onion via proxy-agent', res.statusCode);
  } catch (err) {
    console.error('onion via proxy-agent', err);
  }
})();
onion via socks-proxy-agent 200
onion via proxy-agent Error: getaddrinfo ENOTFOUND duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:109:26) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant