Commit Graph

503 Commits

Author SHA1 Message Date
Andy Wang 6bd2e8fe1e Mitigation for https://github.com/cbeuw/Cloak-android/issues/13 2020-07-27 16:33:11 +01:00
notsure2 dab137dbd7 Support session per connection mode (like GoQuiet) when NumConn = 0. 2020-07-06 23:18:52 +02:00
Andy Wang 98a7b731f3 Do not fatal when accept fails after 10 times 2020-06-08 00:29:56 +01:00
Andy Wang 95ae83d54d Accept retry delay. Prevent #120 2020-06-07 20:06:52 +01:00
Andy Wang 2c995962ed Fix spelling mistake 2020-06-07 12:20:48 +01:00
Andy Wang ff10cbf67b Revert "Fix WriteTo receive loop"
This reverts commit 501f7dda

Address #117
2020-06-07 12:16:08 +01:00
Andy Wang 501f7dda97 Fix WriteTo receive loop 2020-05-27 13:41:34 +01:00
Andy Wang 128f653ea4 Fix duplicate UDP binding 2020-05-27 13:41:34 +01:00
Andy Wang 5984fde09f Better logging for user activation and termination 2020-05-27 13:41:34 +01:00
Andy Wang ae3f97df1e Rearrange if statement 2020-05-23 22:22:58 +01:00
Andy Wang 369f3c781c Fix UDP 2020-05-23 15:44:24 +01:00
Andy Wang 2682460d46 Give time dependent tests more leeway 2020-04-24 01:19:30 +01:00
Andy Wang 13c1c3705b Fix a race in test 2020-04-24 01:10:45 +01:00
Andy Wang b9c3e64750 Add tests 2020-04-24 01:06:35 +01:00
Andy Wang 72d67beea3 Make usageQueue update interval a constant 2020-04-24 01:06:22 +01:00
Andy Wang 2e945cc416 Fix a deadlock on terminating user 2020-04-24 01:05:37 +01:00
Andy Wang e508ade14b Fix test 2020-04-24 01:04:51 +01:00
Andy Wang acc0a1a2dd Fix credit not updating on termination 2020-04-24 00:56:54 +01:00
Andy Wang 6ae3c27320 Add tests and make SessionCap explicitly int32 2020-04-23 23:45:12 +01:00
Andy Wang 1c8903f249 Log repeat stream closing on Debug level 2020-04-20 23:54:41 +01:00
Andy Wang 5baac79e56 Avoid null ProxyBook map. Fixes #111 2020-04-18 16:03:18 +01:00
Andy Wang 69a73ecfc0 Refactor usermanager 2020-04-17 14:21:17 +01:00
Andy Wang d958de9938 Improve switchboard connscount 2020-04-17 01:04:26 +01:00
Andy Wang 70aa04354a Bounds check elimination 2020-04-17 01:03:36 +01:00
Andy Wang d2b17fc9a2 Fix a deadlock 2020-04-15 21:55:07 +01:00
Andy Wang 360f84c5d5 Improve tests 2020-04-14 14:14:51 +01:00
Andy Wang e202d8d03b Implement WriteTo and ReadFrom timeouts 2020-04-14 14:14:51 +01:00
Andy Wang 4a81683e44 Code cleanup and move stuff around 2020-04-14 14:14:51 +01:00
Andy Wang 53c0c6bafe Explicitly allow buf overlap in obfs 2020-04-13 22:48:28 +01:00
Andy Wang 97eb6aa096 Correct usages of b.SetBytes 2020-04-13 19:40:23 +01:00
Andy Wang e03080d3ba Lock stream sending in all cases 2020-04-13 16:39:19 +01:00
Andy Wang 3e6224d8e9 Protect buffer closing 2020-04-13 16:38:46 +01:00
Andy Wang 852f5f5e9f Alter integration tests 2020-04-13 15:17:59 +01:00
Andy Wang a8c584c242 Add tests 2020-04-13 15:17:19 +01:00
Andy Wang c22b0fb54f Fix test 2020-04-13 15:16:41 +01:00
Andy Wang 242fe28262 Use bool instead of atomic into to record closed status 2020-04-13 14:36:32 +01:00
Andy Wang c8368bcc7e Implement stream ReadFrom (flimsy) 2020-04-12 23:01:30 +01:00
Andy Wang 73544c03bb Update comment 2020-04-12 16:35:24 +01:00
Andy Wang 248389b3f6 Make WriteTo return the correct errors 2020-04-12 16:34:49 +01:00
Andy Wang f0e8b4556e Eliminate some bounds check 2020-04-12 16:10:48 +01:00
Andy Wang f05cc19dbc Assign connId only when needed 2020-04-12 12:51:00 +01:00
Andy Wang 14787a7057 Implement stream WriteTo 2020-04-12 12:43:24 +01:00
Andy Wang 334712c413 Regression: closing in the middle of a read will block 2020-04-12 12:28:00 +01:00
Andy Wang 4351815a4a fix stale code 2020-04-12 11:35:24 +01:00
Andy Wang a82a1a5627 writerTo 2020-04-12 11:34:04 +01:00
Andy Wang 21cbe6ab5d Implement WriterTo for receive buffers 2020-04-12 11:33:11 +01:00
Andy Wang 029da207ce Optimise datagramBuffer 2020-04-12 11:18:41 +01:00
Andy Wang f90a008271 Skip uploading nil update 2020-04-12 01:56:33 +01:00
Andy Wang 783d016a29 Fix a race on closing stream 2020-04-12 01:35:17 +01:00
Andy Wang 58e0797578 Synchronise stream.Write 2020-04-12 01:34:21 +01:00
Andy Wang 008fd8f0a3 Lazy allocation 2020-04-12 00:49:49 +01:00
Andy Wang 8a76afabf7 Reduce the amount of goroutines in tests 2020-04-11 23:09:51 +01:00
Andy Wang 17fd78b6c2 Use bbolt instead of bolt to fix go version compatibility issues 2020-04-11 23:09:29 +01:00
Andy Wang ce35a054ed Remove redundant tests 2020-04-11 22:43:29 +01:00
Andy Wang 5d4e8b8d8d Refactor udp piping and add tests 2020-04-11 22:37:15 +01:00
Andy Wang 9f413ff23a Fix multiconn benchmark 2020-04-11 19:03:44 +01:00
Andy Wang e4b45a55e3 Optimise AddRecordLayer 2020-04-10 19:09:17 +01:00
Andy Wang e9243a2e9f Framing in Stream.Write to prevent silent short write 2020-04-10 18:48:36 +01:00
Andy Wang 17d57d9369 Add benchmarks 2020-04-10 18:48:01 +01:00
Andy Wang 8c9bab2a6f TLSConn.Write returns correct length 2020-04-10 16:15:23 +01:00
Andy Wang 78b27c0705 Fix tests 2020-04-10 16:14:32 +01:00
Andy Wang a51d45f41a Avoid unnecessary pass by pointer 2020-04-10 16:09:05 +01:00
Andy Wang 2bf7df0eb0 Integration tests 2020-04-10 15:05:15 +01:00
Andy Wang 0f66fec28e Remove impossible error 2020-04-10 14:11:01 +01:00
Andy Wang 93cf6dec6e Export fields for testing 2020-04-10 14:09:48 +01:00
Andy Wang d53b80208f Refactor for easier testing 2020-04-10 11:07:38 +01:00
Andy Wang e5bda61587 Close connections properly 2020-04-09 23:52:08 +01:00
Andy Wang 254b7152b6 Fix tests 2020-04-09 22:21:02 +01:00
Andy Wang 444182f5bb Purge impurity 2020-04-09 22:11:12 +01:00
Andy Wang bbc0752883 Minor code cleanup 2020-04-09 19:10:04 +01:00
Andy Wang 86214a1df0 Implement stream SetReadDeadline 2020-04-09 18:56:17 +01:00
Andy Wang e41394c83c Set frame size limit through multiplexer 2020-04-09 16:37:46 +01:00
Andy Wang 780d607436 Use io.Copy for redir 2020-04-09 13:41:06 +01:00
Andy Wang 77c33ff352 Fix redir null pointer 2020-04-09 13:37:33 +01:00
Andy Wang 15f343db31 Refactor server configuration 2020-04-09 13:26:23 +01:00
Andy Wang 97858197cd Move common types to its own package 2020-04-09 00:39:40 +01:00
Andy Wang 86095ba5e6 Refactor out Dialer 2020-04-09 00:34:02 +01:00
Andy Wang 2400a33818 Remove extra imports 2020-04-08 22:17:08 +01:00
Andy Wang 7e9fe952aa Move code around for clarity 2020-04-08 22:07:11 +01:00
Andy Wang ec76ecfe71 Update tests 2020-04-08 21:47:31 +01:00
Andy Wang 693544659f Refactor server transport 2020-04-08 21:37:21 +01:00
Andy Wang 7bfae8accd Refactor client side transport (breaks server) 2020-04-08 20:53:09 +01:00
Andy Wang 96845700f8 Add some integration tests for multiplex 2020-04-08 18:26:57 +01:00
Andy Wang a461059b4a Change behaviour of stream.Write(nil) 2020-04-08 18:16:54 +01:00
Andy Wang d3bc3b5a13 Use connutil in test 2020-04-08 16:41:39 +01:00
Andy Wang dc2b1124cb move function out of util 2020-04-08 16:34:20 +01:00
Andy Wang db9b848053 Simplify ReadTLS 2020-04-08 16:31:55 +01:00
Andy Wang 43ae82ec0e Fix test, improve err message and fix nil interface casting 2020-04-08 15:58:46 +01:00
Andy Wang 3bc59ff4b6 Fix tests 2020-04-08 15:17:33 +01:00
Andy Wang 2dc7c6d6e1 Correct switchboard valve's scope 2020-04-08 15:15:08 +01:00
Andy Wang e52daf1a39 Set defaults properly 2020-04-08 15:13:49 +01:00
Andy Wang 545164a300 Make send/receive buffer sizes configurable 2020-04-08 15:07:35 +01:00
Andy Wang 1de5045003 Use errors from io 2020-04-08 14:59:09 +01:00
Andy Wang 01e5d15d20 Code cleanup 2020-04-08 12:18:20 +01:00
Andy Wang 963dae829d Fix tests 2020-04-07 21:19:40 +01:00
Andy Wang c1f3408c2c Make key lengths explicit 2020-04-07 21:15:28 +01:00
Andy Wang 443aeecf5f Use cbeuw/connutil for connection testing 2020-04-07 20:59:32 +01:00
Andy Wang e7963b9e24 Change wsAcceptor's name to wsOnceListener 2020-04-07 18:18:14 +01:00
Andy Wang 8d375e3f9b remove redundant fields 2020-04-06 20:51:21 +01:00
Andy Wang e8af6233c1 Fix test 2020-04-06 15:58:34 +01:00
Andy Wang 285b966326 Fix server reply certificate length 2020-04-06 15:55:22 +01:00
Andy Wang 6a83c58143 Refactor authentication pipeline 2020-04-06 15:24:18 +01:00
Andy Wang a161409577 Rename a struct 2020-04-06 14:29:38 +01:00
Andy Wang 903a413afc Update test 2020-04-06 13:14:11 +01:00
Andy Wang 25e41d0941 Allow UDP option to be set in both commandline and json 2020-04-06 13:11:19 +01:00
Andy Wang a163f066a6 Refactor client config 2020-04-06 13:07:16 +01:00
Andy Wang 402cfc9e25 Logging for silent connections 2020-04-05 01:15:45 +01:00
Andy Wang 8d84ebd145 Code styles 2020-04-05 00:56:43 +01:00
Andy Wang dc262f7ca5 actually change the connId of a stream upon new assignment in send 2020-04-05 00:52:06 +01:00
Andy Wang e9afae72f0 better stream closing error message 2020-04-05 00:51:28 +01:00
Andy Wang 6d75aaff01 fix return shadowing 2020-04-05 00:39:59 +01:00
Andy Wang e4da349aa0 Add websocket auth test 2020-04-04 16:11:02 +01:00
Andy Wang 5e1931a11c Ineffectual assignments 2020-04-04 16:10:43 +01:00
notsure2 2de034ec92 Make keepalive optional on client -> server and server -> proxy connections. Use KeepAlive value in config (seconds). 2020-04-04 15:32:19 +01:00
Andy Wang 2327420f75 Allow remote host to be set in the client config file 2020-04-04 00:43:06 +01:00
Andy Wang d05809f2a6 Fix logging of transport 2020-04-03 23:37:09 +01:00
Andy Wang 766c27a129 Refactor if to switch case 2020-04-03 22:46:07 +01:00
Andy Wang 75ab568cda Merge branch 'master' of https://github.com/cbeuw/Cloak 2020-04-03 22:44:39 +01:00
Andy Wang 85e95de69c variable cert length in TLS server response 2020-03-16 11:39:27 +00:00
Andy Wang e33afb258a extract util testing function 2020-03-16 11:38:30 +00:00
Andy Wang 47410dbb97 add comments 2020-03-15 23:56:45 +00:00
Andy Wang db8dd19c9d fix broken benchmarks 2020-03-15 23:55:56 +00:00
beans 23082aff4f Allow RemotePort to be optionally set in JSON. If it's not set in JSON, Cloak falls back to SS_REMOTE_PORT in SS mode, or the -p argument in standalone 2020-02-14 21:57:57 +00:00
Andy Wang 517a6d6e57 Handle error and retry for Crypto.rand 2020-02-01 23:46:46 +00:00
Andy Wang e714dc61a8 Add a test for server touchstone 2020-01-25 10:20:11 +00:00
Andy Wang bc5ce842a0 Refactor makeAuthenticationPayload to allow easier tests 2020-01-25 10:19:45 +00:00
Andy Wang abc39e4e90 Refactor authentication data representations 2020-01-24 16:44:29 +00:00
Andy Wang fa1c109d90 Make authentication info arrays 2020-01-24 15:13:26 +00:00
Andy Wang fe8b2d78ef Change authenticationInfo structure 2020-01-24 14:38:41 +00:00
Andy Wang 13b66f6fef Remove redundant code 2020-01-24 13:30:17 +00:00
Andy Wang f90ad52455 Add default stream timeout value to client 2020-01-23 20:31:08 +00:00
Andy Wang 6f34229aa0 Make and add stream upon reception of all new streamIDs even if they are closing 2020-01-23 20:30:31 +00:00
Andy Wang 39e54bae6c Fix transport null pointer 2020-01-22 22:27:19 +00:00
Andy Wang 99fa812594 Fix pickRandConn bad loop 2020-01-22 22:17:18 +00:00
Andy Wang 3f5fdae284 Close session immediately after receiving signal 2020-01-22 21:30:30 +00:00
Andy Wang d65aee725a Improve stream closing logic and add tests 2020-01-22 21:12:32 +00:00
Andy Wang af5c8a381f Make a test streamline instead of modular 2020-01-22 19:33:53 +00:00
Andy Wang 3d3d06ec96 Fix tests 2020-01-22 18:40:03 +00:00
Andy Wang 74a70a3113 Refactor Transport and add tests 2020-01-22 18:37:01 +00:00
Andy Wang e7e4cd5726 Refactor frame reception processor 2020-01-09 10:22:40 +00:00
Andy Wang 65553f4ec4 Remove redundant base64 decoding 2019-12-29 16:55:21 +00:00
Andy Wang e3552b2afc Refactor server config parser and add tests 2019-12-29 13:28:52 +00:00
notsure2 d35472aea1 Store stream in packet receive path instead of asynchronously to fix https://github.com/cbeuw/Cloak/issues/74 2019-12-14 12:48:45 +00:00
Andy Wang bdd5308169 Code style clean up 2019-11-08 17:06:20 +00:00
Andy Wang 9c30c9b5b5 Add explanations on accepting websocket connections 2019-11-08 16:56:31 +00:00
Andy Wang fbee919f47 Use constants for Closing value 2019-11-03 20:28:43 +00:00
Andy Wang c26be98e79 Use sync.Map in multiplex instead of manual locks 2019-11-03 12:22:12 +00:00
Andy Wang 9cab4670f4 Make buffer close non-blocking 2019-11-02 21:02:35 +00:00
Andy Wang 4c17923717 Make write error close session as well 2019-10-20 15:37:41 +01:00
Andy Wang e2b21dae9f Fix tests 2019-10-20 15:21:31 +01:00
Andy Wang 3649283a49 Fix tests 2019-10-20 15:18:27 +01:00
Andy Wang 57f0c3d20a Close session when one connection drops 2019-10-16 23:00:23 +01:00
Andy Wang 34a4805c34 Add tests 2019-10-16 23:00:11 +01:00
Andy Wang a1b719b15f Add terminal message 2019-10-15 22:24:33 +01:00
Andy Wang beb6568ce0 Check before passive close 2019-10-15 22:06:23 +01:00
Andy Wang 3b3cd277f8 Fix stream not closing 2019-10-15 22:06:11 +01:00
Andy Wang 67159abcf4 Add tests 2019-10-15 21:59:13 +01:00
Andy Wang 6580e38e44 Introduce a special Session closing frame 2019-10-14 15:34:14 +01:00
Andy Wang c9318dc90b Fix potential deadlocks 2019-10-08 23:11:16 +01:00
Andy Wang 96215f116a Fix #61 2019-09-22 10:44:16 +01:00
Andy Wang 8c477fb2b5 Default StreamTimeout to 300 seconds 2019-09-21 16:47:02 +01:00
Andy Wang 52720ca52f RedirAddr backward compatibility 2019-09-21 16:17:43 +01:00
Andy Wang eec295a00e Remove unnecessary pointer value 2019-09-15 21:33:35 +01:00
Andy Wang 8a6f6b6088 Minor error prompt and listen to :80 and :443 by default 2019-09-15 18:11:23 +01:00
Andy Wang 63f3b4a89f Allow server to listen on multiple ports 2019-09-15 15:29:29 +01:00
Andy Wang e2d4ab7376 Use non-pointer receiver instead 2019-09-02 14:04:52 +01:00
Andy Wang 98b77afb91 websocket over TLS 2019-09-02 14:03:10 +01:00
Andy Wang 854dc422a2 Update some comments 2019-09-01 23:14:28 +01:00
Andy Wang 339b324946 Working direct WebSocket transport 2019-09-01 20:23:45 +01:00
Andy Wang f47f57a59f Direct WebSocket 2019-09-01 01:33:34 +01:00
Andy Wang 3a28bb65d5 Refactor touchStone 2019-08-31 21:40:50 +01:00
Andy Wang a3c3c5dc07 Client side plain websocket 2019-08-31 18:01:39 +01:00
Andy Wang 75dc91c15c Fix wrong wait type 2019-08-31 15:33:23 +01:00
Andy Wang 4861efbc50 Fix #54 2019-08-31 15:32:57 +01:00
Andy Wang 31898dad63 Change the way user termination works 2019-08-30 22:14:45 +01:00
Andy Wang 9dacb9d8fd Handle closing frame properly in datagramBuffer 2019-08-30 21:00:15 +01:00
Andy Wang 3bfaa5c1c1 Receiving a closing frame no longer returns error on Write 2019-08-30 20:50:39 +01:00
Andy Wang 0bc48a5a2e Remove redundant err checking TODO 2019-08-30 20:45:06 +01:00
Andy Wang 3f532ae065 writeFrame returns error 2019-08-30 20:43:04 +01:00
Andy Wang a131af3439 Remove unnecessary Len check 2019-08-30 20:39:23 +01:00
Andy Wang cfa0a97edf Rename a test set 2019-08-30 17:07:08 +01:00
Andy Wang 59f2fe04e3 Use normal Read in ReadTLS instead of ReadFull 2019-08-30 14:38:31 +01:00
Andy Wang 4fb1f55e2d Use 64bit frame Seq to prevent nonce reuse 2019-08-27 15:06:28 +01:00
Andy Wang 2006e5971a Refactor frameSorter and datagramBuffer under one interface 2019-08-22 11:48:10 +01:00
Andy Wang c3ff3f5d1a Fix the weird nil pointer again 2019-08-21 13:14:23 +01:00
Andy Wang bbb0d35e80 Remove conns from map once switchboard.CloseAll is called 2019-08-20 23:15:36 +01:00
Andy Wang 8b99e419b3 Check buffer length for datagramBuffer.Read() in case the datagram is larger than the buffer 2019-08-20 22:50:58 +01:00
Andy Wang 46c02d17f4 Refactor InitState 2019-08-20 22:48:01 +01:00
Andy Wang 87a7684e10 More comments 2019-08-20 22:43:04 +01:00
Andy Wang dd4a1769d0 Refactor new session authorisation 2019-08-20 17:35:17 +01:00
Andy Wang eabe113547 Add Stream Timeout 2019-08-19 23:23:41 +01:00
Andy Wang ba467e8a32 Only store stream in map after Accept 2019-08-19 11:31:56 +01:00
Andy Wang c8184fc1d2 Switch back to juju/ratelimit 2019-08-17 11:23:26 +01:00
Andy Wang cf1f1ccf16 Add some tests 2019-08-17 00:59:30 +01:00
Andy Wang 57255fdeb2 Fail to parse ClientHello if the TLS record layer Content Type and versions are wrong 2019-08-17 00:35:28 +01:00
Andy Wang 0e0a3314c9 Add server TLS parse test 2019-08-17 00:32:03 +01:00
Andy Wang 812ca1af99 Unexport some client.State fields 2019-08-17 00:18:19 +01:00
Andy Wang b98a74f49b Refactor client ClientHello composition 2019-08-17 00:16:31 +01:00
Andy Wang b5c6d7fedc Change touchUp function signature 2019-08-16 23:56:46 +01:00
Andy Wang 52796ad0b1 recvDataFromRemote returns err 2019-08-16 23:47:15 +01:00