-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproxy.h
More file actions
142 lines (98 loc) · 2.9 KB
/
proxy.h
File metadata and controls
142 lines (98 loc) · 2.9 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#ifndef PROXY_H
#define PROXY_H
#include <stdbool.h>
#include <stdio.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <memory.h>
#include <netdb.h>
#include <pthread.h>
#include <regex.h>
#include <unistd.h>
#include "log.h"
#include "sblist.h"
#include "configs.h"
#define SIMPLE_GET_REQUEST_BUFFER_SIZE 1024
union sockaddr_union
{
struct sockaddr_in v4;
struct sockaddr_in6 v6;
};
enum proxy_type
{
Http,
Socks4,
Socks5
};
static const char *proxy_type_str[] =
{
"Http",
"Socks4",
"Socks5"
};
enum anonimity_level
{
Transparent,
Low,
Medium,
High
};
static const char *anonimity_level_str[] =
{
"Transparent",
"Low",
"Medium",
"High"
};
typedef struct proxy_client
{
union sockaddr_union socks_addr;
uint32_t dest_addr;
uint16_t dest_port;
int fd;
} proxy_client_t;
typedef struct
{
char ip[16];
uint16_t port;
} proxy_t;
typedef struct
{
proxy_client_t client;
proxy_t *proxy;
char *output_file;
enum proxy_type proxy_type;
pthread_t pt;
int done;
}proxy_thread_t;
static char simple_request[] = "GET /get HTTP/1.1\r\n"
"Host: "DEST_HOST"\r\n"
"Connection: close\r\n\r\n";
static struct hostent *dest_host = NULL;
static uint32_t dest_host_addr;
static char dest_host_buffer[16];
void checking_from_list(sblist *proxy_list, char *output_filename_proxy,
proxy_thread_t *threads, size_t worker_max,
enum proxy_type type);
void checking_from_range(uint32_t proxy_addr, uint16_t *ports, size_t ports_count,
char *output_filename_proxy,proxy_thread_t *threads,
size_t worker_max, enum proxy_type type);
void create_proxy_checker(proxy_thread_t *t);
void set_timeout(int sock_fd, uint16_t sec);
void dest_addr_init(proxy_client_t *c);
int proxy_client_connect(proxy_client_t *client,uint16_t timeout, proxy_t *proxy);
proxy_thread_t *get_free_thread(proxy_thread_t *t, size_t size);
size_t get_worked_threads_count(proxy_thread_t *t, size_t size);
int load_range_status(char *filename, uint32_t *range_start, uint32_t *range_end);
void save_range_status(char *filename, uint32_t range_start, uint32_t range_end);
sblist *load_proxy(const char *filename);
void save_proxy(proxy_t *p,char *filename,enum proxy_type type,enum anonimity_level lvl);
char *get_global_ip();
void decimal_to_ip(char *dest_buf, uint32_t src_addr);
char *simple_get_request(int fd);
int check_origin(int fd,proxy_t *p);
size_t arr_size(void *array, size_t element_size);
char *parse_origin(char *data);
sblist *parse_ports(char *data, enum proxy_type type);
bool parse_proxy_type(enum proxy_type type,char *proxy_kinds);
#endif // PROXY_H