-
Notifications
You must be signed in to change notification settings - Fork 4
/
socks5.h
60 lines (49 loc) · 1.29 KB
/
socks5.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef S5_SOCKS5_H
#define S5_SOCKS5_H
#include <stdint.h>
#define SOCK_VER 0x05
#define S5_AUTH_NONE 0x00
#define S5_AUTH_USER_PASSWD 0x02
#define S5_AUTH_BAD 0xff
typedef struct s5_method_request {
uint8_t ver;
uint8_t nmethods; // always 1 in our case
uint8_t methods; // S5_AUTH_NONE or S5_AUTH_USER_PASSWD
} __attribute__((packed)) s5_method_request_t;
typedef struct s5_method_reply {
uint8_t ver;
uint8_t method;
} __attribute__((packed)) s5_method_reply_t;
#define CMD_CONNECT 0x01
#define CMD_BIND 0x02
#define CMD_UDP_ASSOC 0x03
#define ATYP_IP 0x01
#define ATYP_FQDN 0x03
#define ATYP_IP6 0x04
typedef struct s5_request_hdr {
uint8_t ver;
uint8_t cmd;
uint8_t rsv;
uint8_t atyp;
} __attribute__((packed)) s5_request_hdr_t;
#define REP_OK 0x00
#define REP_GENERAL 0x01
#define REP_DENY 0x02
#define REP_NET_UNREACH 0x03
#define REP_HOST_UNREACH 0x04
#define REP_CONN_REFUSED 0x05
#define REP_TTL_EXPIRED 0x06
#define REP_BAD_COMMAND 0x07
#define REP_BAD_ATYP 0x08
typedef struct s5_reply_hdr {
uint8_t ver;
uint8_t rep;
uint8_t rsv;
uint8_t atyp;
} __attribute__((packed)) s5_reply_hdr_t;
typedef struct s5_udp_payload_hdr {
uint16_t rsv;
uint8_t frag;
uint8_t atyp;
} __attribute__((packed)) s5_udp_payload_hdr_t;
#endif // S5_SOCKS5_H