-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support Socks5 TCP + UDP outbound (#491)
- Loading branch information
Showing
23 changed files
with
774 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ config.yaml | |
cache.db | ||
Country.mmdb | ||
ruleset/ | ||
geosite.dat | ||
|
||
rust-project.json | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
port: 8888 | ||
socks-port: 8889 | ||
mixed-port: 8899 | ||
|
||
mode: rule | ||
log-level: debug | ||
external-controller: 127.0.0.1:6170 | ||
|
||
|
||
proxies: | ||
- name: "socks5-noauth" | ||
type: socks5 | ||
server: 10.0.0.13 | ||
port: 10800 | ||
udp: true | ||
|
||
- name: "socks5-auth" | ||
type: socks5 | ||
server: 10.0.0.13 | ||
port: 10801 | ||
username: user | ||
password: password | ||
udp: true | ||
|
||
- name: "socks5-tls" | ||
type: socks5 | ||
server: 10.0.0.13 | ||
port: 10802 | ||
username: user | ||
password: password | ||
tls: true | ||
udp: true | ||
skip-cert-verify: true | ||
rules: | ||
# - MATCH, socks5-noauth | ||
# - MATCH, socks5-auth | ||
- MATCH, socks5-tls | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod shadowsocks; | ||
pub mod socks5; | ||
pub mod tor; | ||
pub mod trojan; | ||
pub mod tuic; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::{ | ||
config::internal::proxy::OutboundSocks5, | ||
proxy::{ | ||
socks::{Handler, HandlerOptions}, | ||
AnyOutboundHandler, | ||
}, | ||
}; | ||
|
||
impl TryFrom<OutboundSocks5> for AnyOutboundHandler { | ||
type Error = crate::Error; | ||
|
||
fn try_from(value: OutboundSocks5) -> Result<Self, Self::Error> { | ||
(&value).try_into() | ||
} | ||
} | ||
|
||
impl TryFrom<&OutboundSocks5> for AnyOutboundHandler { | ||
type Error = crate::Error; | ||
|
||
fn try_from(s: &OutboundSocks5) -> Result<Self, Self::Error> { | ||
let h = Handler::new(HandlerOptions { | ||
name: s.name.to_owned(), | ||
common_opts: Default::default(), | ||
server: s.server.to_owned(), | ||
port: s.port, | ||
user: s.username.clone(), | ||
password: s.password.clone(), | ||
udp: s.udp, | ||
tls: s.tls, | ||
sni: s.sni.clone().unwrap_or(s.server.to_owned()), | ||
skip_cert_verify: s.skip_cert_verify, | ||
}); | ||
Ok(h) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
mod inbound; | ||
mod outbound; | ||
mod socks5; | ||
|
||
pub use inbound::{handle_tcp, Listener, Socks5UDPCodec, SOCKS5_VERSION}; | ||
pub use inbound::{handle_tcp, Listener, Socks5UDPCodec}; | ||
pub use outbound::{Handler, HandlerOptions}; | ||
pub use socks5::SOCKS5_VERSION; |
Oops, something went wrong.