]>
Commit | Line | Data |
---|---|---|
2b6e02e2 CP |
1 | #ifndef __TRUSTS_H |
2 | #define __TRUSTS_H | |
3 | ||
4 | #include <time.h> | |
65f34016 | 5 | #include <stdint.h> |
1bbe1ac3 | 6 | #include "../nick/nick.h" |
2b6e02e2 CP |
7 | #include "../lib/sstring.h" |
8 | ||
9 | #define MIGRATION_STOPPED -1 | |
83bccee3 | 10 | #define MIGRATION_LASTERROR -2 |
2b6e02e2 CP |
11 | |
12 | #define CONTACTLEN 100 | |
13 | #define COMMENTLEN 300 | |
be2823bc CP |
14 | #define TRUSTNAMELEN 100 |
15 | #define TRUSTHOSTLEN 100 | |
1f685425 | 16 | #define CREATEDBYLEN NICKLEN + 1 |
01bd21d3 | 17 | #define TRUSTLOGLEN 200 |
1f685425 | 18 | |
2129448c | 19 | #define MAXTGEXTS 5 |
2b6e02e2 | 20 | |
e40626f0 | 21 | #define MAXTRUSTEDFOR 5000 |
2ab0a1e7 CP |
22 | #define MAXDURATION 365 * 86400 * 20 |
23 | #define MAXPERIDENT 1000 | |
c1da06f9 | 24 | #define MAXPERNODE 1000 |
2ab0a1e7 | 25 | |
35449aa5 CP |
26 | #define TABLES_REGULAR 0 |
27 | #define TABLES_MIGRATION 1 | |
28 | #define TABLES_REPLICATION 2 | |
29 | ||
e7a8ea3a | 30 | #define CLEANUP_TH_INACTIVE 60 |
caf2d02a | 31 | |
6f335647 | 32 | #define POLICY_GLINE_DURATION 1800 |
1961b117 | 33 | |
de723023 GB |
34 | #define TRUST_ENFORCE_IDENT 1 /* This must be 1 for compatibility with O. */ |
35 | #define TRUST_NO_CLEANUP 2 | |
e40626f0 GB |
36 | #define TRUST_PROTECTED 4 |
37 | ||
38 | #define TRUST_MIN_UNPRIVILEGED_BITS_IPV4 (96 + 32) | |
39 | #define TRUST_MIN_UNPRIVILEGED_BITS_IPV6 32 | |
40 | ||
41 | #define TRUST_MIN_UNPRIVILEGED_NODEBITS_IPV4 (96 + 24) | |
42 | #define TRUST_MIN_UNPRIVILEGED_NODEBITS_IPV6 48 | |
de723023 | 43 | |
2b6e02e2 CP |
44 | struct trustmigration; |
45 | ||
1bbe1ac3 CP |
46 | struct trusthost; |
47 | ||
be2823bc | 48 | typedef struct trusthost { |
9bf9e8a1 CP |
49 | unsigned int id; |
50 | ||
6e6e98da GB |
51 | struct irc_in_addr ip; |
52 | unsigned char bits; | |
4be1aaf2 | 53 | unsigned int maxusage; |
caf2d02a | 54 | time_t created; |
be2823bc CP |
55 | time_t lastseen; |
56 | ||
1bbe1ac3 CP |
57 | nick *users; |
58 | struct trustgroup *group; | |
59 | ||
60 | unsigned int count; | |
61 | ||
cebc4cab GB |
62 | int maxpernode; |
63 | int nodebits; | |
64 | ||
34e3de85 GB |
65 | struct trusthost *parent, *children; |
66 | unsigned int marker; | |
67 | ||
68 | struct trusthost *nextbychild; | |
be2823bc CP |
69 | struct trusthost *next; |
70 | } trusthost; | |
71 | ||
2b6e02e2 CP |
72 | typedef struct trustgroup { |
73 | unsigned int id; | |
74 | ||
75 | sstring *name; | |
76 | unsigned int trustedfor; | |
de723023 | 77 | int flags; |
2b6e02e2 | 78 | unsigned int maxperident; |
4be1aaf2 | 79 | unsigned int maxusage; |
2b6e02e2 | 80 | time_t expires; |
be2823bc | 81 | time_t lastseen; |
1f685425 | 82 | time_t lastmaxusereset; |
2b6e02e2 CP |
83 | sstring *createdby, *contact, *comment; |
84 | ||
be2823bc | 85 | trusthost *hosts; |
1bbe1ac3 CP |
86 | unsigned int count; |
87 | ||
34e3de85 GB |
88 | unsigned int marker; |
89 | ||
2b6e02e2 | 90 | struct trustgroup *next; |
2129448c CP |
91 | |
92 | void *exts[MAXTGEXTS]; | |
2b6e02e2 CP |
93 | } trustgroup; |
94 | ||
1bbe1ac3 CP |
95 | #define nextbytrust(x) (nick *)((x)->exts[trusts_nextuserext]) |
96 | #define gettrusthost(x) (trusthost *)((x)->exts[trusts_thext]) | |
97 | #define setnextbytrust(x, y) (x)->exts[trusts_nextuserext] = (y) | |
98 | #define settrusthost(x, y) (x)->exts[trusts_thext] = (y) | |
99 | ||
45e8ce62 CP |
100 | /* trusts.c */ |
101 | extern int trusts_thext, trusts_nextuserext; | |
2129448c CP |
102 | int findtgext(const char *); |
103 | int registertgext(const char *); | |
104 | void releasetgext(int); | |
82a316e7 | 105 | int trusts_fullyonline(void); |
45e8ce62 | 106 | |
8a95d3e4 CP |
107 | /* formats.c */ |
108 | char *trusts_timetostr(time_t); | |
6e6e98da | 109 | char *trusts_cidr2str(struct irc_in_addr *ip, unsigned char); |
82a316e7 CP |
110 | char *dumpth(trusthost *, int); |
111 | char *dumptg(trustgroup *, int); | |
112 | int parseth(char *, trusthost *, unsigned int *, int); | |
113 | int parsetg(char *, trustgroup *, int); | |
114 | char *rtrim(char *); | |
5ada3782 CP |
115 | |
116 | /* data.c */ | |
be2823bc | 117 | extern trustgroup *tglist; |
5ada3782 CP |
118 | trustgroup *tg_getbyid(unsigned int); |
119 | void th_free(trusthost *); | |
82a316e7 | 120 | trusthost *th_add(trusthost *); |
2ab0a1e7 | 121 | void tg_free(trustgroup *, int); |
82a316e7 | 122 | trustgroup *tg_add(trustgroup *); |
6e6e98da GB |
123 | trusthost *th_getbyhost(struct irc_in_addr *); |
124 | trusthost *th_getbyhostandmask(struct irc_in_addr *, uint32_t); | |
125 | trusthost *th_getsmallestsupersetbyhost(struct irc_in_addr *, uint32_t); | |
9097ab05 CP |
126 | trustgroup *tg_strtotg(char *); |
127 | void th_adjusthosts(trusthost *th, trusthost *, trusthost *); | |
6e6e98da GB |
128 | void th_getsuperandsubsets(struct irc_in_addr *, uint32_t, trusthost **, trusthost **); |
129 | trusthost *th_getsubsetbyhost(struct irc_in_addr *ip, uint32_t mask); | |
130 | trusthost *th_getnextsubsetbyhost(trusthost *th, struct irc_in_addr *ip, uint32_t mask); | |
34e3de85 GB |
131 | void th_linktree(void); |
132 | unsigned int nexttgmarker(void); | |
133 | unsigned int nextthmarker(void); | |
2ab0a1e7 CP |
134 | trusthost *th_getbyid(unsigned int); |
135 | int tg_modify(trustgroup *, trustgroup *); | |
058f68c5 | 136 | int th_modify(trusthost *, trusthost *); |
5ada3782 CP |
137 | |
138 | /* migration.c */ | |
82a316e7 CP |
139 | typedef void (*TrustMigrationGroup)(void *, trustgroup *); |
140 | typedef void (*TrustMigrationHost)(void *, trusthost *, unsigned int); | |
5ada3782 | 141 | typedef void (*TrustMigrationFini)(void *, int); |
2b6e02e2 | 142 | |
2ab0a1e7 CP |
143 | /* trusts_db.c */ |
144 | extern int trustsdbloaded; | |
145 | int trusts_loaddb(void); | |
146 | void trusts_closedb(int); | |
147 | trustgroup *tg_new(trustgroup *); | |
148 | trusthost *th_new(trustgroup *, char *); | |
149 | void trustsdb_insertth(char *, trusthost *, unsigned int); | |
150 | void trustsdb_inserttg(char *, trustgroup *); | |
151 | trustgroup *tg_copy(trustgroup *); | |
152 | trusthost *th_copy(trusthost *); | |
153 | void tg_update(trustgroup *); | |
154 | void tg_delete(trustgroup *); | |
c1da06f9 | 155 | void th_update(trusthost *); |
2ab0a1e7 | 156 | void th_delete(trusthost *); |
1467e9a4 GB |
157 | void trustlog(trustgroup *tg, const char *user, const char *format, ...); |
158 | void trustlogspewid(nick *np, unsigned int groupid, unsigned int limit); | |
159 | void trustlogspewname(nick *np, const char *groupname, unsigned int limit); | |
01bd21d3 | 160 | void trustloggrep(nick *np, const char *pattern, unsigned int limit); |
2ab0a1e7 | 161 | |
5ada3782 CP |
162 | typedef struct trustmigration { |
163 | int count, cur; | |
164 | void *schedule; | |
165 | void *tag; | |
166 | ||
167 | TrustMigrationGroup group; | |
168 | TrustMigrationHost host; | |
169 | TrustMigrationFini fini; | |
170 | } trustmigration; | |
171 | ||
172 | /* db-migration.c */ | |
5ada3782 | 173 | typedef void (*TrustDBMigrationCallback)(int, void *); |
2d4ba67d | 174 | |
9097ab05 CP |
175 | /* events.c */ |
176 | void trusts_newnick(nick *, int); | |
177 | void trusts_lostnick(nick *, int); | |
178 | ||
813c5b73 CP |
179 | /* trusts_api.c */ |
180 | int istrusted(nick *); | |
a473a1be | 181 | unsigned char getnodebits(struct irc_in_addr *ip); |
813c5b73 | 182 | |
2b6e02e2 | 183 | #endif |