[READ-ONLY] Mirror of https://github.com/VibeDevelopers/Comet.
0

Configure Feed

Select the types of activity you want to include in your feed.

authd: add stats reporting API

Elizabeth Myers (Mar 27, 2016, 5:04 PM -0500) 02e141f7 eccc44ed

+53 -9
+12 -7
authd/dns.c
··· 20 20 21 21 #include "authd.h" 22 22 #include "dns.h" 23 + #include "notice.h" 23 24 #include "res.h" 24 25 25 26 static void handle_lookup_ip_reply(void *data, struct DNSReply *reply); ··· 255 256 { 256 257 char buf[(HOSTIPLEN + 1) * IRCD_MAXNS]; 257 258 char *c = buf; 258 - int i; 259 + size_t s = 0; 260 + uint32_t i_rid = (uint32_t)strtol(rid, NULL, 16); 259 261 260 262 if (!irc_nscount) 261 263 { 262 264 /* Shouldn't happen */ 263 - rb_helper_write(authd_helper, "X %s %c NONAMESERVERS", rid, letter); 265 + stats_error(i_rid, letter, "NONAMESERVERS"); 264 266 return; 265 267 } 266 268 267 - for(i = 0; i < irc_nscount; i++) 269 + for(int i = 0; i < irc_nscount; i++) 268 270 { 269 271 char addr[HOSTIPLEN]; 272 + size_t addrlen; 270 273 271 274 rb_inet_ntop_sock((struct sockaddr *)&irc_nsaddr_list[i], addr, sizeof(addr)); 272 275 273 276 if (!addr[0]) 274 277 { 275 278 /* Shouldn't happen */ 276 - rb_helper_write(authd_helper, "X %s %c INVALIDNAMESERVER", rid, letter); 279 + stats_error(i_rid, letter, "INVALIDNAMESERVER"); 277 280 return; 278 281 } 279 282 280 - (void)snprintf(c, HOSTIPLEN + 1, "%s ", addr); 281 - c += strlen(addr) + 1; 283 + addrlen = strlen(addr) + 1; 284 + (void)snprintf(c, sizeof(buf) - s, "%s ", addr); 285 + c += addrlen; 286 + s += addrlen; 282 287 } 283 288 284 289 *(--c) = '\0'; 285 290 286 - rb_helper_write(authd_helper, "Y %s %c %s", rid, letter, buf); 291 + stats_result(i_rid, letter, "%s", buf); 287 292 } 288 293 289 294 void
+38 -2
authd/notice.c
··· 22 22 #include "notice.h" 23 23 24 24 /* Send a notice to a client */ 25 - void notice_client(uint32_t cid, const char *fmt, ...) 25 + void 26 + notice_client(uint32_t cid, const char *fmt, ...) 26 27 { 27 28 char buf[BUFSIZE]; 28 29 va_list args; ··· 35 36 } 36 37 37 38 /* Send a warning to the IRC daemon for logging, etc. */ 38 - void warn_opers(notice_level_t level, const char *fmt, ...) 39 + void 40 + warn_opers(notice_level_t level, const char *fmt, ...) 39 41 { 40 42 char buf[BUFSIZE]; 41 43 va_list args; ··· 46 48 47 49 rb_helper_write(authd_helper, "W %c :%s", level, buf); 48 50 } 51 + 52 + /* Send a stats result */ 53 + void 54 + stats_result(uint32_t cid, char letter, const char *fmt, ...) 55 + { 56 + char buf[BUFSIZE]; 57 + va_list args; 58 + 59 + va_start(args, fmt); 60 + vsnprintf(buf, sizeof(buf), fmt, args); 61 + va_end(args); 62 + 63 + rb_helper_write(authd_helper, "Y %x %c %s", cid, letter, buf); 64 + } 65 + 66 + /* Send a stats error */ 67 + void 68 + stats_error(uint32_t cid, char letter, const char *fmt, ...) 69 + { 70 + char buf[BUFSIZE]; 71 + va_list args; 72 + 73 + va_start(args, fmt); 74 + vsnprintf(buf, sizeof(buf), fmt, args); 75 + va_end(args); 76 + 77 + rb_helper_write(authd_helper, "X %x %c %s", cid, letter, buf); 78 + } 79 + 80 + void 81 + stats_done(uint32_t cid, char letter) 82 + { 83 + rb_helper_write(authd_helper, "Z %x %c", cid, letter); 84 + }
+3
authd/notice.h
··· 31 31 32 32 void notice_client(uint32_t cid, const char *fmt, ...); 33 33 void warn_opers(notice_level_t level, const char *fmt, ...); 34 + void stats_result(uint32_t cid, char letter, const char *fmt, ...); 35 + void stats_error(uint32_t cid, char letter, const char *fmt, ...); 36 + void stats_done(uint32_t cid, char letter); 34 37 35 38 #endif /* __CHARYBDIS_AUTHD_NOTICE_H__ */