-
Notifications
You must be signed in to change notification settings - Fork 1
/
plug.h
102 lines (95 loc) · 3.22 KB
/
plug.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
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
/*
* PLUGDAEMON. Copyright (c) 2012 Peter da Silva. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The names of the program and author may not be used to endorse or
* promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Exit statuses */
#define S_NORMAL 0
#define S_UNKNOWN 1
#define S_CONNECT 2
#define S_EXCEPT 3
#define S_FATAL 4
#define S_SYNTAX 5
typedef struct {
struct timeval timeval;
struct timezone timezone;
struct sockaddr_in peer, listen, client, proxy, target;
off_t nread[2], nwrite[2];
} loginfo_t;
typedef struct dtab {
struct dtab *next;
char *destname;
char *connect;
struct sockaddr_in addr;
int nclients;
int status;
time_t went_bad;
} dest_t;
typedef struct ptab {
struct ptab *next;
int pid;
struct dtab *dest;
} proc_t;
typedef struct ctab {
struct ctab *next;
unsigned long addr;
struct dtab *dest;
int status;
int bucket;
time_t last_touched;
} client_t;
typedef struct rtab {
struct rtab *next;
u_long addr;
u_long netmask;
} rule_t;
void bail_no_val(char *);
void bailout (char *message, int status);
void daemonize (void);
void delete_client (client_t *client, client_t *back_ptr);
void fill_sockaddr_in (struct sockaddr_in *buffer, u_long addr, u_short port);
char *sa2ascii(struct sockaddr_in *, char *);
void forget_pid (int pid);
void init_signals (void);
void logclient (struct in_addr peer, char* status);
struct ptab *lookup_pid (int pid);
void parse_args (int ac, char **av);
int plug (int fd1, int fd2, loginfo_t *lp);
void remember_pid (int pid, struct dtab *target);
struct dtab *select_target (int clifd, loginfo_t *lp);
void tag_dest_bad (int pid, int status);
#ifdef WAITER_ALTDEF
void waiter (int sig, void *scp);
#else
void waiter (int sig, SA_HANDLER_ARG2_T code, void *scp);
#endif
void inform_undertaker(int pid, int status);
void undertaker(void);
void burials(int);
void add_filter_rule(char *);
void logout(int, loginfo_t *);
char *https_chat(int, char *);
char *raw_readline(int, char *, int);
void write_pidfile(void);
void update_pidfile(void);