refine the protocol document

This commit is contained in:
Max Lv
2015-09-15 12:45:07 +08:00
parent 9e021aa919
commit 58e6dbd470
2 changed files with 18 additions and 7 deletions
-1
View File
@@ -144,7 +144,6 @@ typedef struct {
#define ONETIMEAUTH_KEYBYTES 32U
#define ONETIMEAUTH_FLAG 0x10
#define ONETIMEAUTH_MASK 0xF0
#define ADDRTYPE_MASK 0xF
#define CRC_BUF_LEN 128
+18 -6
View File
@@ -529,11 +529,23 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents)
/*
* Shadowsocks TCP Relay Protocol:
*
* +------+----------+----------+------+
* | ATYP | DST.ADDR | DST.PORT | AUTH |
* +------+----------+----------+------+
* | 1 | Variable | 2 | 16 |
* +------+----------+----------+------+
* +------+----------+----------+-----------------+
* | ATYP | DST.ADDR | DST.PORT | AUTH (Optional) |
* +------+----------+----------+-----------------+
* | 1 | Variable | 2 | 16 |
* +------+----------+----------+-----------------+
*
* If ATYP & ONETIMEAUTH_FLAG(0x10) == 1, AUTH and CRC are enabled.
*/
/*
* Shadowsocks TCP Request Payload CRC (Optional, no CRC for response's payload):
*
* +------+------+------+------+------+
* | DATA | CRC8 | DATA | CRC8 | ...
* +------+------+------+------+------+
* | 128 | 1 | 128 | 1 | ...
* +------+------+------+------+------+
*/
int offset = 0;
@@ -648,7 +660,7 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents)
offset += 2;
if (auth || (atyp & ONETIMEAUTH_MASK)) {
if (auth || (atyp & ONETIMEAUTH_FLAG)) {
if (ss_onetimeauth_verify(server->buf + offset, server->buf, offset)) {
LOGE("authentication error %d", atyp);
report_addr(server->fd);