Comments (7)
It'd be a nice idea for the roadmap, but TCP is what lets us keep track of proxied connections. We'd effectively have to build a UDP state machine.
I'll definitely keep it in mind when I get around to it.
from protoplex.
Hello Guys
I've implemented UDP proxying for my own purposes(Wireguard connection for now), @SapphicCode if you are interested in merging it please let me know and I'll create a PR.
You can have a look at my implementation here - https://github.com/zekker6/protoplex . Feedback is much appreciated.
Binding different addresses for TCP and UDP is not implemented yet but that will be easy to add.
from protoplex.
@zekker6 you are right, it works! After some investigations the problem was not socat, but ncat server. I had to forward the incoming traffic to different ports ( rather than just listen ) to make it work
Your implementation works like a charm with this my last test!(:
from protoplex.
Awesome! I'm glad you liked the idea!(:
I will wait for it like someone that waits for the last episode of his favorite tv show ahah
from protoplex.
@zekker6 amazing!(: The only issue is that the UDP server sends the data to all the clients connected. See the following example with the string "bbbbbbbbb"
2 ncat udp clients -> protoplex UDP server -> socat UDP to TCP -> ncat TCP server
The string "SEZI3t097GZSHEOI" was used for protoplex to handle this test
from protoplex.
Yeah, that's... a bit of a problem, hence why I mentioned state tracking. You need to keep track of your clients individually otherwise this happens.
For now I'd suggest just iptables / any other app on the UDP port (TCP and UDP can occupy the same port on different sockets), that way you don't interfere with multiple clients and you get statekeeping by the respective application.
from protoplex.
@G0ne I'm afraid there is an issue you've found is caused by test scenario(probably socat UDP to TCP part).
There is state tracking implemented based on saving client address(IP + port) as key.
I've tried to reproduce this by using following configuration: client1 -> protoplex -> server and client2 -> protoplex -> server.
Client source:
package main
import (
"log"
"net"
)
func main() {
addr, _ := net.ResolveUDPAddr("udp", "localhost:8443")
con, _ := net.DialUDP("udp", nil, addr)
log.Println(con)
_, e := con.Write([]byte{0x01, 0x00, 0x00, 0x00})
log.Println(e)
buf := make([]byte, 1000)
for {
con.ReadFromUDP(buf)
log.Println(string(buf))
}
}
Server source:
package main
import (
"log"
"net"
"time"
)
func main() {
addr, _ := net.ResolveUDPAddr("udp", "localhost:8444")
con, _ := net.ListenUDP("udp", addr)
log.Println(con)
buf := make([]byte, 1000)
for {
_, client, err := con.ReadFromUDP(buf)
log.Println(client.String(), err)
go func(client *net.UDPAddr) {
for {
_, e := con.WriteToUDP([]byte(client.String()), client)
log.Println(e)
time.Sleep(1 * time.Second)
}
}(client)
}
}
Server only accepts connection and sends client ip back every second.
Test result showed the following:
# client1
2021/07/29 09:05:17 127.0.0.1:41693
2021/07/29 09:05:18 127.0.0.1:41693
2021/07/29 09:05:19 127.0.0.1:41693
2021/07/29 09:05:20 127.0.0.1:41693
2021/07/29 09:05:21 127.0.0.1:41693
2021/07/29 09:05:22 127.0.0.1:41693
2021/07/29 09:05:23 127.0.0.1:41693
2021/07/29 09:05:24 127.0.0.1:41693
#client2
2021/07/29 09:05:15 127.0.0.1:35598
2021/07/29 09:05:16 127.0.0.1:35598
2021/07/29 09:05:17 127.0.0.1:35598
2021/07/29 09:05:18 127.0.0.1:35598
2021/07/29 09:05:19 127.0.0.1:35598
2021/07/29 09:05:20 127.0.0.1:35598
2021/07/29 09:05:21 127.0.0.1:35598
2021/07/29 09:05:22 127.0.0.1:35598
2021/07/29 09:05:23 127.0.0.1:35598
2021/07/29 09:05:24 127.0.0.1:35598
from protoplex.
Related Issues (6)
- MTPROTO Support HOT 4
- [Protocols] Wireguard support. HOT 1
- Fallback Protocol HOT 1
- Openvpn HOT 6
- Support for the RDP protocol
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protoplex.