]> jfr.im git - irc/quakenet/newserv.git/blobdiff - trusts/trusts.h
Merge chanserv-live into default.
[irc/quakenet/newserv.git] / trusts / trusts.h
index d9685046f44d3dfe4274cecc5f12cbe0172cbbef..386cbe9579160199b016f4e8d67fb648102508db 100644 (file)
 #define TRUSTNAMELEN 100
 #define TRUSTHOSTLEN 100
 #define CREATEDBYLEN NICKLEN + 1
+#define TRUSTLOGLEN 200
 
 #define MAXTGEXTS 5
 
-#define MAXTRUSTEDFOR 50000
+#define MAXTRUSTEDFOR 5000
 #define MAXDURATION 365 * 86400 * 20
 #define MAXPERIDENT 1000
+#define MAXPERNODE 1000
 
 #define TABLES_REGULAR 0
 #define TABLES_MIGRATION 1
 #define TABLES_REPLICATION 2
 
+#define CLEANUP_TH_INACTIVE 60
+
+#define POLICY_GLINE_DURATION 1800
+
+#define POLICY_SUCCESS 0
+#define POLICY_FAILURE_NODECOUNT 1
+#define POLICY_FAILURE_GROUPCOUNT 2
+#define POLICY_FAILURE_IDENTD 3
+#define POLICY_FAILURE_IDENTCOUNT 4
+
+#define DEFAULT_TRUSTPORT 5776
+
+#define TRUST_ENFORCE_IDENT 1 /* This must be 1 for compatibility with O. */
+#define TRUST_NO_CLEANUP 2
+#define TRUST_PROTECTED 4
+#define TRUST_RELIABLE_USERNAME 8
+#define TRUST_UNTHROTTLE 16
+
+#define TRUST_MIN_UNPRIVILEGED_BITS_IPV4 (96 + 20)
+#define TRUST_MIN_UNPRIVILEGED_BITS_IPV6 32
+
+#define TRUST_MIN_UNPRIVILEGED_NODEBITS_IPV4 (96 + 24)
+#define TRUST_MIN_UNPRIVILEGED_NODEBITS_IPV6 48
+
 struct trustmigration;
 
 struct trusthost;
@@ -32,8 +58,10 @@ struct trusthost;
 typedef struct trusthost {
   unsigned int id;
 
-  uint32_t ip, mask;
+  struct irc_in_addr ip;
+  unsigned char bits;
   unsigned int maxusage;
+  time_t created;
   time_t lastseen;
 
   nick *users;
@@ -41,6 +69,9 @@ typedef struct trusthost {
 
   unsigned int count;
 
+  int maxpernode;
+  int nodebits;
+
   struct trusthost *parent, *children;
   unsigned int marker;
 
@@ -53,8 +84,8 @@ typedef struct trustgroup {
 
   sstring *name;
   unsigned int trustedfor;
-  int mode;
-  unsigned int maxperident;
+  int flags;
+  int maxperident;
   unsigned int maxusage;
   time_t expires;
   time_t lastseen;
@@ -85,9 +116,6 @@ int trusts_fullyonline(void);
 
 /* formats.c */
 char *trusts_timetostr(time_t);
-int trusts_parsecidr(const char *, uint32_t *, short *);
-int trusts_str2cidr(const char *, uint32_t *, uint32_t *);
-char *trusts_cidr2str(uint32_t, uint32_t);
 char *dumpth(trusthost *, int);
 char *dumptg(trustgroup *, int);
 int parseth(char *, trusthost *, unsigned int *, int);
@@ -101,19 +129,20 @@ void th_free(trusthost *);
 trusthost *th_add(trusthost *);
 void tg_free(trustgroup *, int);
 trustgroup *tg_add(trustgroup *);
-trusthost *th_getbyhost(uint32_t);
-trusthost *th_getbyhostandmask(uint32_t, uint32_t);
-trusthost *th_getsmallestsupersetbyhost(uint32_t, uint32_t);
+trusthost *th_getbyhost(struct irc_in_addr *);
+trusthost *th_getbyhostandmask(struct irc_in_addr *, uint32_t);
+trusthost *th_getsmallestsupersetbyhost(struct irc_in_addr *, uint32_t);
 trustgroup *tg_strtotg(char *);
 void th_adjusthosts(trusthost *th, trusthost *, trusthost *);
-void th_getsuperandsubsets(uint32_t, uint32_t, trusthost **, trusthost **);
-trusthost *th_getsubsetbyhost(uint32_t ip, uint32_t mask);
-trusthost *th_getnextsubsetbyhost(trusthost *th, uint32_t ip, uint32_t mask);
+void th_getsuperandsubsets(struct irc_in_addr *, uint32_t, trusthost **, trusthost **);
+trusthost *th_getsubsetbyhost(struct irc_in_addr *ip, uint32_t mask);
+trusthost *th_getnextsubsetbyhost(trusthost *th, struct irc_in_addr *ip, uint32_t mask);
 void th_linktree(void);
 unsigned int nexttgmarker(void);
 unsigned int nextthmarker(void);
 trusthost *th_getbyid(unsigned int);
 int tg_modify(trustgroup *, trustgroup *);
+int th_modify(trusthost *, trusthost *);
 
 /* migration.c */
 typedef void (*TrustMigrationGroup)(void *, trustgroup *);
@@ -132,7 +161,12 @@ trustgroup *tg_copy(trustgroup *);
 trusthost *th_copy(trusthost *);
 void tg_update(trustgroup *);
 void tg_delete(trustgroup *);
+void th_update(trusthost *);
 void th_delete(trusthost *);
+void trustlog(trustgroup *tg, const char *user, const char *format, ...);
+void trustlogspewid(nick *np, unsigned int groupid, unsigned int limit);
+void trustlogspewname(nick *np, const char *groupname, unsigned int limit);
+void trustloggrep(nick *np, const char *pattern, unsigned int limit);
 
 typedef struct trustmigration {
   int count, cur;
@@ -151,4 +185,8 @@ typedef void (*TrustDBMigrationCallback)(int, void *);
 void trusts_newnick(nick *, int);
 void trusts_lostnick(nick *, int);
 
+/* trusts_api.c */
+int istrusted(nick *);
+unsigned char getnodebits(struct irc_in_addr *ip);
+
 #endif