Giter Club home page Giter Club logo

Comments (20)

rofl0r avatar rofl0r commented on July 22, 2024 1

that functionality is not built in. you could run microsocks through proxychains-ng though and configure it for proxydns_old mode, then modify the proxyresolv script to query the nameserver of your choice. alternatively you can modify the code of microsocks to run a custom DNS resolver function instead of getaddrinfo(), for example using https://github.com/rofl0r/firedns . though you'd need to piece it together yourself.

from microsocks.

DUOLabs333 avatar DUOLabs333 commented on July 22, 2024

Is there a way to force it to use the client's DNS?

from microsocks.

rofl0r avatar rofl0r commented on July 22, 2024

depends on whether the client application using the proxy has a setting to force DNS being looked up before making the proxy connection. it could then send raw ipv4/ipv6 instead of host name to the server. though i think finding such an option is unlikely as its less efficient and the opposite of what most people want.

from microsocks.

srd424 avatar srd424 commented on July 22, 2024

Depending on what you're trying to achieve, you could run microsocks in a namespace to allow setting a different DNS server?

from microsocks.

DUOLabs333 avatar DUOLabs333 commented on July 22, 2024

How would that work?

from microsocks.

srd424 avatar srd424 commented on July 22, 2024

Good question .. you could create a whole new network namespace but that's probably overkill. Maybe something like this? (run as root)

cat >test-ns <<EOM
#! /bin/bash

echo "nameserver 1.2.3.4" >/tmp/new-resolv.conf
mount /tmp/new-resolv.conf /etc/resolv.conf -o bind

cat /etc/resolv.conf
EOM
chmod a+x ./test-ns
cat /etc/resolv.conf
unshare -m ./test-ns
cat /etc/resolv.conf

You should notice that 'test-ns' sees it's own version of resolv.conf compared to the main system .. obviously you can then just change the script to start microsocks. If using systemd you can probably configure the unit file directly somehow.

Note that if you're using systemd-resolved's nss-resolve the above might well not work .. you might need to bind mount over /etc/nsswitch.conf as well to disable it.

from microsocks.

srd424 avatar srd424 commented on July 22, 2024

Hmm, looks like cwrap can redirect resolv.conf as well: https://cwrap.org/resolv_wrapper.html

from microsocks.

DUOLabs333 avatar DUOLabs333 commented on July 22, 2024

I just gave up and changed the DNS on the server. Also, when testing it, it works fine on a computer -- but with SagerNet on Android, the latency is >1000 ms (Shadowsocks is <150 ms).

from microsocks.

rofl0r avatar rofl0r commented on July 22, 2024

the latency is >1000 ms

the socks5 protocol is kinda inefficient, it requires several packets sent hence and forth to establish a connection. that's the reason why tor defaults to using socks4a instead.
i've implemented a socks4a server here: https://github.com/rofl0r/pysocks4 . it will likely work better in regard to latency. http proxies also do not have this issue, as all the required information to establish a connection is included in the first packet. tinyproxy is a good and reasonably lightweight option for http proxying.

from microsocks.

DUOLabs333 avatar DUOLabs333 commented on July 22, 2024

Can pysocks4 be used with python3, or will some things need to change?

from microsocks.

rofl0r avatar rofl0r commented on July 22, 2024

Can pysocks4 be used with python3, or will some things need to change?

it will likely need changes, as py3 made the unfortunate decision to treat all string literals as unicode rather than bytes. but you might just try it out.

from microsocks.

DUOLabs333 avatar DUOLabs333 commented on July 22, 2024

I just tried pproxy, apparently MacOS can't handle socks4

from microsocks.

DUOLabs333 avatar DUOLabs333 commented on July 22, 2024

And it seems like I was mistaken -- microsocks is pretty fast, maybe it was an one-off bad connection. For my purposes, http proxies aren't enough.

from microsocks.

DUOLabs333 avatar DUOLabs333 commented on July 22, 2024

Another problem I found -- while dig, ping, etc does reflect DNS blocks correctly, browsers do not use the system DNS, but use their own. This is on MacOS.

from microsocks.

rofl0r avatar rofl0r commented on July 22, 2024

browsers do not use the system DNS

firefox has a checkbox "use proxy to perform DNS queries (socks5 only)" which can influence this behaviour. if unchecked, it does what you want, namely use the client's nameserver rather than socks server's.

from microsocks.

DUOLabs333 avatar DUOLabs333 commented on July 22, 2024

from microsocks.

srd424 avatar srd424 commented on July 22, 2024

I have a feeling Chrome passes some stuff to the proxy and looks other stuff up (e.g. prefetches) itself, annoyingly. I remember having to do battle with that when I was trying to force everything through the proxy. Trying googling around the "--host-resolver-rules" option to Chrome..

from microsocks.

rofl0r avatar rofl0r commented on July 22, 2024

btw, i just added support for py3 to pysocks4.

from microsocks.

DUOLabs333 avatar DUOLabs333 commented on July 22, 2024

Yeah, apparently, MacOS doesn't have SOCKS4 support.

from microsocks.

themanifold avatar themanifold commented on July 22, 2024

For anyone who has come across this, here is an example proxychains.conf that uses the proxy_dns_old directive:

proxy_dns_old
localnet 0.0.0.0/0.0.0.0

[ProxyList]
<proto> <ip> <port>

DNS requests will be resolved by invoking the proxyresolv script on your system $PATH. You can choose the IP address of the DNS server by editing that file.

from microsocks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.