Commit Graph

621 Commits

Author SHA1 Message Date
Micooz
9a6ea38777 test: move src/presets/__tests__/* to test/presets/ 2018-02-16 17:01:36 +08:00
Indexyz
d355ed9065 refactor: replace ctx with config
refactor: set static config for preset
2018-02-16 17:01:36 +08:00
Indexyz
d63f0bfddc refactor: replace object with config prototype 2018-02-16 17:01:36 +08:00
Indexyz
6ba9db3ab0 fix: remove commited function 2018-02-16 17:01:36 +08:00
Indexyz
59902609ae refactor(config): dynamic config 2018-02-16 17:01:36 +08:00
Indexyz
48c3a2d70e core,transports: remove global object 2018-02-16 17:01:36 +08:00
Micooz
6249092dd5 core/mux-relay: fix cannot read property 'remoteInfo' of null 2018-02-07 22:56:51 +08:00
Micooz
2ae6d9df80 core: remove Hub::onRelayClose() and Relay::getContext() 2018-02-06 22:50:53 +08:00
Micooz
7426a5d3ab presets/mux: prevent print non-ascii characters to log 2018-02-06 21:29:54 +08:00
Micooz
af5ae5036a core: refactor mux sub relay self-closing 2018-02-06 21:28:59 +08:00
Micooz
326eb29771 core,transports: improve log 2018-02-06 17:30:08 +08:00
Micooz
b2ec6ccaf9 core: refactor mux relay creation on client 2018-02-06 10:44:31 +08:00
Micooz
b785e20612 core,utils: move core/dns-cache.js to utils/, and refactor it 2018-02-05 14:23:26 +08:00
Micooz
b66e14d1cb core: fix sub connection id collision 2018-02-05 11:55:52 +08:00
Micooz
6d2ae7ef15 src/constants: set APP_ID randomly when application startsup 2018-02-04 22:34:31 +08:00
Micooz
80bb1ede28 presets/mux: change cid to a random and discrete structure 2018-02-04 22:33:01 +08:00
Micooz
12a21658b8 src: fix "send() is not a function" when enable mux feature though http proxy 2018-02-04 22:30:46 +08:00
Micooz
db56c0119a transports/mux: handle preset errors 2018-02-04 22:26:54 +08:00
Micooz
172b894ebc src: minor fix 2018-02-03 22:42:58 +08:00
Micooz
8d0fa29891 core: add mux-relay and refactor multiplexing 2018-02-03 21:38:47 +08:00
Micooz
1ec6cfca94 transports: use this.ctx 2018-02-03 21:36:33 +08:00
Micooz
456e5e6ce4 transports: add mux 2018-02-03 21:33:44 +08:00
Micooz
6c92d184e6 core: remove multiplexer.js 2018-02-02 21:44:44 +08:00
Micooz
be1efb80a0 core/hub: hook listening event 2018-01-27 11:47:22 +08:00
Micooz
50dd93526c core/multiplexer: log remaining number of sub connections when a sub connection closed 2018-01-20 23:31:02 +08:00
Micooz
a472e86ff8 core/transports: updatePresets() is now called via event emitter 2018-01-20 20:52:19 +08:00
Micooz
13465b7e60 core/relay: pass down DNSCache instance from relay to outbound 2018-01-20 20:50:02 +08:00
Micooz
f4e49f44d0 core: make injectMethodsToBounds() more explicit 2018-01-20 20:47:07 +08:00
Micooz
062c7e9823 transports/websocket: rename websocket.js to ws.js 2018-01-19 22:36:38 +08:00
Micooz
95c1db7e23 core/multiplexer: improve overall performance 2018-01-18 18:05:41 +08:00
Micooz
b801c73460 transports/tcp: add onDrain() 2018-01-18 18:03:50 +08:00
Micooz
d2cefa4756 presets/mux: check hostname and port of CMD_NEW_CONN frame 2018-01-18 18:03:01 +08:00
Micooz
e288d6fc40 utils/crypto: implement a faster version of randomBytes() 2018-01-18 18:02:11 +08:00
Micooz
95fc5cb208 src: extract several constants to constants.js 2018-01-18 18:00:56 +08:00
Micooz
54e73be92b core/multiplexer: randomly reuse mux connection even if we haven't exceed mux_concurrency 2018-01-15 23:34:27 +08:00
Micooz
5b9541bf21 core/relay: log request info on client side when enable mux feature 2018-01-15 22:30:34 +08:00
Micooz
3d1eaa360f core/multiplexer: overwrite outbound/inbound getters when enable mux feature 2018-01-15 20:30:07 +08:00
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