Files: 2781c75ff99cd5da7b25f6b883d78ff3de987308 / common.h
3220 bytesRaw
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 | (res == -1) { \ |
31 | perror(str); \ |
32 | exit(1); \ |
33 | } |
34 | |
35 | |
36 | (res == -1) { \ |
37 | log_message(LOG_CRIT, | , str, errno, strerror(errno)); \
38 | return res; \ |
39 | } |
40 | |
41 | |
42 | |
43 | |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | enum connection_state { |
50 | ST_PROBING=1, /* Waiting for timeout to find where to forward */ |
51 | ST_SHOVELING /* Connexion is established */ |
52 | }; |
53 | |
54 | /* this is used to pass protocols through the command-line parameter parsing */ |
55 | |
56 | |
57 | /* A 'queue' is composed of a file descriptor (which can be read from or |
58 | * written to), and a queue for defered write data */ |
59 | struct queue { |
60 | int fd; |
61 | void *begin_defered_data; |
62 | void *defered_data; |
63 | int defered_data_size; |
64 | }; |
65 | |
66 | struct connection { |
67 | enum connection_state state; |
68 | time_t probe_timeout; |
69 | |
70 | /* q[0]: queue for external connection (client); |
71 | * q[1]: queue for internal connection (httpd or sshd); |
72 | * */ |
73 | struct queue q[2]; |
74 | }; |
75 | |
76 | |
77 | |
78 | |
79 | |
80 | |
81 | /* common.c */ |
82 | void init_cnx(struct connection *cnx); |
83 | int connect_addr(struct addrinfo *addr, int fd_from, const char* cnx_name); |
84 | int fd2fd(struct queue *target, struct queue *from); |
85 | char* sprintaddr(char* buf, size_t size, struct addrinfo *a); |
86 | void resolve_name(struct addrinfo **out, char* fullname); |
87 | struct proto* probe_client_protocol(struct connection *cnx); |
88 | void log_connection(struct connection *cnx); |
89 | int check_access_rights(int in_socket, const char* service); |
90 | void setup_signals(void); |
91 | void setup_syslog(const char* bin_name); |
92 | void drop_privileges(const char* user_name); |
93 | void write_pid_file(const char* pidfile); |
94 | void log_message(int type, char* msg, ...); |
95 | void dump_connection(struct connection *cnx); |
96 | int resolve_split_name(struct addrinfo **out, const char* hostname, const char* port); |
97 | |
98 | int start_listen_sockets(int *sockfd[], struct addrinfo *addr_list); |
99 | |
100 | int defer_write(struct queue *q, void* data, int data_size); |
101 | int flush_defered(struct queue *q); |
102 | |
103 | extern int probing_timeout, verbose, inetd, foreground, |
104 | background, transparent, numeric; |
105 | extern struct sockaddr_storage addr_ssl, addr_ssh, addr_openvpn; |
106 | extern struct addrinfo *addr_listen; |
107 | extern const char* USAGE_STRING; |
108 | extern const char* user_name, *pid_file; |
109 | extern const char* server_type; |
110 | |
111 | /* sslh-fork.c */ |
112 | void start_shoveler(int); |
113 | |
114 | void main_loop(int *listen_sockets, int num_addr_listen); |
115 | |
116 | |
117 |
Built with git-ssb-web