Skip to content

Commit 420e451

Browse files
committed
add manager debug strings
1 parent 13c4fd1 commit 420e451

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

bin/ssmanager.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ fn main() {
4343
(@arg UDP_ONLY: -u conflicts_with[TCP_AND_UDP] "Server mode UDP_ONLY")
4444
(@arg TCP_AND_UDP: -U conflicts_with[UDP_ONLY] "Server mode TCP_AND_UDP")
4545

46-
(@arg CONFIG: -c --config +takes_value required_unless("MANAGER_ADDRESS")
46+
(@arg CONFIG: -c --config +takes_value required_unless("MANAGER_ADDR")
4747
"Shadowsocks configuration file (https://shadowsocks.org/en/config/quick-guide.html), \
4848
the only required fields are \"manager_address\" and \"manager_port\". \
4949
Servers defined will be created when process is started.")
5050

5151
(@arg BIND_ADDR: -b --("bind-addr") +takes_value {validator::validate_ip_addr} "Bind address, outbound socket will bind this address")
5252
(@arg SERVER_HOST: -s --("server-host") +takes_value "Host name or IP address of your remote server")
5353

54-
(@arg MANAGER_ADDRESS: --("manager-address") +takes_value {validator::validate_manager_addr} "ShadowSocks Manager (ssmgr) address, could be ip:port, domain:port or /path/to/unix.sock")
54+
(@arg MANAGER_ADDR: --("manager-addr") +takes_value alias("manager-address") {validator::validate_manager_addr} "ShadowSocks Manager (ssmgr) address, could be ip:port, domain:port or /path/to/unix.sock")
5555
(@arg ENCRYPT_METHOD: -m --("encrypt-method") +takes_value possible_values(available_ciphers()) "Default encryption method")
5656
(@arg TIMEOUT: --timeout +takes_value {validator::validate_u64} "Default timeout seconds for TCP relay")
5757

@@ -177,7 +177,7 @@ fn main() {
177177
config.outbound_bind_interface = Some(iface.to_owned());
178178
}
179179

180-
if let Some(m) = matches.value_of("MANAGER_ADDRESS") {
180+
if let Some(m) = matches.value_of("MANAGER_ADDR") {
181181
if let Some(ref mut manager_config) = config.manager {
182182
manager_config.addr = m.parse::<ManagerAddr>().expect("manager-address");
183183
} else {

bin/ssserver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn main() {
5555
(@arg PLUGIN: --plugin +takes_value requires[SERVER_ADDR] "SIP003 (https://shadowsocks.org/en/spec/Plugin.html) plugin")
5656
(@arg PLUGIN_OPT: --("plugin-opts") +takes_value requires[PLUGIN] "Set SIP003 plugin options")
5757

58-
(@arg MANAGER_ADDRESS: --("manager-address") +takes_value "ShadowSocks Manager (ssmgr) address, could be \"IP:Port\", \"Domain:Port\" or \"/path/to/unix.sock\"")
58+
(@arg MANAGER_ADDR: --("manager-addr") +takes_value alias("manager-address") "ShadowSocks Manager (ssmgr) address, could be \"IP:Port\", \"Domain:Port\" or \"/path/to/unix.sock\"")
5959

6060
(@arg ACL: --acl +takes_value "Path to ACL (Access Control List)")
6161
(@arg DNS: --dns +takes_value "DNS nameservers, formatted like [(tcp|udp)://]host[:port][,host[:port]]..., or unix:///path/to/dns, or predefined keys like \"google\", \"cloudflare\"")
@@ -218,7 +218,7 @@ fn main() {
218218
config.outbound_bind_interface = Some(iface.to_owned());
219219
}
220220

221-
if let Some(m) = matches.value_of("MANAGER_ADDRESS") {
221+
if let Some(m) = matches.value_of("MANAGER_ADDR") {
222222
config.manager = Some(ManagerConfig::new(m.parse::<ManagerAddr>().expect("manager address")));
223223
}
224224

crates/shadowsocks-service/src/manager/server.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::{collections::HashMap, io, net::SocketAddr, sync::Arc, time::Duration};
44

55
use futures::future::{self, AbortHandle};
6-
use log::{error, info};
6+
use log::{error, info, trace};
77
use shadowsocks::{
88
config::{Mode, ServerConfig, ServerType},
99
context::{Context, SharedContext},
@@ -131,6 +131,8 @@ impl Manager {
131131
}
132132
};
133133

134+
trace!("received {:?} from {:?}", req, peer_addr);
135+
134136
match req {
135137
ManagerRequest::Add(ref req) => match self.handle_add(req).await {
136138
Ok(rsp) => {

crates/shadowsocks/src/manager/protocol.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub trait ManagerProtocol: Sized {
1717
}
1818

1919
/// Server's configuration
20-
#[derive(Serialize, Deserialize, Debug)]
20+
#[derive(Serialize, Deserialize, Debug, Clone)]
2121
pub struct ServerConfig {
2222
pub server_port: u16,
2323
pub password: String,
@@ -64,6 +64,7 @@ impl ManagerProtocol for AddRequest {
6464
}
6565

6666
/// `add` response
67+
#[derive(Debug, Clone)]
6768
pub struct AddResponse(pub String);
6869

6970
impl ManagerProtocol for AddResponse {
@@ -79,7 +80,7 @@ impl ManagerProtocol for AddResponse {
7980
}
8081

8182
/// `remove` request
82-
#[derive(Serialize, Deserialize, Debug)]
83+
#[derive(Serialize, Deserialize, Debug, Clone)]
8384
pub struct RemoveRequest {
8485
pub server_port: u16,
8586
}
@@ -112,6 +113,7 @@ impl ManagerProtocol for RemoveRequest {
112113
}
113114

114115
/// `remove` response
116+
#[derive(Debug, Clone)]
115117
pub struct RemoveResponse(pub String);
116118

117119
impl ManagerProtocol for RemoveResponse {
@@ -127,6 +129,7 @@ impl ManagerProtocol for RemoveResponse {
127129
}
128130

129131
/// `list` request
132+
#[derive(Debug, Clone)]
130133
pub struct ListRequest;
131134

132135
impl ManagerProtocol for ListRequest {
@@ -145,7 +148,7 @@ impl ManagerProtocol for ListRequest {
145148
}
146149

147150
/// `list` response
148-
#[derive(Serialize, Deserialize, Debug)]
151+
#[derive(Serialize, Deserialize, Debug, Clone)]
149152
#[serde(transparent)]
150153
pub struct ListResponse {
151154
pub servers: Vec<ServerConfig>,
@@ -165,6 +168,7 @@ impl ManagerProtocol for ListResponse {
165168
}
166169

167170
/// `ping` request
171+
#[derive(Debug, Clone)]
168172
pub struct PingRequest;
169173

170174
impl ManagerProtocol for PingRequest {
@@ -183,7 +187,7 @@ impl ManagerProtocol for PingRequest {
183187
}
184188

185189
/// `ping` reponse
186-
#[derive(Serialize, Deserialize, Debug)]
190+
#[derive(Serialize, Deserialize, Debug, Clone)]
187191
#[serde(transparent)]
188192
pub struct PingResponse {
189193
pub stat: HashMap<u16, u64>,
@@ -217,7 +221,7 @@ impl ManagerProtocol for PingResponse {
217221
}
218222

219223
/// `stat` request
220-
#[derive(Serialize, Deserialize, Debug)]
224+
#[derive(Serialize, Deserialize, Debug, Clone)]
221225
#[serde(transparent)]
222226
pub struct StatRequest {
223227
pub stat: HashMap<u16, u64>,
@@ -251,6 +255,7 @@ impl ManagerProtocol for StatRequest {
251255
}
252256

253257
/// Server's error message
258+
#[derive(Debug, Clone)]
254259
pub struct ErrorResponse<E: ToString>(pub E);
255260

256261
impl<E: ToString> ManagerProtocol for ErrorResponse<E> {
@@ -266,6 +271,7 @@ impl<E: ToString> ManagerProtocol for ErrorResponse<E> {
266271
}
267272

268273
/// Collections of Manager's request
274+
#[derive(Debug, Clone)]
269275
pub enum ManagerRequest {
270276
Add(AddRequest),
271277
Remove(RemoveRequest),

0 commit comments

Comments
 (0)