Skip to content

Commit

Permalink
g3proxy: update socks5 proxy udp peer ip transmute rules
Browse files Browse the repository at this point in the history
  • Loading branch information
zh-jq-b committed Oct 16, 2023
1 parent e25e477 commit a9da70c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions g3proxy/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ v1.7.27:
- Optimization: set default c-ares init options as c-ares 1.20.1 default values
- Feature: rename trust-dns resolver type to hickory to be sync with upstream
- Feature: add dns over http/3 support in hickory resolver
- Feature: use tcp peer ip if socks5 proxy returns unspecified udp peer ip

v1.7.26:
- BUG FIX: fix deb and rpm build scripts
Expand Down
6 changes: 4 additions & 2 deletions g3proxy/src/config/escaper/proxy_socks5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,10 @@ impl ProxySocks5EscaperConfig {
tcp_peer_ip: IpAddr,
) -> SocketAddr {
if let Some(map) = &self.transmute_udp_peer_ip {
let ip = map.get(&returned_addr.ip()).unwrap_or(&tcp_peer_ip);
SocketAddr::new(*ip, returned_addr.port())
let ip = map.get(&returned_addr.ip()).copied().unwrap_or(tcp_peer_ip);
SocketAddr::new(ip, returned_addr.port())
} else if returned_addr.ip().is_unspecified() {
SocketAddr::new(tcp_peer_ip, returned_addr.port())
} else {
returned_addr
}
Expand Down
6 changes: 4 additions & 2 deletions g3proxy/src/escape/proxy_float/peer/socks5/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ impl ProxyFloatSocks5Peer {
tcp_peer_ip: IpAddr,
) -> SocketAddr {
if let Some(map) = &self.transmute_udp_peer_ip {
let ip = map.get(&returned_addr.ip()).unwrap_or(&tcp_peer_ip);
SocketAddr::new(*ip, returned_addr.port())
let ip = map.get(&returned_addr.ip()).copied().unwrap_or(tcp_peer_ip);
SocketAddr::new(ip, returned_addr.port())
} else if returned_addr.ip().is_unspecified() {
SocketAddr::new(tcp_peer_ip, returned_addr.port())
} else {
returned_addr
}
Expand Down

0 comments on commit a9da70c

Please sign in to comment.