diff --git a/LICENSE b/LICENSE index 7c92c93c..879f6781 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014 Y. T. CHUNG +Copyright (c) 2017 Y. T. CHUNG Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.md b/README.md index 432e45d1..84dc3579 100644 --- a/README.md +++ b/README.md @@ -47,10 +47,7 @@ Create a ShadowSocks' configuration file. Example "local_port": 1080, "password": "mypassword", "timeout": 300, - "method": "aes-256-cfb", - - "local_http_port": 10240, - "local_http_address": "127.0.0.1" + "method": "aes-256-cfb" } ``` @@ -76,10 +73,7 @@ In shadowsocks-rust, we also have an extended configuration file format, which i } ], "local_port": 8388, - "local_address": "127.0.0.1", - - "local_http_port": 10240, - "local_http_address": "127.0.0.1" + "local_address": "127.0.0.1" } ``` @@ -94,6 +88,15 @@ cargo run --bin ssserver -- -c config.json List all available arguments with `-h`. +## Supported Ciphers + +* `aes-128-cfb`, `aes-256-cfb` +* `rc4`, `rc4-md5` +* `chacha20`, `salsa20` +* `dummy` (No encryption, just for debugging) +* `aes-128-gcm`, `aes-192-gcm`, `aes-256-gcm` +* `chacha20-ietf-poly1305` + ## Useful Tools 1. `ssurl` is for encoding and decoding ShadowSocks URLs. Example: `ss://YWVzLTI1Ni1jZmI6aGVsbG93b3JsZF9mdWNrQDEyNy4wLjAuMTo4Mzg4` diff --git a/examples/config_ext.json b/examples/config_ext.json index edd71158..14b7b415 100644 --- a/examples/config_ext.json +++ b/examples/config_ext.json @@ -18,7 +18,5 @@ "password": "password-svr3", "method": "rc4-md5" } - ], - "local_port": 1080, - "local_address": "127.0.0.1" + ] } diff --git a/src/bin/local.rs b/src/bin/local.rs index e23db1aa..402d23ee 100644 --- a/src/bin/local.rs +++ b/src/bin/local.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! This is a binary runing in the local environment //! //! You have to provide all needed configuration attributes via command line parameters, diff --git a/src/bin/server.rs b/src/bin/server.rs index 12347314..a93a4fa8 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! This is a binary running in the server environment //! //! You have to provide all needed configuration attributes via command line parameters, diff --git a/src/config.rs b/src/config.rs index b863380a..1ae2203b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! This is a mod for storing and parsing configuration //! //! According to shadowsocks' official documentation, the standard configuration diff --git a/src/crypto/aead.rs b/src/crypto/aead.rs index 0d627aae..f6369bf7 100644 --- a/src/crypto/aead.rs +++ b/src/crypto/aead.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! Aead Ciphers use crypto::cipher::{CipherType, CipherCategory, CipherResult}; diff --git a/src/crypto/cipher.rs b/src/crypto/cipher.rs index 95a64a4a..a3b96a56 100644 --- a/src/crypto/cipher.rs +++ b/src/crypto/cipher.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! Ciphers use std::str::{self, FromStr}; diff --git a/src/crypto/crypto.rs b/src/crypto/crypto.rs index 2942cce1..c1395952 100644 --- a/src/crypto/crypto.rs +++ b/src/crypto/crypto.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2015 Y. T. Chung - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! Cipher defined with Rust-Crypto use std::mem; diff --git a/src/crypto/digest.rs b/src/crypto/digest.rs index e3767b0c..40669cb3 100644 --- a/src/crypto/digest.rs +++ b/src/crypto/digest.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! Message digest algorithm use rust_crypto::md5::Md5; diff --git a/src/crypto/dummy.rs b/src/crypto/dummy.rs index 09654616..b39d792a 100644 --- a/src/crypto/dummy.rs +++ b/src/crypto/dummy.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! Dummy cipher, encrypt and decrypt nothing use super::{StreamCipher, CipherResult}; diff --git a/src/crypto/mod.rs b/src/crypto/mod.rs index 117b208a..203858c1 100644 --- a/src/crypto/mod.rs +++ b/src/crypto/mod.rs @@ -1,27 +1,5 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! Crypto methods for shadowsocks - use std::convert::From; use openssl::symm; diff --git a/src/crypto/openssl.rs b/src/crypto/openssl.rs index bb87be3b..eb0ced5d 100644 --- a/src/crypto/openssl.rs +++ b/src/crypto/openssl.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! Cipher defined with Rust binding for libcrypto (OpenSSL) use std::convert::From; diff --git a/src/crypto/rc4_md5.rs b/src/crypto/rc4_md5.rs index 24d2b1c6..273d40cc 100644 --- a/src/crypto/rc4_md5.rs +++ b/src/crypto/rc4_md5.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. Chung - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! Rc4Md5 cipher definition use crypto::openssl::OpenSSLCrypto; diff --git a/src/crypto/sodium.rs b/src/crypto/sodium.rs deleted file mode 100644 index 21789347..00000000 --- a/src/crypto/sodium.rs +++ /dev/null @@ -1,136 +0,0 @@ -// The MIT License (MIT) - -// Copyright (c) 2015 Y. T. Chung - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -//! Cipher defined with Rust binding for libsodium - -extern crate libc; - -use std::iter::repeat; - -use crypto::cipher::{Cipher, CipherType, CipherResult}; - -const BLOCK_SIZE: usize = 64; // Just for Salsa20 and Chacha20 - -mod ffi { - pub use libsodium_ffi::crypto_stream_chacha20_xor_ic; - pub use libsodium_ffi::crypto_stream_salsa20_xor_ic; -} - -pub struct SodiumCipher { - cipher_type: CipherType, - key: Vec, - iv: Vec, - counter: usize, - buf: Vec, -} - -impl SodiumCipher { - pub fn new(t: CipherType, key: &[u8], iv: &[u8]) -> SodiumCipher { - match t { - CipherType::Salsa20 | CipherType::ChaCha20 => (), - _ => panic!("Sodium does not support {:?} cipher", t), - } - - SodiumCipher { - cipher_type: t, - key: key.to_vec(), - iv: iv.to_vec(), - counter: 0, - buf: Vec::new(), - } - } -} - -impl Cipher for SodiumCipher { - fn update(&mut self, data: &[u8], out: &mut Vec) -> CipherResult<()> { - let padding_len = self.counter % BLOCK_SIZE; - let pad = - if padding_len == 0 { - None - } else { - let pad = repeat(0u8).take(padding_len).chain(data.iter().map(|&x| x)).collect::>(); - Some(pad) - }; - - let padded_data = match &pad { - &Some(ref p) => &p[..], - &None => data, - }; - - if self.buf.len() < padding_len + data.len() { - self.buf.resize(padding_len + data.len(), 0u8); - } - - match self.cipher_type { - CipherType::ChaCha20 => unsafe { - ffi::crypto_stream_chacha20_xor_ic(self.buf.as_mut_ptr() as *mut libc::c_char, padded_data.as_ptr(), - (padding_len + data.len()) as libc::c_ulonglong, - self.iv.as_ptr(), - (self.counter / BLOCK_SIZE) as libc::uint64_t, - self.key.as_ptr()); - }, - CipherType::Salsa20 => unsafe { - ffi::crypto_stream_salsa20_xor_ic(self.buf.as_mut_ptr() as *mut libc::c_char, padded_data.as_ptr(), - (padding_len + data.len()) as libc::c_ulonglong, - self.iv.as_ptr(), - (self.counter / BLOCK_SIZE) as libc::uint64_t, - self.key.as_ptr()); - }, - _ => unreachable!(), - } - - self.counter += data.len(); - - out.extend(&self.buf[padding_len..padding_len + data.len()]); - - Ok(()) - } - - fn finalize(&mut self, _: &mut Vec) -> CipherResult<()> { - Ok(()) - } -} - -#[cfg(test)] -mod test_sodium { - use crypto::cipher::{Cipher, CipherType}; - use crypto::sodium::SodiumCipher; - - #[test] - fn test_sodium_cipher() { - let ct = CipherType::ChaCha20; - - let key = ct.bytes_to_key(b"PassWORD"); - let message = b"message"; - - let iv = ct.gen_init_vec(); - - let mut enc = SodiumCipher::new(ct, &key[..], &iv[..]); - let mut encrypted_msg = Vec::new(); - enc.update(message, &mut encrypted_msg).unwrap(); - - let mut dec = SodiumCipher::new(ct, &key[..], &iv[..]); - let mut decrypted_msg = Vec::new(); - dec.update(&encrypted_msg[0..], &mut decrypted_msg).unwrap(); - - assert_eq!(message, &decrypted_msg[..]); - } -} diff --git a/src/crypto/stream.rs b/src/crypto/stream.rs index a2fc9a41..d5f1ed04 100644 --- a/src/crypto/stream.rs +++ b/src/crypto/stream.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! Stream ciphers use crypto::cipher::{CipherType, CipherCategory, CipherResult}; diff --git a/src/crypto/table.rs b/src/crypto/table.rs index 9910e30e..114bd6ed 100644 --- a/src/crypto/table.rs +++ b/src/crypto/table.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! This module implements the `table` cipher for fallback compatibility use std::io::BufReader; diff --git a/src/lib.rs b/src/lib.rs index 73d5998d..8fa8144a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! shadowsocks is a fast tunnel proxy that helps you bypass firewalls. //! //! Currently it supports SOCKS5 and HTTP Proxy protocol. diff --git a/src/relay/dns_resolver.rs b/src/relay/dns_resolver.rs index a2ee37ab..37bed9a2 100644 --- a/src/relay/dns_resolver.rs +++ b/src/relay/dns_resolver.rs @@ -1,23 +1,4 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +//! Asynchronous DNS resolver use std::io; diff --git a/src/relay/loadbalancing/mod.rs b/src/relay/loadbalancing/mod.rs index cab17d8f..8bddc9bd 100644 --- a/src/relay/loadbalancing/mod.rs +++ b/src/relay/loadbalancing/mod.rs @@ -1,23 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +//! Load balancer pub mod server; - diff --git a/src/relay/loadbalancing/server/mod.rs b/src/relay/loadbalancing/server/mod.rs index 8c45d9f1..3c925615 100644 --- a/src/relay/loadbalancing/server/mod.rs +++ b/src/relay/loadbalancing/server/mod.rs @@ -1,23 +1,4 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +//! Load balancer for picking servers use std::rc::Rc; diff --git a/src/relay/loadbalancing/server/roundrobin.rs b/src/relay/loadbalancing/server/roundrobin.rs index c5556c0e..9c195940 100644 --- a/src/relay/loadbalancing/server/roundrobin.rs +++ b/src/relay/loadbalancing/server/roundrobin.rs @@ -1,23 +1,4 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +//! Load balancer using round robin strategy use std::rc::Rc; diff --git a/src/relay/local.rs b/src/relay/local.rs index a185a3d2..80494a75 100644 --- a/src/relay/local.rs +++ b/src/relay/local.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! Local side use std::rc::Rc; diff --git a/src/relay/mod.rs b/src/relay/mod.rs index f1c3db37..627af669 100644 --- a/src/relay/mod.rs +++ b/src/relay/mod.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! Relay server in local and server side implementations. use std::io; diff --git a/src/relay/server.rs b/src/relay/server.rs index 254dddd6..069dac6b 100644 --- a/src/relay/server.rs +++ b/src/relay/server.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! Server side use std::rc::Rc; diff --git a/src/relay/socks5.rs b/src/relay/socks5.rs index 56d70195..7ee34afc 100644 --- a/src/relay/socks5.rs +++ b/src/relay/socks5.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! Socks5 protocol definition (RFC1928) //! //! Implements [SOCKS Protocol Version 5](https://www.ietf.org/rfc/rfc1928.txt) proxy protocol diff --git a/src/relay/tcprelay/client.rs b/src/relay/tcprelay/client.rs index 22c28c3e..c1d829e0 100644 --- a/src/relay/tcprelay/client.rs +++ b/src/relay/tcprelay/client.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! TCP relay client implementation use std::io::{self, Read, Write}; diff --git a/src/relay/tcprelay/local.rs b/src/relay/tcprelay/local.rs index 808d0d80..f6613a24 100644 --- a/src/relay/tcprelay/local.rs +++ b/src/relay/tcprelay/local.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! Relay for TCP server that running on local environment use std::rc::Rc; diff --git a/src/relay/tcprelay/mod.rs b/src/relay/tcprelay/mod.rs index 07479ff8..aebd9f26 100644 --- a/src/relay/tcprelay/mod.rs +++ b/src/relay/tcprelay/mod.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! Relay for TCP implementation use std::io::{self, Read, BufRead}; diff --git a/src/relay/tcprelay/server.rs b/src/relay/tcprelay/server.rs index 3e0f5c2d..8d5d7d17 100644 --- a/src/relay/tcprelay/server.rs +++ b/src/relay/tcprelay/server.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! Relay for TCP server that running on the server side use std::io; diff --git a/src/relay/tcprelay/socks5_local.rs b/src/relay/tcprelay/socks5_local.rs index a5714722..c380b712 100644 --- a/src/relay/tcprelay/socks5_local.rs +++ b/src/relay/tcprelay/socks5_local.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! Local server that accepts SOCKS 5 protocol use std::io; diff --git a/src/relay/tcprelay/stream.rs b/src/relay/tcprelay/stream.rs index cd0963f9..50354ab4 100644 --- a/src/relay/tcprelay/stream.rs +++ b/src/relay/tcprelay/stream.rs @@ -1,23 +1,4 @@ -// The MIT License (MIT) - -// Copyright (c) 2015 Y. T. Chung - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +//! Stream protocol implementation use std::io::{self, Read, BufRead, Write}; use std::cmp; diff --git a/src/relay/tcprelay/utils.rs b/src/relay/tcprelay/utils.rs index 5f2b27df..9af6648c 100644 --- a/src/relay/tcprelay/utils.rs +++ b/src/relay/tcprelay/utils.rs @@ -18,6 +18,7 @@ pub fn copy_timeout(r: R, w: W, dur: Duration, handle: Handle) -> CopyTime CopyTimeout::new(r, w, dur, handle) } +/// Copies all data from `r` to `w`, abort if timeout reaches pub struct CopyTimeout where R: Read, W: Write diff --git a/src/relay/udprelay/local.rs b/src/relay/udprelay/local.rs index 07fe1da5..ae219159 100644 --- a/src/relay/udprelay/local.rs +++ b/src/relay/udprelay/local.rs @@ -1,59 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -// SOCKS5 UDP Request -// +----+------+------+----------+----------+----------+ -// |RSV | FRAG | ATYP | DST.ADDR | DST.PORT | DATA | -// +----+------+------+----------+----------+----------+ -// | 2 | 1 | 1 | Variable | 2 | Variable | -// +----+------+------+----------+----------+----------+ - -// SOCKS5 UDP Response -// +----+------+------+----------+----------+----------+ -// |RSV | FRAG | ATYP | DST.ADDR | DST.PORT | DATA | -// +----+------+------+----------+----------+----------+ -// | 2 | 1 | 1 | Variable | 2 | Variable | -// +----+------+------+----------+----------+----------+ - -// shadowsocks UDP Request (before encrypted) -// +------+----------+----------+----------+ -// | ATYP | DST.ADDR | DST.PORT | DATA | -// +------+----------+----------+----------+ -// | 1 | Variable | 2 | Variable | -// +------+----------+----------+----------+ - -// shadowsocks UDP Response (before encrypted) -// +------+----------+----------+----------+ -// | ATYP | DST.ADDR | DST.PORT | DATA | -// +------+----------+----------+----------+ -// | 1 | Variable | 2 | Variable | -// +------+----------+----------+----------+ - -// shadowsocks UDP Request and Response (after encrypted) -// +-------+--------------+ -// | IV | PAYLOAD | -// +-------+--------------+ -// | Fixed | Variable | -// +-------+--------------+ - //! UDP relay local server use std::rc::Rc; diff --git a/src/relay/udprelay/mod.rs b/src/relay/udprelay/mod.rs index 17d94e20..a36952f5 100644 --- a/src/relay/udprelay/mod.rs +++ b/src/relay/udprelay/mod.rs @@ -1,25 +1,41 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! Relay for UDP implementation +//! +//! ## ShadowSocks UDP protocol +//! +//! SOCKS5 UDP Request +//! +----+------+------+----------+----------+----------+ +//! |RSV | FRAG | ATYP | DST.ADDR | DST.PORT | DATA | +//! +----+------+------+----------+----------+----------+ +//! | 2 | 1 | 1 | Variable | 2 | Variable | +//! +----+------+------+----------+----------+----------+ +//! +//! SOCKS5 UDP Response +//! +----+------+------+----------+----------+----------+ +//! |RSV | FRAG | ATYP | DST.ADDR | DST.PORT | DATA | +//! +----+------+------+----------+----------+----------+ +//! | 2 | 1 | 1 | Variable | 2 | Variable | +//! +----+------+------+----------+----------+----------+ +//! +//! shadowsocks UDP Request (before encrypted) +//! +------+----------+----------+----------+ +//! | ATYP | DST.ADDR | DST.PORT | DATA | +//! +------+----------+----------+----------+ +//! | 1 | Variable | 2 | Variable | +//! +------+----------+----------+----------+ +//! +//! shadowsocks UDP Response (before encrypted) +//! +------+----------+----------+----------+ +//! | ATYP | DST.ADDR | DST.PORT | DATA | +//! +------+----------+----------+----------+ +//! | 1 | Variable | 2 | Variable | +//! +------+----------+----------+----------+ +//! +//! shadowsocks UDP Request and Response (after encrypted) +//! +-------+--------------+ +//! | IV | PAYLOAD | +//! +-------+--------------+ +//! | Fixed | Variable | +//! +-------+--------------+ use std::io; diff --git a/src/relay/udprelay/server.rs b/src/relay/udprelay/server.rs index 5f56058f..0b8f90b9 100644 --- a/src/relay/udprelay/server.rs +++ b/src/relay/udprelay/server.rs @@ -1,24 +1,3 @@ -// The MIT License (MIT) - -// Copyright (c) 2014 Y. T. CHUNG - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - //! UDP relay proxy server use std::rc::Rc;