plabayo / rama

modular service framework to move and transform network packets
https://ramaproxy.org
Apache License 2.0
189 stars 20 forks source link

Support IP modes in connector and resolver #331

Open GlenDC opened 1 month ago

GlenDC commented 1 month ago

enum IpMode

Then wrapper types can be made:

GlenDC commented 1 month ago

These wrapper types are then to be used in the core tcp connector code, as to make sure we respect these desires when establishing a tcp connection.

AnkurRathore commented 1 month ago

@GlenDC I would like to work on this. let me know what I need to do to start contributing.

GlenDC commented 1 month ago

Hi @AnkurRathore , welcome and nice to meet you. It's all yours for now.

I can give you the high level steps that I would undertake if i would do it myself, but feel free to diviate where you see fit at your own best judgement:

  1. implement the enum types as I'll lay them out at end of my comment;
  2. use DnsResolveIpMode in https://github.com/plabayo/rama/blob/45848f3e0276d7490e0f71e021823c897137dbed/rama-tcp/src/client/connect.rs#L153 to respect that enum (both to not resolve what shouldn't be resolved, and also to make it respect the preference. Because currently both IPv4 and IPv6 are allowed, and Ipv6 is currently always preferred (see delay))
  3. use ConnectIpMode in (a) https://github.com/plabayo/rama/blob/45848f3e0276d7490e0f71e021823c897137dbed/rama-tcp/src/client/connect.rs#L121 to ensure we don't connect to IPv4/IPv6 if not desired, also use that same mode to overwrite DnsResolveIPMode in case ConnectIPMode is stricter. E.g. if IPv4 only is desired, than it's pointless to request Ipv6 addresses :)
enum DnsResolveIpMode
    dual (default)
    singleIpV4
    singleIpV6
    dualPreferIpv4

enum ConnectIpMode
    dual (default)
    ipv4
    ipv6

I do not know how good your rust or network knowledge is. So in case something is not clear now, or at any point, do feel free to ask. I'm here to mentor where you see fit. Also feel free to open a PR even if not yet "finished", in case you are stuck, want guidance or have questions of any other kind. I'm here. I do not always respond immediately, but I do promise I'll always get back to you eventually.

AnkurRathore commented 1 month ago

@GlenDC Thanks for including me. I have some experience in developing Software defined networking applications using Python. I have a basic knowledge about Rust and thought by improving that by getting involved in open source projects. I will be going through the Rama book and the source code to gain a better understanding. Will surely get back to you when stuck.