GithubHelp home page GithubHelp logo

Comments (7)

txthinking avatar txthinking commented on August 11, 2024

Thx, I am working on this function.
Server before handle udp packet, it should check the src if prepared by a tcp connection

from socks5.

txthinking avatar txthinking commented on August 11, 2024

This is nothing about LAN or WLAN, it just care DST.ADDR and DST.PORT.

Before send UDP data, client send DST.ADDR and DST.PORT with a TCP connection, so we can store DST.ADDR and DST.PORT and compare it with src of UDP when UDP data come.

But If server get zero:zero DST.ADDR and DST.PORT with a TCP connection, how to limit or compare it with src of UDP when UDP data come.
https://stackoverflow.com/questions/62283351/how-to-use-socks-5-proxy-with-tidudpclient-properly
This link said:

If the requested Host/Port is all zeros, the relay should simply use the Host/Port that sent the request.
That means server should assume DST.ADDR and DST.PORT is src of TCP? [a]

this[a] is what I did, but looks like some software don't do with this. like proxycap do:

proxycap(src1) -- tcp --zero DST.ADDR and DST.PORT--> socks5 server
proxycap(src2) -- udp --socks5 server

If the stackoverflow link is correct, src2 should equal with src1

from socks5.

Danieldachao avatar Danieldachao commented on August 11, 2024

Yes, DST.ADDR and DST.PORT matter.
But if the client is in a lan, it does not have a public ip. When it wants to negotiate with the server, it can only fill local ip and port into DST.ADDR and DST.PORT. After negotiation, when udp packets come, the server would get a public ip which is mapped by a NAT device like a Router instead of the local ip which the client filled in during the negotiation. So I still can not compare those 2 address.
Does this make sense?
Or in this situation, the client should use zero:zero DST.ADDR and DST.PORT ?

from socks5.

txthinking avatar txthinking commented on August 11, 2024

https://github.com/txthinking/socks5/blob/master/server.go#L43

If set LimitUDP with true, server will check incoming src if it has been sent by a prev tcp connection

from socks5.

txthinking avatar txthinking commented on August 11, 2024

Yes, DST.ADDR and DST.PORT matter.
But if the client is in a lan, it does not have a public ip. When it wants to negotiate with the server, it can only fill local ip and port into DST.ADDR and DST.PORT. After negotiation, when udp packets come, the server would get a public ip

Yes, this is NAT's work. socks5 server only can handle incoming src, https://en.wikipedia.org/wiki/Network_address_translation

And more, socks5 server is also a NAT too, this library implements Symmetric NAT

from socks5.

hayden-pan avatar hayden-pan commented on August 11, 2024

Yes, DST.ADDR and DST.PORT matter.
But if the client is in a lan, it does not have a public ip. When it wants to negotiate with the server, it can only fill local ip and port into DST.ADDR and DST.PORT. After negotiation, when udp packets come, the server would get a public ip

Yes, this is NAT's work. socks5 server only can handle incoming src, https://en.wikipedia.org/wiki/Network_address_translation

And more, socks5 server is also a NAT too, this library implements Symmetric NAT

The situation mentioned by @Danieldachao just like this:
Application Client - SOCKS Client - NAT - SOCKS Server - Application Server
Then the SOCKS Client can only set the UDP Association DST.ADDR and DST.PORT with zero because can not foresee the NAT's behavior. There is no problem. The problem is how SOCKS Server relate a incoming udp packet with current tcp connection when a lot of SOCKS Clients request the UDP Association command concurrent ?

After my deep thinking, we can set the reply of UDP Association command with a dynamic BND.PORT to solve. Then SOCKS Server can relate the incoming udp packet with a TCP connection correct.

from socks5.

txthinking avatar txthinking commented on August 11, 2024

Server.LimitUDP

from socks5.

Related Issues (13)

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.