int main(int argc, char **argv) { NAMADR_LIST *list; char *host; char *addr; int ch; msg_vstream_init(argv[0], VSTREAM_ERR); while ((ch = GETOPT(argc, argv, "v")) > 0) { switch (ch) { case 'v': msg_verbose++; break; default: usage(argv[0]); } } if (argc != optind + 3) usage(argv[0]); list = namadr_list_init(MATCH_FLAG_PARENT, argv[optind]); host = argv[optind + 1]; addr = argv[optind + 2]; vstream_printf("%s/%s: %s\n", host, addr, namadr_list_match(list, host, addr) ? "YES" : "NO"); vstream_fflush(VSTREAM_OUT); namadr_list_free(list); return (0); }
int debug_peer_check(const char *name, const char *addr) { /* * Crank up the noise when this peer is listed. */ if (debug_peer_list != 0 && saved_level == UNUSED_SAVED_LEVEL && namadr_list_match(debug_peer_list, name, addr) != 0) { saved_level = msg_verbose; msg_verbose += var_debug_peer_level; return (1); } return (0); }
static void qmqpd_proto(QMQPD_STATE *state) { int status; netstring_setup(state->client, var_qmqpd_timeout); switch (status = vstream_setjmp(state->client)) { default: msg_panic("qmqpd_proto: unknown status %d", status); case NETSTRING_ERR_EOF: state->reason = "lost connection"; break; case NETSTRING_ERR_TIME: state->reason = "read/write timeout"; break; case NETSTRING_ERR_FORMAT: state->reason = "netstring format error"; if (vstream_setjmp(state->client) == 0) if (state->reason && state->where) qmqpd_reply(state, DONT_LOG, QMQPD_STAT_HARD, "%s while %s", state->reason, state->where); break; case NETSTRING_ERR_SIZE: state->reason = "netstring length exceeds storage limit"; if (vstream_setjmp(state->client) == 0) if (state->reason && state->where) qmqpd_reply(state, DONT_LOG, QMQPD_STAT_HARD, "%s while %s", state->reason, state->where); break; case 0: /* * See if we want to talk to this client at all. */ if (namadr_list_match(qmqpd_clients, state->name, state->addr) != 0) { qmqpd_receive(state); } else if (qmqpd_clients->error == 0) { qmqpd_reply(state, DONT_LOG, QMQPD_STAT_HARD, "Error: %s is not authorized to use this service", state->namaddr); } else { qmqpd_reply(state, DONT_LOG, QMQPD_STAT_RETRY, "Error: server configuration error"); } break; } /* * Log abnormal session termination. Indicate the last recognized state * before things went wrong. */ if (state->reason && state->where) msg_info("%s: %s: %s while %s", state->queue_id, state->namaddr, state->reason, state->where); }