@@ -92,6 +92,8 @@ struct SSConfig {
92
92
#[ serde( skip_serializing_if = "Option::is_none" ) ]
93
93
local_port : Option < u16 > ,
94
94
#[ serde( skip_serializing_if = "Option::is_none" ) ]
95
+ protocol : Option < String > ,
96
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
95
97
manager_address : Option < String > ,
96
98
#[ serde( skip_serializing_if = "Option::is_none" ) ]
97
99
manager_port : Option < u16 > ,
@@ -923,6 +925,20 @@ impl Config {
923
925
// shadowsocks uses SOCKS5 by default
924
926
let mut local_config = LocalConfig :: new ( local_addr, ProtocolType :: Socks ) ;
925
927
local_config. mode = global_mode;
928
+ local_config. protocol = match config. protocol {
929
+ None => ProtocolType :: Socks ,
930
+ Some ( p) => match p. parse :: < ProtocolType > ( ) {
931
+ Ok ( p) => p,
932
+ Err ( ..) => {
933
+ let err = Error :: new (
934
+ ErrorKind :: Malformed ,
935
+ "`protocol` invalid" ,
936
+ Some ( format ! ( "unrecognized protocol {}" , p) ) ,
937
+ ) ;
938
+ return Err ( err) ;
939
+ }
940
+ } ,
941
+ } ;
926
942
nconfig. local . push ( local_config) ;
927
943
}
928
944
@@ -1546,6 +1562,9 @@ impl fmt::Display for Config {
1546
1562
ServerAddr :: SocketAddr ( ref sa) => sa. port ( ) ,
1547
1563
ServerAddr :: DomainName ( .., port) => port,
1548
1564
} ) ;
1565
+ if local. protocol != ProtocolType :: Socks {
1566
+ jconf. protocol = Some ( local. protocol . as_str ( ) . to_owned ( ) ) ;
1567
+ }
1549
1568
} else {
1550
1569
let mut jlocals = Vec :: with_capacity ( self . local . len ( ) ) ;
1551
1570
for local in & self . local {
0 commit comments