mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-04-21 22:39:08 +00:00
Implement GFW bypass (see issue #35)
This commit is contained in:
parent
75bfdcc95a
commit
6767076a6b
1 changed files with 12 additions and 2 deletions
14
src/socks.rs
14
src/socks.rs
|
@ -69,7 +69,11 @@ pub enum SocksCommand {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
enum SocksAuthentication {
|
enum SocksAuthentication {
|
||||||
None = 0,
|
None = 0,
|
||||||
|
GssApi = 1,
|
||||||
Password = 2,
|
Password = 2,
|
||||||
|
ChallengeHandshake = 3,
|
||||||
|
Unassigned = 4,
|
||||||
|
Unassigned100 = 100,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
@ -163,18 +167,24 @@ impl SocksConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
SocksVersion::V5 => {
|
SocksVersion::V5 => {
|
||||||
|
// Providing unassigned methods is supposed to bypass China's GFW.
|
||||||
|
// For details, refer to https://github.com/blechschmidt/tun2proxy/issues/35.
|
||||||
if credentials.is_some() {
|
if credentials.is_some() {
|
||||||
self.server_outbuf.extend(&[
|
self.server_outbuf.extend(&[
|
||||||
self.version as u8,
|
self.version as u8,
|
||||||
2u8,
|
4u8,
|
||||||
SocksAuthentication::None as u8,
|
SocksAuthentication::None as u8,
|
||||||
SocksAuthentication::Password as u8,
|
SocksAuthentication::Password as u8,
|
||||||
|
SocksAuthentication::Unassigned as u8,
|
||||||
|
SocksAuthentication::Unassigned100 as u8,
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
self.server_outbuf.extend(&[
|
self.server_outbuf.extend(&[
|
||||||
self.version as u8,
|
self.version as u8,
|
||||||
1u8,
|
3u8,
|
||||||
SocksAuthentication::None as u8,
|
SocksAuthentication::None as u8,
|
||||||
|
SocksAuthentication::Unassigned as u8,
|
||||||
|
SocksAuthentication::Unassigned100 as u8,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue