-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathclient.h
77 lines (48 loc) · 1.51 KB
/
client.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
//
// Created by Li on 2020/4/1.
//
#ifndef SBPROXY_CLIENT_H
#define SBPROXY_CLIENT_H
#include <iostream>
#include "lib/base64/base64.h"
#ifdef _WIN32
#include "event2/event.h"
#include "event2/bufferevent.h"
#include "event2/buffer.h"
#include "event2/listener.h"
#else
#include <event2/event.h>
#include <event2/bufferevent.h>
#include <event2/buffer.h>
#include <event2/listener.h>
#endif
#ifdef _WIN32
#include <WinSock2.h>
#pragma comment(lib, "ws2_32.lib")
#else
#include <signal.h>
#endif
#include "spdlog/spdlog.h"
using std::string;
class client {
public:
static void setConfig(const char *ip, unsigned short local_port, unsigned short remote_port, string password);
public:
static void local_event_cb(bufferevent *bev, short what, void *ctx);
static void local_read_cb(bufferevent *bev, void *arg);
// void local_write_cb(bufferevent *bev, void *arg);
static void remote_event_cb(bufferevent *bev, short what, void *ctx);
static void remote_read_cb(bufferevent *bev, void *arg);
// void remote_write_cb(bufferevent *bev, void *arg);
static void close_on_finished_write_cb(struct bufferevent *bev, void *ctx);
static void listen_cb(evconnlistener *ev, evutil_socket_t s, sockaddr *sin, int sin_len, void *arg);
static void init();
static void clear();
public:
static event_base *base_loop;
static const char *ip;
static unsigned short local_port;
static unsigned short remote_port;
static unsigned char password[256];
};
#endif //SBPROXY_CLIENT_H