]> jfr.im git - irc/quakenet/newserv.git/blame - trusts/trusts.h
Update message for expired trusts.
[irc/quakenet/newserv.git] / trusts / trusts.h
CommitLineData
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
2ab0a1e7
CP
21#define MAXTRUSTEDFOR 50000
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
caf2d02a
GB
30#define CLEANUP_TH_INACTIVE 30
31
1961b117
GB
32#define POLICY_GLINE_DURATION 18
33
2b6e02e2
CP
34struct trustmigration;
35
1bbe1ac3
CP
36struct trusthost;
37
be2823bc 38typedef struct trusthost {
9bf9e8a1
CP
39 unsigned int id;
40
6e6e98da
GB
41 struct irc_in_addr ip;
42 unsigned char bits;
4be1aaf2 43 unsigned int maxusage;
caf2d02a 44 time_t created;
be2823bc
CP
45 time_t lastseen;
46
1bbe1ac3
CP
47 nick *users;
48 struct trustgroup *group;
49
50 unsigned int count;
51
cebc4cab
GB
52 int maxpernode;
53 int nodebits;
54
34e3de85
GB
55 struct trusthost *parent, *children;
56 unsigned int marker;
57
58 struct trusthost *nextbychild;
be2823bc
CP
59 struct trusthost *next;
60} trusthost;
61
2b6e02e2
CP
62typedef struct trustgroup {
63 unsigned int id;
64
65 sstring *name;
66 unsigned int trustedfor;
67 int mode;
68 unsigned int maxperident;
4be1aaf2 69 unsigned int maxusage;
2b6e02e2 70 time_t expires;
be2823bc 71 time_t lastseen;
1f685425 72 time_t lastmaxusereset;
2b6e02e2
CP
73 sstring *createdby, *contact, *comment;
74
be2823bc 75 trusthost *hosts;
1bbe1ac3
CP
76 unsigned int count;
77
34e3de85
GB
78 unsigned int marker;
79
2b6e02e2 80 struct trustgroup *next;
2129448c
CP
81
82 void *exts[MAXTGEXTS];
2b6e02e2
CP
83} trustgroup;
84
1bbe1ac3
CP
85#define nextbytrust(x) (nick *)((x)->exts[trusts_nextuserext])
86#define gettrusthost(x) (trusthost *)((x)->exts[trusts_thext])
87#define setnextbytrust(x, y) (x)->exts[trusts_nextuserext] = (y)
88#define settrusthost(x, y) (x)->exts[trusts_thext] = (y)
89
45e8ce62
CP
90/* trusts.c */
91extern int trusts_thext, trusts_nextuserext;
2129448c
CP
92int findtgext(const char *);
93int registertgext(const char *);
94void releasetgext(int);
82a316e7 95int trusts_fullyonline(void);
45e8ce62 96
8a95d3e4
CP
97/* formats.c */
98char *trusts_timetostr(time_t);
6e6e98da 99char *trusts_cidr2str(struct irc_in_addr *ip, unsigned char);
82a316e7
CP
100char *dumpth(trusthost *, int);
101char *dumptg(trustgroup *, int);
102int parseth(char *, trusthost *, unsigned int *, int);
103int parsetg(char *, trustgroup *, int);
104char *rtrim(char *);
5ada3782
CP
105
106/* data.c */
be2823bc 107extern trustgroup *tglist;
5ada3782
CP
108trustgroup *tg_getbyid(unsigned int);
109void th_free(trusthost *);
82a316e7 110trusthost *th_add(trusthost *);
2ab0a1e7 111void tg_free(trustgroup *, int);
82a316e7 112trustgroup *tg_add(trustgroup *);
6e6e98da
GB
113trusthost *th_getbyhost(struct irc_in_addr *);
114trusthost *th_getbyhostandmask(struct irc_in_addr *, uint32_t);
115trusthost *th_getsmallestsupersetbyhost(struct irc_in_addr *, uint32_t);
9097ab05
CP
116trustgroup *tg_strtotg(char *);
117void th_adjusthosts(trusthost *th, trusthost *, trusthost *);
6e6e98da
GB
118void th_getsuperandsubsets(struct irc_in_addr *, uint32_t, trusthost **, trusthost **);
119trusthost *th_getsubsetbyhost(struct irc_in_addr *ip, uint32_t mask);
120trusthost *th_getnextsubsetbyhost(trusthost *th, struct irc_in_addr *ip, uint32_t mask);
34e3de85
GB
121void th_linktree(void);
122unsigned int nexttgmarker(void);
123unsigned int nextthmarker(void);
2ab0a1e7
CP
124trusthost *th_getbyid(unsigned int);
125int tg_modify(trustgroup *, trustgroup *);
058f68c5 126int th_modify(trusthost *, trusthost *);
5ada3782
CP
127
128/* migration.c */
82a316e7
CP
129typedef void (*TrustMigrationGroup)(void *, trustgroup *);
130typedef void (*TrustMigrationHost)(void *, trusthost *, unsigned int);
5ada3782 131typedef void (*TrustMigrationFini)(void *, int);
2b6e02e2 132
2ab0a1e7
CP
133/* trusts_db.c */
134extern int trustsdbloaded;
135int trusts_loaddb(void);
136void trusts_closedb(int);
137trustgroup *tg_new(trustgroup *);
138trusthost *th_new(trustgroup *, char *);
139void trustsdb_insertth(char *, trusthost *, unsigned int);
140void trustsdb_inserttg(char *, trustgroup *);
141trustgroup *tg_copy(trustgroup *);
142trusthost *th_copy(trusthost *);
143void tg_update(trustgroup *);
144void tg_delete(trustgroup *);
c1da06f9 145void th_update(trusthost *);
2ab0a1e7 146void th_delete(trusthost *);
1467e9a4
GB
147void trustlog(trustgroup *tg, const char *user, const char *format, ...);
148void trustlogspewid(nick *np, unsigned int groupid, unsigned int limit);
149void trustlogspewname(nick *np, const char *groupname, unsigned int limit);
01bd21d3 150void trustloggrep(nick *np, const char *pattern, unsigned int limit);
2ab0a1e7 151
5ada3782
CP
152typedef struct trustmigration {
153 int count, cur;
154 void *schedule;
155 void *tag;
156
157 TrustMigrationGroup group;
158 TrustMigrationHost host;
159 TrustMigrationFini fini;
160} trustmigration;
161
162/* db-migration.c */
5ada3782 163typedef void (*TrustDBMigrationCallback)(int, void *);
2d4ba67d 164
9097ab05
CP
165/* events.c */
166void trusts_newnick(nick *, int);
167void trusts_lostnick(nick *, int);
168
813c5b73
CP
169/* trusts_api.c */
170int istrusted(nick *);
ac3af088
GB
171int trustgline(trustgroup *tg, const char *ident, int duration, const char *reason);
172int trustungline(trustgroup *tg, const char *ident, int duration, const char *reason);
a473a1be 173unsigned char getnodebits(struct irc_in_addr *ip);
813c5b73 174
2b6e02e2 175#endif