-
Notifications
You must be signed in to change notification settings - Fork 8
/
socks5.h
76 lines (65 loc) · 1.27 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// socks5.h
//
// Created by 吴怡生 on 12/03/2018.
// Copyright © 2018 yeshen.org. All rights reserved.
//
#ifndef SOCKS5_H
#define SOCKS5_H
#include <inttypes.h>
#include "common.h"
#define ACCEPT_VERSION '\x05'
#define NO_AUTHON '\x00'
#define AUTHON '\x02'
enum SectionStatus{
SS_INIT = 0,
SS_REQUEST = 1,
SS_REDY = 2,
SS_CLOSE = 3
};
struct UDPPair{
int in_fd;
int out_fd;
UDPPair *next;
};
struct Section{
int fd;
bool tcp;
SectionStatus status;
int watch_fd;
UDPPair *udp;
struct LinkBuff* insidebuff;
struct LinkBuff* outsidebuff;
};
struct RequestVersion{
uint8_t VER;
uint8_t NMETHODS;
uint8_t METHODS;
};
struct ReplytVersion{
uint8_t VER;
uint8_t METHOD;
};
struct Request{
uint8_t VER;
uint8_t CMD;
uint8_t RSV;
uint8_t ATYP;
char* DST_ADDR;
uint16_t DST_PORT;
};
struct Replies{
uint8_t VER;
uint8_t REP;
uint8_t RSV;
uint8_t ATYP;
char* BND_ADDR;
uint16_t BND_PORT;
};
namespace Socks5{
bool decodeRequestVersion(struct RequestVersion* version,struct LinkBuff* buf);
bool decodeRequest(struct Request* version,struct LinkBuff* buf);
uint8_t* createReplytVersion();
uint8_t* createReplies(uint8_t rep);
};
#endif