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 30
32 struct trustmigration
;
36 typedef struct trusthost
{
39 struct irc_in_addr ip
;
41 unsigned int maxusage
;
46 struct trustgroup
*group
;
53 struct trusthost
*parent
, *children
;
56 struct trusthost
*nextbychild
;
57 struct trusthost
*next
;
60 typedef struct trustgroup
{
64 unsigned int trustedfor
;
66 unsigned int maxperident
;
67 unsigned int maxusage
;
70 time_t lastmaxusereset
;
71 sstring
*createdby
, *contact
, *comment
;
78 struct trustgroup
*next
;
80 void *exts
[MAXTGEXTS
];
83 #define nextbytrust(x) (nick *)((x)->exts[trusts_nextuserext])
84 #define gettrusthost(x) (trusthost *)((x)->exts[trusts_thext])
85 #define setnextbytrust(x, y) (x)->exts[trusts_nextuserext] = (y)
86 #define settrusthost(x, y) (x)->exts[trusts_thext] = (y)
89 extern int trusts_thext
, trusts_nextuserext
;
90 int findtgext(const char *);
91 int registertgext(const char *);
92 void releasetgext(int);
93 int trusts_fullyonline(void);
96 char *trusts_timetostr(time_t);
97 char *trusts_cidr2str(struct irc_in_addr
*ip
, unsigned char);
98 char *dumpth(trusthost
*, int);
99 char *dumptg(trustgroup
*, int);
100 int parseth(char *, trusthost
*, unsigned int *, int);
101 int parsetg(char *, trustgroup
*, int);
105 extern trustgroup
*tglist
;
106 trustgroup
*tg_getbyid(unsigned int);
107 void th_free(trusthost
*);
108 trusthost
*th_add(trusthost
*);
109 void tg_free(trustgroup
*, int);
110 trustgroup
*tg_add(trustgroup
*);
111 trusthost
*th_getbyhost(struct irc_in_addr
*);
112 trusthost
*th_getbyhostandmask(struct irc_in_addr
*, uint32_t);
113 trusthost
*th_getsmallestsupersetbyhost(struct irc_in_addr
*, uint32_t);
114 trustgroup
*tg_strtotg(char *);
115 void th_adjusthosts(trusthost
*th
, trusthost
*, trusthost
*);
116 void th_getsuperandsubsets(struct irc_in_addr
*, uint32_t, trusthost
**, trusthost
**);
117 trusthost
*th_getsubsetbyhost(struct irc_in_addr
*ip
, uint32_t mask
);
118 trusthost
*th_getnextsubsetbyhost(trusthost
*th
, struct irc_in_addr
*ip
, uint32_t mask
);
119 void th_linktree(void);
120 unsigned int nexttgmarker(void);
121 unsigned int nextthmarker(void);
122 trusthost
*th_getbyid(unsigned int);
123 int tg_modify(trustgroup
*, trustgroup
*);
126 typedef void (*TrustMigrationGroup
)(void *, trustgroup
*);
127 typedef void (*TrustMigrationHost
)(void *, trusthost
*, unsigned int);
128 typedef void (*TrustMigrationFini
)(void *, int);
131 extern int trustsdbloaded
;
132 int trusts_loaddb(void);
133 void trusts_closedb(int);
134 trustgroup
*tg_new(trustgroup
*);
135 trusthost
*th_new(trustgroup
*, char *);
136 void trustsdb_insertth(char *, trusthost
*, unsigned int);
137 void trustsdb_inserttg(char *, trustgroup
*);
138 trustgroup
*tg_copy(trustgroup
*);
139 trusthost
*th_copy(trusthost
*);
140 void tg_update(trustgroup
*);
141 void tg_delete(trustgroup
*);
142 void th_update(trusthost
*);
143 void th_delete(trusthost
*);
144 void trustlog(trustgroup
*tg
, const char *user
, const char *format
, ...);
145 void trustlogspewid(nick
*np
, unsigned int groupid
, unsigned int limit
);
146 void trustlogspewname(nick
*np
, const char *groupname
, unsigned int limit
);
147 void trustloggrep(nick
*np
, const char *pattern
, unsigned int limit
);
149 typedef struct trustmigration
{
154 TrustMigrationGroup group
;
155 TrustMigrationHost host
;
156 TrustMigrationFini fini
;
160 typedef void (*TrustDBMigrationCallback
)(int, void *);
163 void trusts_newnick(nick
*, int);
164 void trusts_lostnick(nick
*, int);
167 int istrusted(nick
*);
168 int trustgline(trustgroup
*tg
, const char *ident
, int duration
, const char *reason
);
169 int trustungline(trustgroup
*tg
, const char *ident
, int duration
, const char *reason
);