@@ -148,6 +148,8 @@ struct SSConfig {
148
148
plugin_opts : Option < String > ,
149
149
#[ serde( skip_serializing_if = "Option::is_none" ) ]
150
150
plugin_args : Option < Vec < String > > ,
151
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
152
+ plugin_mode : Option < String > ,
151
153
152
154
#[ serde( skip_serializing_if = "Option::is_none" ) ]
153
155
timeout : Option < u64 > ,
@@ -326,6 +328,8 @@ struct SSServerExtConfig {
326
328
plugin_opts : Option < String > ,
327
329
#[ serde( skip_serializing_if = "Option::is_none" ) ]
328
330
plugin_args : Option < Vec < String > > ,
331
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
332
+ plugin_mode : Option < String > ,
329
333
330
334
#[ serde( skip_serializing_if = "Option::is_none" ) ]
331
335
timeout : Option < u64 > ,
@@ -1646,6 +1650,20 @@ impl Config {
1646
1650
plugin : p. clone ( ) ,
1647
1651
plugin_opts : config. plugin_opts . clone ( ) ,
1648
1652
plugin_args : config. plugin_args . clone ( ) . unwrap_or_default ( ) ,
1653
+ plugin_mode : match config. plugin_mode {
1654
+ None => Mode :: TcpOnly ,
1655
+ Some ( ref mode) => match mode. parse :: < Mode > ( ) {
1656
+ Ok ( m) => m,
1657
+ Err ( ..) => {
1658
+ let e = Error :: new (
1659
+ ErrorKind :: Malformed ,
1660
+ "malformed `plugin_mode`, must be one of `tcp_only`, `udp_only` and `tcp_and_udp`" ,
1661
+ None ,
1662
+ ) ;
1663
+ return Err ( e) ;
1664
+ }
1665
+ } ,
1666
+ } ,
1649
1667
} ;
1650
1668
nsvr. set_plugin ( plugin) ;
1651
1669
}
@@ -1773,6 +1791,20 @@ impl Config {
1773
1791
plugin : p,
1774
1792
plugin_opts : svr. plugin_opts ,
1775
1793
plugin_args : svr. plugin_args . unwrap_or_default ( ) ,
1794
+ plugin_mode : match svr. plugin_mode {
1795
+ None => Mode :: TcpOnly ,
1796
+ Some ( ref mode) => match mode. parse :: < Mode > ( ) {
1797
+ Ok ( m) => m,
1798
+ Err ( ..) => {
1799
+ let e = Error :: new (
1800
+ ErrorKind :: Malformed ,
1801
+ "malformed `plugin_mode`, must be one of `tcp_only`, `udp_only` and `tcp_and_udp`" ,
1802
+ None ,
1803
+ ) ;
1804
+ return Err ( e) ;
1805
+ }
1806
+ } ,
1807
+ } ,
1776
1808
} ;
1777
1809
nsvr. set_plugin ( plugin) ;
1778
1810
}
@@ -1889,6 +1921,20 @@ impl Config {
1889
1921
plugin : p,
1890
1922
plugin_opts : config. plugin_opts ,
1891
1923
plugin_args : config. plugin_args . unwrap_or_default ( ) ,
1924
+ plugin_mode : match config. plugin_mode {
1925
+ None => Mode :: TcpOnly ,
1926
+ Some ( ref mode) => match mode. parse :: < Mode > ( ) {
1927
+ Ok ( m) => m,
1928
+ Err ( ..) => {
1929
+ let e = Error :: new (
1930
+ ErrorKind :: Malformed ,
1931
+ "malformed `plugin_mode`, must be one of `tcp_only`, `udp_only` and `tcp_and_udp`" ,
1932
+ None ,
1933
+ ) ;
1934
+ return Err ( e) ;
1935
+ }
1936
+ } ,
1937
+ } ,
1892
1938
} ) ;
1893
1939
}
1894
1940
}
@@ -2461,6 +2507,13 @@ impl fmt::Display for Config {
2461
2507
Some ( p. plugin_args . clone ( ) )
2462
2508
}
2463
2509
} ) ;
2510
+ jconf. plugin_mode = match svr. plugin ( ) {
2511
+ None => None ,
2512
+ Some ( p) => match p. plugin_mode {
2513
+ Mode :: TcpOnly => None ,
2514
+ _ => Some ( p. plugin_mode . to_string ( ) ) ,
2515
+ } ,
2516
+ } ;
2464
2517
jconf. timeout = svr. timeout ( ) . map ( |t| t. as_secs ( ) ) ;
2465
2518
jconf. mode = Some ( svr. mode ( ) . to_string ( ) ) ;
2466
2519
@@ -2510,6 +2563,13 @@ impl fmt::Display for Config {
2510
2563
Some ( p. plugin_args . clone ( ) )
2511
2564
}
2512
2565
} ) ,
2566
+ plugin_mode : match svr. plugin ( ) {
2567
+ None => None ,
2568
+ Some ( p) => match p. plugin_mode {
2569
+ Mode :: TcpOnly => None ,
2570
+ _ => Some ( p. plugin_mode . to_string ( ) ) ,
2571
+ } ,
2572
+ } ,
2513
2573
timeout : svr. timeout ( ) . map ( |t| t. as_secs ( ) ) ,
2514
2574
remarks : svr. remarks ( ) . map ( ToOwned :: to_owned) ,
2515
2575
id : svr. id ( ) . map ( ToOwned :: to_owned) ,
0 commit comments