mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-02-09 01:59:16 +08:00
add manager debug strings
This commit is contained in:
@@ -43,7 +43,7 @@ fn main() {
|
||||
(@arg UDP_ONLY: -u conflicts_with[TCP_AND_UDP] "Server mode UDP_ONLY")
|
||||
(@arg TCP_AND_UDP: -U conflicts_with[UDP_ONLY] "Server mode TCP_AND_UDP")
|
||||
|
||||
(@arg CONFIG: -c --config +takes_value required_unless("MANAGER_ADDRESS")
|
||||
(@arg CONFIG: -c --config +takes_value required_unless("MANAGER_ADDR")
|
||||
"Shadowsocks configuration file (https://shadowsocks.org/en/config/quick-guide.html), \
|
||||
the only required fields are \"manager_address\" and \"manager_port\". \
|
||||
Servers defined will be created when process is started.")
|
||||
@@ -51,7 +51,7 @@ fn main() {
|
||||
(@arg BIND_ADDR: -b --("bind-addr") +takes_value {validator::validate_ip_addr} "Bind address, outbound socket will bind this address")
|
||||
(@arg SERVER_HOST: -s --("server-host") +takes_value "Host name or IP address of your remote server")
|
||||
|
||||
(@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")
|
||||
(@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")
|
||||
(@arg ENCRYPT_METHOD: -m --("encrypt-method") +takes_value possible_values(available_ciphers()) "Default encryption method")
|
||||
(@arg TIMEOUT: --timeout +takes_value {validator::validate_u64} "Default timeout seconds for TCP relay")
|
||||
|
||||
@@ -177,7 +177,7 @@ fn main() {
|
||||
config.outbound_bind_interface = Some(iface.to_owned());
|
||||
}
|
||||
|
||||
if let Some(m) = matches.value_of("MANAGER_ADDRESS") {
|
||||
if let Some(m) = matches.value_of("MANAGER_ADDR") {
|
||||
if let Some(ref mut manager_config) = config.manager {
|
||||
manager_config.addr = m.parse::<ManagerAddr>().expect("manager-address");
|
||||
} else {
|
||||
|
||||
@@ -55,7 +55,7 @@ fn main() {
|
||||
(@arg PLUGIN: --plugin +takes_value requires[SERVER_ADDR] "SIP003 (https://shadowsocks.org/en/spec/Plugin.html) plugin")
|
||||
(@arg PLUGIN_OPT: --("plugin-opts") +takes_value requires[PLUGIN] "Set SIP003 plugin options")
|
||||
|
||||
(@arg MANAGER_ADDRESS: --("manager-address") +takes_value "ShadowSocks Manager (ssmgr) address, could be \"IP:Port\", \"Domain:Port\" or \"/path/to/unix.sock\"")
|
||||
(@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\"")
|
||||
|
||||
(@arg ACL: --acl +takes_value "Path to ACL (Access Control List)")
|
||||
(@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() {
|
||||
config.outbound_bind_interface = Some(iface.to_owned());
|
||||
}
|
||||
|
||||
if let Some(m) = matches.value_of("MANAGER_ADDRESS") {
|
||||
if let Some(m) = matches.value_of("MANAGER_ADDR") {
|
||||
config.manager = Some(ManagerConfig::new(m.parse::<ManagerAddr>().expect("manager address")));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use std::{collections::HashMap, io, net::SocketAddr, sync::Arc, time::Duration};
|
||||
|
||||
use futures::future::{self, AbortHandle};
|
||||
use log::{error, info};
|
||||
use log::{error, info, trace};
|
||||
use shadowsocks::{
|
||||
config::{Mode, ServerConfig, ServerType},
|
||||
context::{Context, SharedContext},
|
||||
@@ -131,6 +131,8 @@ impl Manager {
|
||||
}
|
||||
};
|
||||
|
||||
trace!("received {:?} from {:?}", req, peer_addr);
|
||||
|
||||
match req {
|
||||
ManagerRequest::Add(ref req) => match self.handle_add(req).await {
|
||||
Ok(rsp) => {
|
||||
|
||||
@@ -17,7 +17,7 @@ pub trait ManagerProtocol: Sized {
|
||||
}
|
||||
|
||||
/// Server's configuration
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct ServerConfig {
|
||||
pub server_port: u16,
|
||||
pub password: String,
|
||||
@@ -64,6 +64,7 @@ impl ManagerProtocol for AddRequest {
|
||||
}
|
||||
|
||||
/// `add` response
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AddResponse(pub String);
|
||||
|
||||
impl ManagerProtocol for AddResponse {
|
||||
@@ -79,7 +80,7 @@ impl ManagerProtocol for AddResponse {
|
||||
}
|
||||
|
||||
/// `remove` request
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct RemoveRequest {
|
||||
pub server_port: u16,
|
||||
}
|
||||
@@ -112,6 +113,7 @@ impl ManagerProtocol for RemoveRequest {
|
||||
}
|
||||
|
||||
/// `remove` response
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RemoveResponse(pub String);
|
||||
|
||||
impl ManagerProtocol for RemoveResponse {
|
||||
@@ -127,6 +129,7 @@ impl ManagerProtocol for RemoveResponse {
|
||||
}
|
||||
|
||||
/// `list` request
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ListRequest;
|
||||
|
||||
impl ManagerProtocol for ListRequest {
|
||||
@@ -145,7 +148,7 @@ impl ManagerProtocol for ListRequest {
|
||||
}
|
||||
|
||||
/// `list` response
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[serde(transparent)]
|
||||
pub struct ListResponse {
|
||||
pub servers: Vec<ServerConfig>,
|
||||
@@ -165,6 +168,7 @@ impl ManagerProtocol for ListResponse {
|
||||
}
|
||||
|
||||
/// `ping` request
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PingRequest;
|
||||
|
||||
impl ManagerProtocol for PingRequest {
|
||||
@@ -183,7 +187,7 @@ impl ManagerProtocol for PingRequest {
|
||||
}
|
||||
|
||||
/// `ping` reponse
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[serde(transparent)]
|
||||
pub struct PingResponse {
|
||||
pub stat: HashMap<u16, u64>,
|
||||
@@ -217,7 +221,7 @@ impl ManagerProtocol for PingResponse {
|
||||
}
|
||||
|
||||
/// `stat` request
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[serde(transparent)]
|
||||
pub struct StatRequest {
|
||||
pub stat: HashMap<u16, u64>,
|
||||
@@ -251,6 +255,7 @@ impl ManagerProtocol for StatRequest {
|
||||
}
|
||||
|
||||
/// Server's error message
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ErrorResponse<E: ToString>(pub E);
|
||||
|
||||
impl<E: ToString> ManagerProtocol for ErrorResponse<E> {
|
||||
@@ -266,6 +271,7 @@ impl<E: ToString> ManagerProtocol for ErrorResponse<E> {
|
||||
}
|
||||
|
||||
/// Collections of Manager's request
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ManagerRequest {
|
||||
Add(AddRequest),
|
||||
Remove(RemoveRequest),
|
||||
|
||||
Reference in New Issue
Block a user