74 lines
2.1 KiB
C
74 lines
2.1 KiB
C
#ifndef MAIN_H
|
||
#define MAIN_H
|
||
|
||
#include <netinet/in.h>
|
||
#include <arpa/inet.h>
|
||
#include "common.h"
|
||
#include "httpdns.h"
|
||
#include "conf.h"
|
||
|
||
// 字体颜色
|
||
#define NONE "\033[m"
|
||
#define RED "\033[0;32;31m"
|
||
#define LIGHT_RED "\033[1;31m"
|
||
#define GREEN "\033[0;32;32m"
|
||
#define LIGHT_GREEN "\033[1;32m"
|
||
#define BLUE "\033[0;32;34m"
|
||
#define LIGHT_BLUE "\033[1;34m"
|
||
#define DARY_GRAY "\033[1;30m"
|
||
#define CYAN "\033[0;36m"
|
||
#define LIGHT_CYAN "\033[1;36m"
|
||
#define PURPLE "\033[0;35m"
|
||
#define LIGHT_PURPLE "\033[1;35m"
|
||
#define BROWN "\033[0;33m"
|
||
#define YELLOW "\033[1;33m"
|
||
#define LIGHT_GRAY "\033[0;37m"
|
||
#define WHITE "\033[1;37m"
|
||
|
||
#define LOG(fmt...) do { fprintf(stderr, ##fmt); } while(0)
|
||
|
||
/* 数据类型 */
|
||
#define OTHER 1
|
||
#define HTTP 2
|
||
#define HTTP_OTHERS 3
|
||
#define HTTP_CONNECT 4
|
||
/* 处理TCP请求模式 */
|
||
#define WAP 1
|
||
#define WAP_CONNECT 2
|
||
#define NET_CONNECT 3
|
||
#define NET_PROXY 4
|
||
|
||
struct httpudp {
|
||
struct sockaddr_in dst;
|
||
char *http_request, *original_http_request; //original_http_request为初始化生成的请求头,用来配合use_hdr语法
|
||
int http_request_len, original_http_request_len;
|
||
unsigned encodeCode, //数据编码传输
|
||
httpsProxy_encodeCode; //CONNECT代理编码
|
||
};
|
||
|
||
typedef struct connection {
|
||
struct sockaddr_in original_dst;
|
||
char *ready_data; //已就绪的数据,可以发送
|
||
char *incomplete_data; //存放不是完整的请求头
|
||
char *host;
|
||
char *connect; //存放CONNECT请求
|
||
int connect_len; //CONNECT请求的长度
|
||
int incomplete_data_len, ready_data_len, sent_len, fd, timer;
|
||
uint16_t original_port;
|
||
unsigned reqType:3, //请求类型
|
||
first_connection:1, //发送客户端数据前是否首先进行CONNECT连接
|
||
is_httpsProxy:1; //如果真 则表示连接是走HTTPS模块
|
||
} tcp_t;
|
||
|
||
struct global {
|
||
int tcp_listen_fd, dns_listen_fd, udp_listen_fd, uid, procs, timeout_m;
|
||
unsigned mode:3, strict_modify:1;
|
||
};
|
||
|
||
extern struct global global;
|
||
|
||
extern uint16_t tcp_listen_port;
|
||
extern struct httpudp udp;
|
||
|
||
#endif
|