Commit Graph
36 Commits
Author SHA1 Message Date
Shun Sakai f57d50659f Change the return type of the main function
Since Rust 1.61.0, the `main` function can return a type that
implements the `Termination` trait.
By this, the `main` function can return custom exit codes, so use this.
2022-06-13 11:26:50 +08:00
John 12eadcdd39 remove deprecated code for clap 3.1.0 (#774) 2022-02-25 10:46:18 +08:00
zonyitoo 9ef0b31f91 upgrade clap to v3.0 2022-01-05 20:12:53 +08:00
zonyitoo 486e1d7279 Local, Server & Manager unified binary ssservice
- fixes #698
- Refactored shadowsocks-rust crate structure. Common code are put into
a separated library
2021-11-27 17:36:16 +08:00
zonyitoo 1eff9b1883 remove redundant clone and Into for RemoteDnsAddress 2021-11-26 00:43:05 +08:00
zonyitoo 1dc0c2a363 make clippy happy 2021-11-26 00:12:13 +08:00
zonyitoo 7aec233271 command line --password also support ${VAR_NAME} syntax
- use the original text instead of empty string if ${VAR_NAME} 's
VAR_NAME doesn't exist

ref #419
2021-11-25 23:54:23 +08:00
zonyitoo 11262f5f99 refactored command line options getter with clap::value_t! 2021-11-25 20:21:50 +08:00
zonyitoo 74e8a4f8f5 Reading password from environment variable or TTY
- servers creating from command line options would use TTY,
SS_SERVER_PASSWORD and SS_SERVER_${SERVER_ADDR}_PASSWORD environment
variables
- servers in configuration file "password" would allow ${VAR_NAME} to
read from environment variable VAR_NAME

fixes #419
2021-11-25 17:19:16 +08:00
zonyitoo fa3a2a83d2 default configuration file (config.json) for Windows, Linux, macOS
- $XDG_CONFIG_PATH/shadowsocks-rust/config.json
- $HOME/.config/shadowsocks-rust/config.json
- {FOLDERID_RoamingAppData}\shadowsocks\shadowsocks-rust\config\config.json
- $HOME/Library/Application Support/org.shadowsocks.shadowsocks-rust/config.json

fixes #688
2021-11-25 15:14:07 +08:00
zonyitoo da6473be09 servers created from command-line should have tcp_only default mode
fixes #670
2021-11-08 18:30:47 +08:00
Zimo LiandZimo Li 183b4bf0ca Fix spelling (#667)
* spelling: active

* spelling: availability

* spelling: because

* spelling: behavior

* spelling: browsers

* spelling: excessive

* spelling: extended

* spelling: insecure

* spelling: miscellaneous

* *spelling: negotiate

* spelling: particular

* spelling: readiness

* spelling: recommended

* spelling: response

* spelling: respectively

* spelling: reassemble

* spelling: Shadowsocks

* spelling: simultaneously

* spelling: silent

* spelling: stabilized

* spelling: unexpectedly

* *spelling: UNEXPECTEDLY

Co-authored-by: Zimo Li <lzm0@users.noreply.github.com>
2021-11-05 01:17:24 +08:00
zonyitoo e46d57936f support outbound-bind-interface for Windows 2021-10-23 17:32:15 +08:00
zonyitoo a9e2f372c4 support ssmanager server standalone mode
- fixes #648
- allow restarting ssmanager without killing all running ssservers
2021-10-15 19:02:18 +08:00
zonyitoo 0c96cf5840 log BUILD_TIME and bump version to v1.12.0-alpha.5 2021-09-25 23:20:33 +08:00
ty 337ab16adb Local server support Tun interface for both TCP and UDP (#586)
* [POC] basic implementation of TCP redirecting tun (#581)

* [POC] basic implementation of UDP redirection of Tun

* build with action

* add configuration interface for tun

* refine document and command line options

* outbound-bind-addr instead of reusing local_address for outbound sockets

* support customizing udp expiry and capacity

* make clippy happy

* fixed build error for Android

* add docs

* make a customized AsyncFd with the released tun crate

* TUN_INTERFACE_NAME to_owned directly

* ignore accept errors for tcp tun

* tun supports Android only on master branch

* android doesnt support setting IFF_NO_PI

* set route for macos automatically when creating tun

* set route for macos directly with PF_ROUTE

* Linux-like uses ETH_P_IP and ETH_P_IPV6

* use tun on crates.io and ignores Android support temporary

* update dependencies
2021-08-22 04:49:53 +08:00
zonyitoo 97bb489293 set Mode::UdpOnly via command line -u
- fixes #577
- Why the original code use merge instead of replace?
2021-07-21 12:48:06 +08:00
zonyitoo 5d232ca123 exit with code instead of panic! when loading config and ACL errors
- fixes #566
2021-07-10 02:33:30 +08:00
zonyitoo 420e4511d3 add manager debug strings 2021-06-13 08:14:31 +08:00
zonyitoo d61d1028a5 add tcp-keep-alive command line option
- ref #546
2021-06-07 03:17:44 +08:00
ty 4dfcc8e036 Manage UDP associations with LFU strategy (#506)
* manage UDP associations with LFU

- DNS associations could be evicted firstly then others like HTTP/3

* UDP redir caches inbound non-local socket

- Optimization: prevent creating new sockets for the same remotes

* updated libc to v0.2.94 for unified TCP options

* make clippy happy

* Pin lfu-cache to v1.2.1 for edward-shen/lfu-cache#2

* UDP target should cache with expiration 1hrs

* UDP tunnel test with an echo server

- CI crashes occasionally because of 8.8.8.8:53 doesn't respond
2021-04-28 01:27:33 +08:00
ty 8a27bb296c support TFO on Linux, FreeBSD, macOS and Windows (#487)
- ref #184
2021-04-25 23:31:13 +08:00
zonyitoo 50286dc9d9 free the memory of clap after parsing options
- --nofile is now only existed in *nix build except Android
2021-04-11 20:03:04 +08:00
zonyitoo 468207e0c1 support --udp-timeout and --udp-max-associations in ssmanager (#494)
- renamed --no-delay to --tcp-no-delay
2021-04-11 17:44:19 +08:00
zonyitoo 32640208fa release v1.10.1 2021-03-26 23:00:04 +08:00
zonyitoo 68d315ecd6 expose dns in command line options 2021-03-14 17:59:27 +08:00
zonyitoo 0ac0f15459 allow setting mode independently for every locals and servers
ref #452

- adding `mode` in `locals` and `servers` extended format`
redir and tunnel supports customizing UDP binding address by `udp_addr`

BREAKING CHANGES:

- `sslocal` and `ssserver` command line option `-u` and `-U` can only
  control mode of command line specified local or server instance`
2021-03-14 17:09:41 +08:00
zonyitoo 6bebb6c6c0 support multiple local servers in configuration file
ref #452

- support `locals` in configuration file, running multiple local server
  instance simultaneously
- support `unix://` in `dns` configuration

BREAKING CHANGE:

- `sslocal`'s `--dns-addr` is now only available in Android
- shadowsocks-service's `Config` struct have lots of changes
2021-03-14 17:09:41 +08:00
zonyitoo 39c8d5fb3c resolved OUTBOUND_BIND_INTERFACE duplication
ref shadowsocks/shadowsocks-android#2667
2021-02-08 09:33:53 +08:00
zonyitoo dd830c70ae allow customizing worker-threads for multi-threaded scheduler
fixes #379
2021-01-09 10:43:11 +08:00
zonyitoo 47169d6fc1 BREAKING: completely deprecated local-dns-relay and single-threaded features 2021-01-04 22:01:34 +08:00
zonyitoo 7bf6d320a7 uses multi-threaded to enable tokio's multi-thread runtime
- single-threaded is kept for compatible
2021-01-03 11:21:29 +08:00
zonyitoo c1bb097cfa Start single-threaded mode with command opt 2021-01-02 21:09:49 +08:00
zonyitoo ea03dc2122 fix typo of inbound-recv-buffer-size outbound-recv-buffer-size, ref #352 2020-12-28 19:12:42 +08:00
ty 303f96c61f Upgrade to tokio 1.0 (#358)
* upgrade to tokio v1.0

- removed tokio::prelude
- upgrade hyper to v0.14, tokio-rustls to v0.22

still working on migrating trust-dns-* and tokio-native-tls

ref #354

* tokio v1.0 removed with_poll

fix #355, ref #354

* removed CTRL-BREAK signal handler

ref #354

* fixes compliation error, add missing return

fixes #355

* allow setting SO_SNDBUF and SO_RCVBUF for sockets

ref #352

* completely removed unix socket based DNS resolving

ref shadowsocks/shadowsocks-android#2622

* fix build issue on Windows

* fixed uds poll_write loop, fixed udp outbound loopback check

ref #355

* disable default trust-dns resolver for andorid, macos, ios

This commit also:

- Optimized resolve() logging with elapsed time
- updated tokio-native-tls

* local-dns removed from default features

* fix rustc version with rust-toolchain

* Bump bytes from 0.6.0 to 1.0.0

* add dependabot badge

* indirectly depend on trust_dns_proto via trust_dns_resolver

* auto reconnect if udp sendto failed

* recreate proxied socket if recv() returns failure

* increase score precision to 0.0001

* example of log4rs configuration

* PingBalancer instance shouldn't kill probing task when dropping

- Probing task should be controlled by the internal shared state

* switch to trust-dns main for latest tokio 1.0 support
2020-12-28 10:10:19 +08:00
ty 07583f3cc8 Refactored and separate library into crates (#345)
* 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
2020-12-20 19:06:21 +08:00