X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/e40626f0dd5a4f64be2523c94c4588a6d65ba631..21b22dceca9d89abfa607419c4289b9eacf84a2f:/trusts/trusts_db.c diff --git a/trusts/trusts_db.c b/trusts/trusts_db.c index 49c7fa65..792c5fa3 100644 --- a/trusts/trusts_db.c +++ b/trusts/trusts_db.c @@ -1,5 +1,6 @@ #include #include +#include "../lib/version.h" #include "../dbapi2/dbapi2.h" #include "../core/error.h" #include "../core/hooks.h" @@ -8,6 +9,8 @@ #include "../irc/irc.h" #include "trusts.h" +MODULE_VERSION(""); + DBAPIConn *trustsdb; static int tgmaxid, thmaxid; static int loaderror; @@ -42,7 +45,7 @@ void createtrusttables(int mode) { trustsdb->createtable(trustsdb, NULL, NULL, "CREATE TABLE ? (id INT PRIMARY KEY, groupid INT, host VARCHAR(?), maxusage INT, created INT, lastseen INT, maxpernode INT, nodebits INT)", "Td", hosts, TRUSTHOSTLEN); trustsdb->createtable(trustsdb, NULL, NULL, - "CREATE TABLE ? (id INT PRIMARY KEY, groupid INT, groupname VARCHAR(?), ts INT, username VARCHAR(?), message VARCHAR(?))", + "CREATE TABLE ? (groupid INT, groupname VARCHAR(?), ts INT, username VARCHAR(?), message VARCHAR(?))", "Tddd", "log", TRUSTNAMELEN, CREATEDBYLEN, TRUSTLOGLEN ); } @@ -281,6 +284,9 @@ trusthost *th_new(trustgroup *tg, char *host) { nth.maxpernode = 0; nth.nodebits = (irc_in_addr_is_ipv4(&nth.ip))?128:64; + if (nth.bits < nth.nodebits) + nth.nodebits = nth.bits; + th = th_copy(&nth); if(!th) return NULL; @@ -319,7 +325,7 @@ trustgroup *tg_new(trustgroup *itg) { void trustsdb_insertth(char *table, trusthost *th, unsigned int groupid) { trustsdb->squery(trustsdb, "INSERT INTO ? (id, groupid, host, maxusage, created, lastseen, maxpernode, nodebits) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", - "Tuusuutuu", table, th->id, groupid, trusts_cidr2str(&th->ip, th->bits), th->maxusage, th->created, th->lastseen, th->maxpernode, th->nodebits + "Tuusuutuu", table, th->id, groupid, CIDRtostr(th->ip, th->bits), th->maxusage, th->created, th->lastseen, th->maxpernode, th->nodebits ); }