Commit Graph

634 Commits

Author SHA1 Message Date
Micooz
441aee8f4c core/relay: add injectMethodsToBounds() convenience 2018-01-15 20:30:07 +08:00
Micooz
8b69a06d7c transports/tcp: access outbound/inbound via getters when onReceive() 2018-01-15 20:30:07 +08:00
Micooz
30b9ef509e transports/def: add outbound and inbound getters 2018-01-15 20:30:07 +08:00
Micooz
4a208d2b4f core/relay: add outbound and inbound getters 2018-01-15 20:30:07 +08:00
Micooz
fea32ea227 core/multiplexer: log the number of pending frames 2018-01-15 20:30:06 +08:00
Micooz
c6a1b94e8d test: fix ci 2018-01-15 20:26:52 +08:00
Micooz
02cbc8771c utils: fix getRandomInt() 2018-01-15 20:23:58 +08:00
Micooz
f51806b348 utils: remove generateMutexId() 2018-01-15 20:22:50 +08:00
Micooz
c54e1fc360 core,transports: refactor inbound and outbound closing logic 2017-12-26 21:39:21 +08:00
Micooz
3b5f50b5be core/multiplexer: better log 2017-12-26 16:00:42 +08:00
Micooz
298a65bb3c presets/mux: use strict length check 2017-12-26 16:00:18 +08:00
Micooz
24ec7b38f2 core: fix udp relay 2017-12-26 15:59:29 +08:00
Micooz Lee
80a6e69653
Add multiplexing support (#94)
* core,presets,transports: add initial mux support

* core,presets: holy shit

* core,transports: fix fix

* core: some fix to multiplexer

* still not working, too complex

* transports: add mux

* core: pass "extraArgs" as the second parameter during piping

* src: first working version of mux

* core,presets: properly close sub connection from client

* core/multiplexer: fix stuck at the second connection

* core/multiplexer: split class into MuxClient and MuxServer

* core/multiplexer: pick a random mux relay to transfer encoded data on server side

* core,transports: remove "mux" transport and make mux on TLS work

* presets/tracker: only dump result when preset destroyed

* lint: fix

* core: bring preparePresets() to module scope

* transports/tcp: fix inbound destroy behaviour for mux

* utils: fix getRandomInt()

* core/multiplexer: fix getRandomMuxRelay()

* core/multiplexer: distinguish relay self-close and protocol(mux)-close

* test: add test for "mux"

* transports/websocket: prevent calling "on()" on null this._socket

* presets: add class IPresetAddressing

* core: wrap mux protocol inside custom protocol stack

* core: pass remoteInfo to new Relay() to correct remote address in log

* core: fix bugs and improve stability

* src: add/remove TODOs

* core/relay: store remoteInfo rather than context

* core/relay: fix a bug

* docs: update
2017-12-25 16:42:01 +08:00
Micooz
cc758d3471
proxies/tcp: take host and port from func parameters 2017-12-19 11:25:08 +08:00
Micooz
733aa9e4b2
presets,test: remove base-auth-stream and base-with-padding 2017-12-19 11:24:21 +08:00
Micooz
078ca1530f
test: update 2017-12-19 11:23:32 +08:00
Micooz
27a1c748fe
bin,core: refactor config.js, remove "dstaddr" 2017-12-19 11:23:04 +08:00
Micooz
e7e607547d
transports/websocket: make data receive throttle work 2017-12-18 14:52:02 +08:00
Micooz
766d767a49
transports/websocket: optimize data send 2017-12-14 15:10:25 +08:00
Micooz
4ec33d2c85
transport: add missing brackets 2017-12-14 14:58:22 +08:00
Micooz
acb2174097
transports: make websocket extends from tcp 2017-12-14 14:46:37 +08:00
Micooz
a640a9598e
proxies/socks: fix crash when client reset the socks connection 2017-12-14 09:33:03 +08:00
Micooz
161b300af0
presets/ss-stream-cipher: add "none" method 2017-12-13 11:51:08 +08:00
Micooz
98a00424c2
transports/tcp: handle half-close correctly 2017-12-13 10:02:28 +08:00
Micooz
5c973a661c
core: refine relay creation 2017-12-13 10:01:45 +08:00
Micooz
46fded4d67
core: set connection id in _onConnection() 2017-11-28 14:03:47 +08:00
Micooz
c915e31248
core/hub: change _server to _tcpServer 2017-11-28 09:38:28 +08:00
Micooz
9fd276a565
core/hub: use Map to store relays 2017-11-28 09:38:28 +08:00
Micooz
25130c0489 core/hub: log worker id 2017-11-26 19:39:43 +08:00
Micooz
da6ac2d824 core: refactor createPreset() 2017-11-26 11:55:14 +08:00
Micooz
d91c725fbd presets/auto-conf: protocol changed 2017-11-25 12:44:00 +08:00
Micooz
10b6644770 core,transports: fix udp relay when use auto-conf 2017-11-25 11:50:13 +08:00
Micooz
1fa922b71d presets/auto-conf: refactor 2017-11-25 11:48:25 +08:00
Micooz
d129e6b56a
presets/auto-conf: refine payload of CHANGE_PRESET_SUITE action 2017-11-24 17:33:05 +08:00
Micooz
0b978668bf
presets/auto-conf: check if suites are loaded properly 2017-11-24 14:23:58 +08:00
Micooz
1bd4cf5276
presets: monkey patch onInit() and checkParams() 2017-11-24 14:22:37 +08:00
Micooz
fd17714e77
core: pre-init presets at startup 2017-11-24 14:21:34 +08:00
Micooz
beb84d4e2c
core: refine preset creation, remove reset() 2017-11-24 14:20:18 +08:00
Micooz
3cd3a6fafa
core: refine multi-server switch 2017-11-24 14:18:31 +08:00
Micooz
8558de98dc
presets: allow to load suites from remote 2017-11-24 13:04:13 +08:00
Micooz
45893d2736
core,utils: (new Date()).getTime() -> Date.now() 2017-11-24 10:59:55 +08:00
Micooz
979cb9caa2
core: prevent calling onReceive() on null inbound during udp relay 2017-11-22 10:47:56 +08:00
Micooz
61a9aae948
transports: fix RangeError [ERR_SOCKET_BAD_PORT] for udp 2017-11-22 10:46:31 +08:00
Micooz
32012c51e0
transports: just refine websocket 2017-11-22 10:43:18 +08:00
Micooz
46c65d5a72 transports: fix unexpected pause when CONNECT_TO_REMOTE has "true" keepAlive 2017-11-11 16:25:19 +08:00
Micooz
8f2688a87e
docs: add suites instructions 2017-11-10 10:49:46 +08:00
Micooz
c524837184 test: fix eslint 2017-11-09 22:19:28 +08:00
Micooz
5c29c34de0 presets: refactor and add udp support for "auto-conf" 2017-11-09 22:18:37 +08:00
Micooz
dc894496a2 presets: minor fix for tracker 2017-11-09 21:02:49 +08:00
Micooz
123fe73768 core: update preset suite doesn't recreate pipe now 2017-11-09 21:02:24 +08:00
Micooz
6424498fad
core: display a warning when provide redundant presets 2017-11-09 15:49:37 +08:00
Micooz
7956e3fded
presets: add auto-conf.js 2017-11-09 11:05:53 +08:00
Micooz
e3eefc88f4
transports: wait until connection established 2017-11-09 11:04:51 +08:00
Micooz
17399e4c0d
core: support dynamic change preset suite 2017-11-09 11:03:43 +08:00
Micooz
d1114b1c6f
core: always check preset parameters when create 2017-11-09 11:01:06 +08:00
Micooz
e2f817071e presets: fix hard coded "userKey" in ssr-auth-xxx 2017-11-07 21:59:33 +08:00
Micooz
2054b60430 presets: fix hard coded "userKey" in ssr-auth-xxx 2017-11-07 21:29:52 +08:00
Micooz
b09b4475cb
presets: apply padding strategy to "obfs-random-padding" to reduce bandwidth usage 2017-11-07 09:40:13 +08:00
Micooz
0a9fcce055
presets: fix eslint 2017-11-06 14:09:39 +08:00
Micooz
71abe6492a
presets: refactor obfs-http 2017-11-06 14:01:07 +08:00
Micooz
587ea3cac3 test: update 2017-11-04 22:00:38 +08:00
Micooz
1d33d04d84 presets: refactor and add "rc4-md5", "rc4-md5-6" to ss-stream-cipher 2017-11-04 17:24:41 +08:00
Micooz
4cdaddcbe7 core: give a warning when readProperty() from nonexistent preset 2017-11-04 17:23:58 +08:00
Micooz
da7697e181 presets: fixed a bug in random bytes length calculation 2017-11-03 23:33:13 +08:00
Micooz
a23cb24447 presets: fix unnecessary queue stuff in ssr-auth-chain 2017-11-03 23:29:28 +08:00
Micooz
3bb89f7a6f presets: fix overhead typo for ssr-auth-chain 2017-11-03 23:28:20 +08:00
Micooz
6ad41f8c43
presets: add "ssr-auth-chain-a" and "ssr-auth-chain-b" 2017-11-03 15:45:41 +08:00
Micooz
a4f98f09ce
core: destroy relay when inbound closed 2017-11-03 15:45:11 +08:00
Micooz
c324c56b58 presets: minor fix for ssr-auth-aes128 2017-11-02 21:40:10 +08:00
Micooz
0cef3d3a0b
presets: refine ssr-auth-aes128-xxx
- make ssr-auth-aes128 as base class
- explicit add ssr-auth-aes128-md5 and ssr-auth-aes128-sha1
2017-11-01 11:42:23 +08:00
Micooz
34575d6944 test: add test for dumpHex() 2017-10-31 22:52:53 +08:00
Micooz
1ac146668e presets: add ssr-auth-aes128.js 2017-10-31 22:50:06 +08:00
Micooz
2e1bc7748b utils: add dumpHex() 2017-10-31 22:46:53 +08:00
Micooz
a5a14e2913 presets: expose iv getter in ss-stream-cipher 2017-10-31 22:26:40 +08:00
Micooz
a013986b05 presets: expose headSize() interface in ss-base 2017-10-31 22:26:08 +08:00
Micooz
152ac034a5 core: implement readProperty() for IPreset 2017-10-30 22:18:20 +08:00
Micooz
557dff7506 presets: add getName() and readProperty() to IPreset 2017-10-30 22:15:56 +08:00
Micooz
6d378ae3fe transport: fix verbose log for udp transport 2017-10-28 15:34:02 +08:00
Micooz
17b5323cea core,presets: print transport type in tracker 2017-10-28 15:32:03 +08:00
Micooz
c4f423f77c
bin,core: apply lru-cache to udp relays 2017-10-27 12:45:27 +08:00
Micooz
cc0278d243 src: compatible with shadowsocks udp addessing 2017-10-26 22:28:47 +08:00
Micooz
68aa678925
presets: implement udp based protocols 2017-10-26 17:59:09 +08:00
Micooz
ea25df4cb1
transports: broadcast CONNECTION_CLOSED when udp packets fail to process 2017-10-26 16:46:19 +08:00
Micooz
0598950d91
core,test: support piping udp packets 2017-10-26 16:45:07 +08:00
Micooz
0b8ae8fe97
core: refine _onClose() and terminate() 2017-10-26 14:18:39 +08:00
Micooz
8f46dc6ef4
core: fix eslint 2017-10-26 14:14:54 +08:00
Micooz
9e3e00a79e
core: add udp support 2017-10-26 14:07:39 +08:00
Micooz
323a588953
proxies: handle socks5 udp associate properly 2017-10-26 14:06:21 +08:00
Micooz
bf37255bce
core,transports: add udp.js 2017-10-26 14:05:19 +08:00
Micooz
c9ce5fe3ae core: fix type of "port" parsed from url.parse() 2017-10-25 21:49:25 +08:00
Micooz
5aa1cfc755 src: refine api interfaces 2017-10-21 11:59:00 +08:00
Micooz
889b2bd6e6 src: refine api interfaces 2017-10-21 11:57:58 +08:00
Micooz
ff03246e31
core: fix lint error 2017-10-20 11:03:21 +08:00
Micooz
a81eea0401
presets: fix base-auth 2017-10-20 11:03:02 +08:00
Micooz
e0a51ab7e8
presets: deprecated base-auth-stream and base-with-padding, add base-auth 2017-10-20 10:56:03 +08:00
Micooz
2ad0b4fad0
core: move middleware creation from relay to pipe 2017-10-20 10:53:11 +08:00
Micooz
129b515167 presets: allow to use external preset 2017-10-19 21:32:40 +08:00
Micooz
39521ae8f8
transports: pause inbound receiving before outbound connected to remote 2017-10-19 15:23:33 +08:00
Micooz
d7883321f3
src: rename constants
- MIDDLEWARE_DIRECTION_UPWARD -> PIPE_ENCODE
- MIDDLEWARE_DIRECTION_DOWNWARD -> PIPE_DECODE
2017-10-19 11:19:32 +08:00
Micooz
434983d01f
transport: throttle receiving data to reduce memory grow when using websocket 2017-10-19 11:05:45 +08:00
Micooz
f1a555f050
presets: add CONNECTED_TO_REMOTE action 2017-10-19 11:04:23 +08:00
Micooz
5da3bac7d3
proxies: display error message when got invalid requests 2017-10-18 18:02:56 +08:00
Micooz
cd15044aa4
core: disable json output to log files 2017-10-18 13:54:31 +08:00
Micooz
95e6b1b842
presets: fix preset "ss-base" fail to process: invalid length: 0 2017-10-17 10:20:15 +08:00
Micooz
3501b877ab
test: add tests for v2ray-vmess.js, defs.js and middleware.js 2017-10-17 10:14:17 +08:00
Micooz
5b3e1518d4
core: throw an error rather than process.exit() when createMiddlware() 2017-10-17 10:13:31 +08:00
Micooz
6f12dcb2ba transport: fix a null pointer bug in tcp.js 2017-10-15 12:19:51 +08:00
Micooz
34acc66a1d presets: add chacha20-poly1305 security support for v2ray-vmess 2017-10-15 12:17:42 +08:00
Micooz
0c297c9a92 core: catch errors throw from presets at pipe() 2017-10-15 12:14:56 +08:00
Micooz
ba16b706d1 presets: add chacha20-* support for ss-aead-cipher
- chacha20-poly1305
- chacha20-ietf-poly1305
- xchacha20-ietf-poly1305
2017-10-14 22:55:13 +08:00
Micooz
801dd69867 transports: log host and resolved ip separately 2017-10-14 22:51:43 +08:00
Micooz
8c87a360d5 proxies: unify host type in socks.js 2017-10-14 22:50:36 +08:00
Micooz
daf9ba8927 proxies: add tcp.js 2017-10-14 22:48:06 +08:00
Micooz
6200a9ce9a core: add "dstaddr" option to config.js 2017-10-14 22:47:09 +08:00
Micooz
42c7ea8ec2 core: refine hub, pass proxyRequest to relay 2017-10-14 22:45:47 +08:00
Micooz
d26b63f59a presets: remove tunnel 2017-10-14 22:28:06 +08:00
Micooz
a816d60968 presets: remove exp-compress 2017-10-14 19:23:28 +08:00
Micooz
1b17e08288 presets: refine ss-aead-cipher and ss-stream-cipher 2017-10-14 12:26:25 +08:00
Micooz
8294d87bf8
core,test: support "service" option in config 2017-10-13 16:56:49 +08:00
Micooz
92c20bf61c
presets: only watch file in non-test environment 2017-10-13 16:23:28 +08:00
Micooz
d47f7b1337
core: universal service start of hub 2017-10-13 15:51:13 +08:00
Micooz
4459b44e84
bin,src: refine module exports 2017-10-13 15:48:09 +08:00
Micooz
d20443bfc7
transports: change "websocket" to "ws" 2017-10-13 15:43:25 +08:00
Micooz
30288a51f5
transport: destroy socket when "end" as well 2017-10-13 15:42:47 +08:00
Micooz
116c1ff9de
utils: remove problematic parseURI() 2017-10-13 15:41:10 +08:00
Micooz
414bfb86d5
core,presets: remove proxy preset 2017-10-13 15:39:28 +08:00
Micooz
f206be69e3
proxies: a big refactor, use more robust, lightweight and efficient approach 2017-10-13 15:37:42 +08:00
Micooz
53c6681084
transports: check websocket writable before send 2017-10-09 12:56:43 +08:00
Micooz
d73d9fcf44 core: refactor pipe, add pre-hook, improve pipe performance 2017-10-08 11:30:05 +08:00
Micooz
ef8ff9aa48 utils: add generateMutexId() 2017-10-08 11:21:19 +08:00
Micooz
21f4a33c4b core: print logs when load cert.pem or key.pem 2017-10-07 17:02:12 +08:00
Micooz
55d18e7199 core: drop Object.values to fix compatibility for node v6.x 2017-10-07 16:59:01 +08:00
Micooz
835ade4750 core: normalize log output of hub.js 2017-10-07 15:40:45 +08:00
Micooz
373feea909
transports: sync return context when _connect() 2017-09-28 14:27:10 +08:00
Micooz
09dc24da9e
transports: extract tls relevant logic from tcp.js to tls.js 2017-09-27 10:50:57 +08:00
Micooz
1d676a04a1
transports: refine index.js 2017-09-26 11:09:39 +08:00
Micooz
68a595c426
core,bin: add "log_max_days" option 2017-09-26 11:08:55 +08:00
Micooz
708926c72f
core: should clear cache after switch to another server 2017-09-21 12:48:29 +08:00
Micooz
8e72dec75c
presets: fix access bug to static members 2017-09-20 14:22:26 +08:00
Micooz
260c89dda6
presets: two presets are ready for production
exp-base-auth-stream -> base-auth-stream
exp-base-with-padding -> base-with-padding
2017-09-20 13:33:42 +08:00
Micooz
793835d570
presets: refactor exp-compress, expose "threshold" and "options" 2017-09-20 11:48:01 +08:00
Micooz
17e621237f presets: typo 2017-09-19 22:29:49 +08:00
Micooz
3884f4d07c
core,transports: refactor tcp/tls relay, add websocket 2017-09-19 14:07:07 +08:00
Micooz
6d93761f09
presets/tracker: extract dump() method to global static function 2017-09-19 14:05:49 +08:00
Micooz
596c51db3d
core,test: deprecated __IS_TLS__ 2017-09-19 14:04:40 +08:00
Micooz
8436de0124 presets: fix "out of range" bug in v2ray-vmess 2017-09-18 22:52:01 +08:00
Micooz
464cf4e95c core: add _destroy property to pipe 2017-09-18 22:42:46 +08:00
Micooz
2581da27c9 core: print a verbose log when hit cache 2017-09-18 22:41:56 +08:00
Micooz
6cf69805e7
utils: fixed a performance regression of advanced-buffer 2017-09-14 17:21:47 +08:00
Micooz
eae044bade
presets: minor fixes 2017-09-14 13:43:41 +08:00
Micooz
b2778b0785
test: prepare e2e tests for presets 2017-09-13 17:02:24 +08:00
Micooz
b4758e73ed
utils: add missing unit tests 2017-09-13 16:11:06 +08:00
Micooz
03e33a2b6b
utils: refactor shake128() 2017-09-13 15:10:31 +08:00
Micooz
e10ae03f74
presets: add v2ray-vmess support 2017-09-13 15:02:02 +08:00
Micooz
ceeb47d945 presets: adapt utils 2017-09-12 22:23:01 +08:00
Micooz
14b1b02412 utils: more robust 2017-09-12 22:23:01 +08:00
Micooz
01e42411fb utils: split common into several modules 2017-09-12 22:23:01 +08:00
Micooz
15169212b8 core: fix typo in action-handler.js 2017-09-12 22:23:01 +08:00
Micooz
8848d603a2 core: refactor terminate() of hub 2017-09-12 22:23:01 +08:00
Micooz
91a94f3255
core: refine timeout event callback 2017-09-11 14:40:05 +08:00
Micooz
d7e348b592
presets: improve performance and reduce memory usage 2017-09-08 10:47:36 +08:00
Micooz
ca548603b7
core: refactor middleware, improve cache strategy 2017-09-08 10:44:15 +08:00
Micooz
c52ebbae9b
core,presets: remove PRESET_INIT, add static onInit() to IPreset 2017-09-08 10:41:25 +08:00
Micooz
4db9bbb3b9
utils: add clear() for AdvancedBuffer 2017-09-08 10:38:45 +08:00
Micooz
8e8591840d
core,presets: add a new interface next() to IPreset 2017-09-07 17:11:37 +08:00
Micooz
47e992d03b
presets: adjust presets order 2017-09-05 17:55:37 +08:00
Micooz
730db0f29f
core: remove unnessarty check and bring "redirect" back 2017-09-05 14:36:11 +08:00
Micooz
d938eda05b
core: extract onPipeNotified() from relay.hs to action-handler.js 2017-09-05 14:35:19 +08:00
Micooz
17d1e02abb
presets: add access-control.js 2017-09-05 14:34:19 +08:00
Micooz
94be72599b
docs,bin,src: remove behaviours 2017-09-05 14:32:40 +08:00
Micooz
d86b8220f6
utils: fix isValidPort() 2017-09-05 09:52:43 +08:00
Micooz
07a28346bc
core,presets: add 4 actions for traffic control 2017-09-05 09:52:18 +08:00
Micooz
2fd99f6303 presets: check data length after verify for two aead ciphers 2017-09-03 17:16:18 +08:00
Micooz
53577c2fda core: implement PRESET_CLOSE_CONNECTION in relay 2017-09-03 12:23:17 +08:00
Micooz
f921ce9415 core: ignore action emitter itself when broadcast 2017-09-03 12:22:25 +08:00
Micooz
d904b287aa presets: add convenience methods this.broadcast(...) and this.fail(...) 2017-09-02 22:09:51 +08:00
Micooz
a3cab733bd core: refactor pipe.js 2017-09-02 21:31:27 +08:00
Micooz
93ab9d0390 core: refactor middleware.js 2017-09-02 21:30:18 +08:00
Micooz
f439713f17 presets: export modules from defs.js 2017-09-02 11:24:34 +08:00
Micooz
2fc59687b1 utils: fix a type check bug in isValidPort() 2017-09-02 11:23:13 +08:00
Micooz
fff076711f
*: fix mode 2017-08-31 18:01:28 +08:00
Micooz
2a3e645f14
presets: refactor stats.js using IPresetStatic 2017-08-31 15:57:57 +08:00
Micooz
eafa5e9aff
presets: refine parameters check 2017-08-31 15:31:44 +08:00
Micooz
bae4be4452
core,test: refine config.js 2017-08-31 14:53:45 +08:00
Micooz
8850fd0850
presets: add static method checkParams() to IPreset 2017-08-31 14:42:10 +08:00
Micooz
5764a4f2cc
presets,core: add IPresetStatic class, remove checkMiddleware() 2017-08-31 14:41:11 +08:00
Micooz
f88e107f37
presets: change SOCKET_CONNECT_TO_REMOTE to CONNECT_TO_REMOTE 2017-08-31 13:01:34 +08:00
Micooz
b8bbf239ac
core: refactor "drain" event 2017-08-30 16:30:19 +08:00
Micooz
0c4aa5aeea
core,presets: replace PROCESSING_FAILED to PRESET_FAILED 2017-08-30 15:07:06 +08:00
Micooz
85342b7dd9
core,presets: add onDestroy() hook for presets 2017-08-30 14:25:56 +08:00
Micooz
49536e9814
presets: fix obfs-random-padding 2017-08-29 12:50:21 +08:00
Micooz
e4043ea1b2
utils: fix getRandomInt() 2017-08-29 11:35:54 +08:00
Micooz
14484038e6
docs: update presets 2017-08-29 11:06:22 +08:00
Micooz
a4b5ab0c05
presets: re-implement obfs-random-padding 2017-08-29 10:57:31 +08:00
Micooz
d974c2b4d1
utils: improve performance of advanced-buffer 2017-08-29 10:50:32 +08:00
Micooz
654b2f9a39 presets: add obfs-random-padding.js 2017-08-28 22:41:45 +08:00
Micooz
e9eca38110 presets: dump details when fail 2017-08-28 22:41:25 +08:00
Micooz
5f85be4b75 core: fix calling close() on null in hub.js 2017-08-28 22:40:30 +08:00
Micooz
ef704a692c presets: refine stats.js 2017-08-28 19:50:56 +08:00
Micooz
f68ee79319 ci: fix zlib constants for Node.js v6.x 2017-08-28 19:37:52 +08:00