byedpi/proxy.h

99 lines
1.7 KiB
C
Raw Normal View History

2024-08-07 11:25:26 +00:00
#ifndef PROXY_H
#define PROXY_H
2023-06-03 19:52:10 +00:00
#include <stdint.h>
2024-02-18 20:20:52 +00:00
#ifdef _WIN32
#include <ws2tcpip.h>
#else
#include <arpa/inet.h>
#include <sys/socket.h>
2024-02-18 20:20:52 +00:00
#endif
2023-06-03 19:52:10 +00:00
2024-05-02 16:36:29 +00:00
#include "conev.h"
2024-04-23 05:47:27 +00:00
#define SA_SIZE(s) \
(((struct sockaddr *)s)->sa_family == AF_INET6) ? \
sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in)
2023-06-03 19:52:10 +00:00
#pragma pack(push, 1)
struct s4_req {
uint8_t ver, cmd;
uint16_t port;
struct in_addr i4;
};
struct s5_req {
uint8_t ver, cmd, zero, atp;
union {
2023-07-06 18:21:44 +00:00
struct {
2025-01-12 10:56:24 +00:00
struct in_addr ip;
uint16_t port;
} i4;
2023-07-06 18:21:44 +00:00
struct {
2025-01-12 10:56:24 +00:00
struct in6_addr ip;
uint16_t port;
} i6;
2023-06-03 19:52:10 +00:00
struct {
uint8_t len;
2025-01-12 10:56:24 +00:00
char domain[257];
2023-06-03 19:52:10 +00:00
} id;
2025-01-12 10:56:24 +00:00
} dst;
2023-06-03 19:52:10 +00:00
};
struct s5_rep {
uint8_t ver, code, zero, atp;
struct {
struct in_addr i4;
uint16_t port;
2025-01-12 10:56:24 +00:00
} addr;
2023-06-03 19:52:10 +00:00
};
#pragma pack(pop)
2025-01-12 10:56:24 +00:00
#define S_AUTH_NONE 0x00
#define S_AUTH_BAD 0xff
2023-06-03 19:52:10 +00:00
2025-01-12 10:56:24 +00:00
#define S_ATP_I4 0x01
#define S_ATP_ID 0x03
#define S_ATP_I6 0x04
2023-06-03 19:52:10 +00:00
2025-01-12 10:56:24 +00:00
#define S_CMD_CONN 0x01
#define S_CMD_BIND 0x02
#define S_CMD_AUDP 0x03
2023-06-03 19:52:10 +00:00
2025-01-12 10:56:24 +00:00
#define S_ER_OK 0x00
#define S_ER_GEN 0x01
#define S_ER_DENY 0x02
#define S_ER_NET 0x03
#define S_ER_HOST 0x04
#define S_ER_CONN 0x05
#define S_ER_TTL 0x06
#define S_ER_CMD 0x07
#define S_ER_ATP 0x08
2023-06-03 19:52:10 +00:00
2025-01-12 10:56:24 +00:00
#define S4_OK 0x5a
#define S4_ER 0x5b
2023-06-03 19:52:10 +00:00
#define S_VER5 0x05
#define S_VER4 0x04
2023-07-06 18:21:44 +00:00
#define S_SIZE_MIN 8
#define S_SIZE_I4 10
#define S_SIZE_I6 22
#define S_SIZE_ID 7
2025-01-12 10:56:24 +00:00
void map_fix(union sockaddr_u *addr, char f6);
2024-04-23 05:47:27 +00:00
int create_conn(struct poolhd *pool,
2025-01-12 10:56:24 +00:00
struct eval *val, const union sockaddr_u *dst, int next);
2024-11-09 15:07:27 +00:00
2025-01-12 10:56:24 +00:00
int listen_socket(const union sockaddr_u *srv);
2024-04-23 05:47:27 +00:00
2024-02-27 15:34:02 +00:00
int event_loop(int srvfd);
2024-04-23 05:47:27 +00:00
2025-01-12 10:56:24 +00:00
int run(const union sockaddr_u *srv);
2024-08-07 11:25:26 +00:00
#endif