mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-11-07 00:13:33 +00:00
* Refactored and separate library into crates
- shadowsocks: the core feature of shadowsocks
- shadowsocks-service: library for building shadowsocks services
- dns, http, redir, socks, tunnel
- load balancer
- shadowsocks-rust: release binaries
fix #347
* unified DnsResolver implementation
* unified local service common parameters into ServiceContext
- ServiceContext is common parameters shared between all local
implementations
- Completely removed https local support
* add #292 reply attack protection
* migrated redir local server
* support customizing outbound socket bind address
* manager outbound socket should accepts connect_opts
* republic local implementations
* socks5 udp server should always listen to client address
* socks4 controlled by local-socks4 feature
* socks4 also obey mode configuration
* socks server tcp cannot be disable. add support of udp-bind-addr parameter
* add udp-bind-addr for customizing udp-relay bind-addr
* local-dns infra, support customizing resolver
* fully implements DNS relay server
* support binding to specific interface on Linux-like platform
* tcp cannot be disabled in socks
* enable local-flow-stat
* fixed windows build
* fixed android specific warnings and compile errors
* allow udp_only mode in socks5
* dns relay listens to both TCP and UDP, mode controls outbound upstreams
* dns relay retries twice if request failed
* doc
* fix DnsClient typo
* fix stream EncryptWriter bug
* allow disable logging output
updated dependencies
* add readme
* refine doc
* remove depending on trust-dns-client
* socks4/4a client
* allow socks5 udp_only mode, fixes compile warning
* create standalone socks5 UDP relay server
- socks5 UDP association full cone (NAT2)
* server udp relay supports full cone (NAT2)
* acl moved to crate root
* redir udp relay support full cone (NAT2)
* standard socks5 udp test must use tcp_and_udp mode
* set server context fields with pub APIs
* udp_max_associations and udp_timeout default value set in Config
* local dns resolver retry with fixed attempts
* max_udp_association keeps unlimited by default
* fixed logging binary name
* pops first exited future result for local and server
* update reverse target index cache
* fix ProxyClientStreamWriteHalf that allows sending empty buffers
ref #232
* remove unused import when socks4 is disabled
* make balancer become a globally shared object
* print plugin exit status
* control local, server, manager services in features
49 lines
1.5 KiB
Rust
49 lines
1.5 KiB
Rust
//! Command line argument validator
|
|
|
|
#![allow(dead_code)]
|
|
|
|
use std::net::SocketAddr;
|
|
|
|
#[cfg(feature = "local-dns")]
|
|
use shadowsocks_service::config::NameServerAddr;
|
|
use shadowsocks_service::shadowsocks::{relay::socks5::Address, ManagerAddr, ServerAddr, ServerConfig};
|
|
|
|
macro_rules! validate_type {
|
|
($name:ident, $ty:ty, $help:expr) => {
|
|
pub fn $name(v: String) -> Result<(), String> {
|
|
match v.parse::<$ty>() {
|
|
Ok(..) => Ok(()),
|
|
Err(..) => Err($help.to_owned()),
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
validate_type!(
|
|
validate_server_addr,
|
|
ServerAddr,
|
|
"should be either ip:port or domain:port"
|
|
);
|
|
validate_type!(validate_socket_addr, SocketAddr, "should be ip:port");
|
|
validate_type!(validate_address, Address, "should be either ip:port or domain:port");
|
|
validate_type!(
|
|
validate_manager_addr,
|
|
ManagerAddr,
|
|
"should be either ip:port, domain:port or /path/to/unix.sock"
|
|
);
|
|
#[cfg(feature = "local-dns")]
|
|
validate_type!(
|
|
validate_name_server_addr,
|
|
NameServerAddr,
|
|
"should be either ip:port, domain:port or /path/to/unix.sock"
|
|
);
|
|
validate_type!(validate_u64, u64, "should be unsigned integer");
|
|
validate_type!(validate_u32, u32, "should be unsigned integer");
|
|
|
|
pub fn validate_server_url(v: String) -> Result<(), String> {
|
|
match ServerConfig::from_url(&v) {
|
|
Ok(..) => Ok(()),
|
|
Err(..) => Err("should be SIP002 (https://shadowsocks.org/en/spec/SIP002-URI-Scheme.html) format".to_owned()),
|
|
}
|
|
}
|