GithubHelp home page GithubHelp logo

Comments (11)

ambrop72 avatar ambrop72 commented on August 15, 2024 1

Hi,

  • Software is based on a single-threaded event-driven architecture, so read up on event loops etc.. The event loop implementation is in system/BReactor_badvpn.{h,c}.
  • To work with UDP, use the existing BDatagram facility (look at system/BDatagram.h for the API).
  • The tun2socks main implementation is in tun2socks/tun2socks.c. The most important functions here are:
    • process_device_udp_packet (called to handle a UDP packet coming in from the TUN and needs to be sent),
    • BTap_Send - use this when you receive a packet to send it into the TUN, see for example what udpgw_client_handler_received does.
  • The current UDP support in tun2socks uses the custom "udpgw" server - you will need to add conditionals (e.g. in the above mentioned places) so that UDP support is provided either by udpgw or UDP Associate.
  • You will need to maintain a collection of UDP "associations", and you will need to associate packets coming from TUN with a association possibly involving creation of one. Each "association" object will be responsible for a particular (LocalPort, RemotePort, LocalAddress, RemoteAddress) combination.
  • Each association object will need to do the SOCKS handshaking using TCP. You can probably copy a lot of code from current socksclient/ code which is for TCP connections. It would be best to separate this code into its own module. Or maybe the existing socksclient could be extended to also do UDP Associate, your call.
  • You will probably need to buffer packets within associations while you are doing the SOCKS handshaking, to prevent undesired loss.

I need to go right now, I can provide further guidance...

from badvpn.

GF-Huang avatar GF-Huang commented on August 15, 2024

Well, thanks your detailed guides.
I go to have a try first.

from badvpn.

GF-Huang avatar GF-Huang commented on August 15, 2024

Hi,
Another question: Why not use map(dictionary) (use source port or destination port as key or both) to manage connections instead of AVL tree for enhance performance of finding connection in "UdpGwClient.c Line 529"?

from badvpn.

4-FLOSS-Free-Libre-Open-Source-Software avatar 4-FLOSS-Free-Libre-Open-Source-Software commented on August 15, 2024

@greatfirewall give #71 a try

from badvpn.

diegocr avatar diegocr commented on August 15, 2024

While waiting for #71 to get merged (any eta?) a good workaround would be using dns2socks

from badvpn.

GF-Huang avatar GF-Huang commented on August 15, 2024

Emm.. I had built myself product to implement this feature..
If anyone is interested, you can take a look Win2Socks.

from badvpn.

diegocr avatar diegocr commented on August 15, 2024

Interesting :)

from badvpn.

ambrop72 avatar ambrop72 commented on August 15, 2024

@greatfirewall, it is not clear to me if your product is based on tun2socks code?

from badvpn.

GF-Huang avatar GF-Huang commented on August 15, 2024

@greatfirewall, it is not clear to me if your product is based on tun2socks code?

No, I completely developed it myself. I am sorry to make you feel confused. :)

from badvpn.

ambrop72 avatar ambrop72 commented on August 15, 2024

@greatfirewall, okay good for you, thanks for the info!

from badvpn.

GF-Huang avatar GF-Huang commented on August 15, 2024

@ambrop72 You're welcome.

from badvpn.

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.