-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsocks.h
85 lines (66 loc) · 1.35 KB
/
socks.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
77
78
79
80
81
82
83
84
85
/*
SOCKS5 Client Library
Copyright (c) 2016 NuclearC
*/
#pragma once
#ifndef SOCKS_H_
#define SOCKS_H_
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <vector>
#include <chrono>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <fcntl.h>
// Need to link with Ws2_32.lib, Mswsock.lib, and Advapi32.lib
#pragma comment (lib, "Ws2_32.lib")
#pragma comment (lib, "Mswsock.lib")
#pragma comment (lib, "AdvApi32.lib")
namespace socks5cpp {
class SocksClient
{
public:
enum SocksState
{
Open,
Connecting,
Closed
};
struct SocksUrl
{
enum Type
{
WS,
WSS,
HTTP
};
Type type;
std::string ip;
unsigned int port;
uint8_t ipv4[4];
uint8_t ipv6[16];
};
private:
std::string ip;
std::string targetIP;
SocksUrl url;
SocksUrl targetUrl;
SocksState state;
public:
unsigned long long timeoutDuration = 20000; // 20 seconds
SocksClient(std::string _Ip, std::string _TargetIp);
~SocksClient();
SocksClient::SocksUrl scanURL(const std::string _url);
int connect(SOCKET& sfd);
int sendPacket(SOCKET& sfd, const char* _Buffer, const size_t _Size);
int recvPacket(SOCKET& sfd, char* _Buffer, const size_t _Size);
void destroy();
const SocksState& getState();
protected:
};
} // socks5cpp
#endif // SOCKS_H_