6 #include "../nick/nick.h"
7 #include "../lib/sstring.h"
9 #define MIGRATION_STOPPED -1
10 #define MIGRATION_LASTERROR -2
12 #define CONTACTLEN 100
13 #define COMMENTLEN 300
14 #define TRUSTNAMELEN 100
15 #define TRUSTHOSTLEN 100
16 #define CREATEDBYLEN NICKLEN + 1
17 #define TRUSTLOGLEN 200
21 #define MAXTRUSTEDFOR 50000
22 #define MAXDURATION 365 * 86400 * 20
23 #define MAXPERIDENT 1000
24 #define MAXPERNODE 1000
26 #define TABLES_REGULAR 0
27 #define TABLES_MIGRATION 1
28 #define TABLES_REPLICATION 2
30 #define CLEANUP_TH_INACTIVE 60
32 #define POLICY_GLINE_DURATION 1800
34 #define TRUST_ENFORCE_IDENT 1 /* This must be 1 for compatibility with O. */
35 #define TRUST_NO_CLEANUP 2
37 struct trustmigration
;
41 typedef struct trusthost
{
44 struct irc_in_addr ip
;
46 unsigned int maxusage
;
51 struct trustgroup
*group
;
58 struct trusthost
*parent
, *children
;
61 struct trusthost
*nextbychild
;
62 struct trusthost
*next
;
65 typedef struct trustgroup
{
69 unsigned int trustedfor
;
71 unsigned int maxperident
;
72 unsigned int maxusage
;
75 time_t lastmaxusereset
;
76 sstring
*createdby
, *contact
, *comment
;
83 struct trustgroup
*next
;
85 void *exts
[MAXTGEXTS
];
88 #define nextbytrust(x) (nick *)((x)->exts[trusts_nextuserext])
89 #define gettrusthost(x) (trusthost *)((x)->exts[trusts_thext])
90 #define setnextbytrust(x, y) (x)->exts[trusts_nextuserext] = (y)
91 #define settrusthost(x, y) (x)->exts[trusts_thext] = (y)
94 extern int trusts_thext
, trusts_nextuserext
;
95 int findtgext(const char *);
96 int registertgext(const char *);
97 void releasetgext(int);
98 int trusts_fullyonline(void);
101 char *trusts_timetostr(time_t);
102 char *trusts_cidr2str(struct irc_in_addr
*ip
, unsigned char);
103 char *dumpth(trusthost
*, int);
104 char *dumptg(trustgroup
*, int);
105 int parseth(char *, trusthost
*, unsigned int *, int);
106 int parsetg(char *, trustgroup
*, int);
110 extern trustgroup
*tglist
;
111 trustgroup
*tg_getbyid(unsigned int);
112 void th_free(trusthost
*);
113 trusthost
*th_add(trusthost
*);
114 void tg_free(trustgroup
*, int);
115 trustgroup
*tg_add(trustgroup
*);
116 trusthost
*th_getbyhost(struct irc_in_addr
*);
117 trusthost
*th_getbyhostandmask(struct irc_in_addr
*, uint32_t);
118 trusthost
*th_getsmallestsupersetbyhost(struct irc_in_addr
*, uint32_t);
119 trustgroup
*tg_strtotg(char *);
120 void th_adjusthosts(trusthost
*th
, trusthost
*, trusthost
*);
121 void th_getsuperandsubsets(struct irc_in_addr
*, uint32_t, trusthost
**, trusthost
**);
122 trusthost
*th_getsubsetbyhost(struct irc_in_addr
*ip
, uint32_t mask
);
123 trusthost
*th_getnextsubsetbyhost(trusthost
*th
, struct irc_in_addr
*ip
, uint32_t mask
);
124 void th_linktree(void);
125 unsigned int nexttgmarker(void);
126 unsigned int nextthmarker(void);
127 trusthost
*th_getbyid(unsigned int);
128 int tg_modify(trustgroup
*, trustgroup
*);
129 int th_modify(trusthost
*, trusthost
*);
132 typedef void (*TrustMigrationGroup
)(void *, trustgroup
*);
133 typedef void (*TrustMigrationHost
)(void *, trusthost
*, unsigned int);
134 typedef void (*TrustMigrationFini
)(void *, int);
137 extern int trustsdbloaded
;
138 int trusts_loaddb(void);
139 void trusts_closedb(int);
140 trustgroup
*tg_new(trustgroup
*);
141 trusthost
*th_new(trustgroup
*, char *);
142 void trustsdb_insertth(char *, trusthost
*, unsigned int);
143 void trustsdb_inserttg(char *, trustgroup
*);
144 trustgroup
*tg_copy(trustgroup
*);
145 trusthost
*th_copy(trusthost
*);
146 void tg_update(trustgroup
*);
147 void tg_delete(trustgroup
*);
148 void th_update(trusthost
*);
149 void th_delete(trusthost
*);
150 void trustlog(trustgroup
*tg
, const char *user
, const char *format
, ...);
151 void trustlogspewid(nick
*np
, unsigned int groupid
, unsigned int limit
);
152 void trustlogspewname(nick
*np
, const char *groupname
, unsigned int limit
);
153 void trustloggrep(nick
*np
, const char *pattern
, unsigned int limit
);
155 typedef struct trustmigration
{
160 TrustMigrationGroup group
;
161 TrustMigrationHost host
;
162 TrustMigrationFini fini
;
166 typedef void (*TrustDBMigrationCallback
)(int, void *);
169 void trusts_newnick(nick
*, int);
170 void trusts_lostnick(nick
*, int);
173 int istrusted(nick
*);
174 unsigned char getnodebits(struct irc_in_addr
*ip
);