X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/d3204d06c7120485185cf5c97cb89dd6e67300d5..babee1a0fda9095a0a2b2b5c529e03382a7d0363:/trusts/trusts_db.c diff --git a/trusts/trusts_db.c b/trusts/trusts_db.c index 173ccac2..1b04d3ee 100644 --- a/trusts/trusts_db.c +++ b/trusts/trusts_db.c @@ -45,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 ); } @@ -197,7 +197,7 @@ static void loadgroups_fini(const DBAPIResult *result, void *tag) { static int trusts_connectdb(void) { if(!trustsdb) { - trustsdb = dbapi2open(NULL, "trusts"); + trustsdb = dbapi2open("sqlite", "trusts"); if(!trustsdb) { Error("trusts", ERR_WARNING, "Unable to connect to db -- not loaded."); return 0; @@ -284,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; @@ -322,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 ); }