static void list_bans(void) { static char buf[512]; struct rsdb_table table; int i, j; /* schedule a clear of anything already pending */ rb_helper_write_queue(bandb_helper, "C"); for(i = 0; i < LAST_BANDB_TYPE; i++) { rsdb_exec_fetch(&table, "SELECT mask1,mask2,oper,reason FROM %s WHERE 1", bandb_table[i]); for(j = 0; j < table.row_count; j++) { if(i == BANDB_KLINE) rb_snprintf(buf, sizeof(buf), "%c %s %s %s :%s", bandb_letter[i], table.row[j][0], table.row[j][1], table.row[j][2], table.row[j][3]); else rb_snprintf(buf, sizeof(buf), "%c %s %s :%s", bandb_letter[i], table.row[j][0], table.row[j][2], table.row[j][3]); rb_helper_write_queue(bandb_helper, "%s", buf); } rsdb_exec_fetch_end(&table); } rb_helper_write(bandb_helper, "F"); }
static void db_error_cb(const char *errstr) { char buf[256]; rb_snprintf(buf, sizeof(buf), "! :%s", errstr); rb_helper_write(bandb_helper, "%s", buf); rb_sleep(2 << 30, 0); exit(1); }
static void db_error_cb(const char *errstr, void *data) { rb_helper *helper = (rb_helper *)data; char buf[256]; snprintf(buf, sizeof(buf), "! :%s", errstr); rb_helper_write(helper, "%s", buf); rb_sleep(INT_MAX-1, 0); exit(1); }
static void submit_dns_answer(const char *reply, bool status, query_type type, void *data) { char *id = data; if(!id || type == QUERY_INVALID) { warn_opers(L_CRIT, "DNS: submit_dns_answer gave us a bad query"); exit(EX_DNS_ERROR); } if(reply == NULL || status == false) { rb_helper_write(authd_helper, "E %s E %c *", id, type); rb_free(id); return; } rb_helper_write(authd_helper, "E %s O %c %s", id, type, reply); rb_free(id); }
static void report_nameservers(void) { int i; char ipaddr[HOSTIPLEN + 1]; char buf[512]; buf[0] = '\0'; for(i = 0; i < irc_nscount; i++) { if(!rb_inet_ntop_sock ((struct sockaddr *)&(irc_nsaddr_list[i]), ipaddr, sizeof(ipaddr))) { rb_strlcpy(ipaddr, "?", sizeof(ipaddr)); } rb_snprintf_append(buf, sizeof(buf), "%s ", ipaddr); } rb_helper_write(res_helper, "A %s", buf); }
static void send_answer(void *vptr, struct DNSReply *reply) { struct dns_request *req = (struct dns_request *)vptr; char response[64]; int result = 0; int aftype = 0; strcpy(response, "FAILED"); if(reply != NULL) { switch (req->revfwd) { case REQREV: { if(req->reqtype == REVIPV4) { struct sockaddr_in *ip, *ip_fwd; ip = (struct sockaddr_in *)&req->addr; ip_fwd = (struct sockaddr_in *)&reply->addr; aftype = 4; if(ip->sin_addr.s_addr != ip_fwd->sin_addr.s_addr) { result = 0; break; } } #ifdef RB_IPV6 else if(req->reqtype == REVIPV6) { struct sockaddr_in6 *ip, *ip_fwd; ip = (struct sockaddr_in6 *)&req->addr; ip_fwd = (struct sockaddr_in6 *)&reply->addr; aftype = 6; if(memcmp (&ip->sin6_addr, &ip_fwd->sin6_addr, sizeof(struct in6_addr)) != 0) { result = 0; break; } } #endif else { /* uhh wut? */ result = 0; break; } if(strlen(reply->h_name) < 63) { strcpy(response, reply->h_name); result = 1; } else { strcpy(response, "HOSTTOOLONG"); result = 0; } break; } case REQFWD: { #ifdef RB_IPV6 if(GET_SS_FAMILY(&reply->addr) == AF_INET6) { char tmpres[65]; rb_inet_ntop_sock((struct sockaddr *)&reply->addr, tmpres, sizeof(tmpres) - 1); aftype = 6; if(*tmpres == ':') { strcpy(response, "0"); strcat(response, tmpres); } else strcpy(response, tmpres); result = 1; break; } else #endif if(GET_SS_FAMILY(&reply->addr) == AF_INET) { result = 1; aftype = 4; rb_inet_ntop_sock((struct sockaddr *)&reply->addr, response, sizeof(response)); break; } else break; } default: { exit(1); } } } rb_helper_write(res_helper, "R %s %d %d %s\n", req->reqid, result, aftype, response); rb_free(req); }