asavie / xdp

Package xdp allows one to use XDP sockets from the Go programming language.
BSD 3-Clause "New" or "Revised" License
298 stars 64 forks source link

how do also listen to a specific port and forward to another application port based on ip address? #25

Open kolinfluence opened 1 year ago

kolinfluence commented 1 year ago
  1. how do also listen to a specific port and forward to another application port based on ip address? e.g. how to listen to port 80, forward to port 8080 if crc/xxhash(123.123.123.123)%[number of cpu] + 8080?

[client 123.123.123.123] -> [listen port 80, xdp hash ip] -> [forward to app listening on port 8080+2 (hashed based on ip address)]

also,

  1. with reference to https://github.com/asavie/xdp/issues/23
kolinfluence commented 1 year ago

i just read this https://github.com/asavie/xdp/issues/13

so how do i forward to different af_xdp program based on ip address? since i cant divert to different application ports?

but https://github.com/xdp-project/xdp-tutorial/tree/master/packet-solutions

packet rewriting, rewrite port numbers. this works. i just need to rewrite port number that's all.

can u provide an example or clue on how to get this done? thx in advance.

can i buy u coffees for this? need to

  1. divert to port
  2. drop some ips based on the application reactions etc. (this can be later, shld be much easier. my app connects to a redis pub/sub and listens for bad ips and not sure how to connect to this af_xdp thing.)