//
// This program is open source software. Use, duplication, or disclosure
// is subject to the terms of the GNU General Public License, version 3.
//
// This program is open source software. Use, duplication, or disclosure
// is subject to the terms of the GNU General Public License, version 3.
-/*
- * Given an open client socket, return the host name and IP address at the other end.
- * (IPv4 and IPv6 compatible)
- */
-void locate_host(char *tbuf, size_t n, char *abuf, size_t na, int client_socket)
-{
+// Given an open client socket, return the host name and IP address at the other end.
+// (IPv4 and IPv6 compatible)
+void locate_host(char *tbuf, size_t n, char *abuf, size_t na, int client_socket) {
getnameinfo((struct sockaddr *)&clientaddr, addrlen, tbuf, n, NULL, 0, 0);
getnameinfo((struct sockaddr *)&clientaddr, addrlen, abuf, na, NULL, 0, NI_NUMERICHOST);
getnameinfo((struct sockaddr *)&clientaddr, addrlen, tbuf, n, NULL, 0, 0);
getnameinfo((struct sockaddr *)&clientaddr, addrlen, abuf, na, NULL, 0, NI_NUMERICHOST);
- /* Convert IPv6-mapped IPv4 addresses back to traditional dotted quad.
- *
- * Other code here, such as the RBL check, will expect IPv4 addresses to be represented
- * as dotted-quad, even if they come in over a hybrid IPv6/IPv4 socket.
- */
+ // Convert IPv6-mapped IPv4 addresses back to traditional dotted quad.
+ //
+ // Other code here, such as the RBL check, will expect IPv4 addresses to be represented
+ // as dotted-quad, even if they come in over a hybrid IPv6/IPv4 socket.
if ( (strlen(abuf) > 7) && (!strncasecmp(abuf, "::ffff:", 7)) ) {
if (!strcmp(abuf, tbuf)) strcpy(tbuf, &tbuf[7]);
strcpy(abuf, &abuf[7]);
if ( (strlen(abuf) > 7) && (!strncasecmp(abuf, "::ffff:", 7)) ) {
if (!strcmp(abuf, tbuf)) strcpy(tbuf, &tbuf[7]);
strcpy(abuf, &abuf[7]);
-/*
- * RBL check written by Edward S. Marshall [http://rblcheck.sourceforge.net]
- */
-#define RESULT_SIZE 4096 /* What is the longest result text we support? */
+// RBL check written by Edward S. Marshall [http://rblcheck.sourceforge.net]
+#define RESULT_SIZE 4096 // What is the longest result text we support?
}
len = res_query(domain, C_IN, T_A, answer, PACKETSZ);
}
len = res_query(domain, C_IN, T_A, answer, PACKETSZ);
- /* Make another DNS query for textual data; this shouldn't
- * be a performance hit, since it'll now be cached at the
- * nameserver we're using.
- */
+ // Make another DNS query for textual data; this shouldn't
+ // be a performance hit, since it'll now be cached at the
+ // nameserver we're using.
len = res_query(domain, C_IN, T_TXT, answer, PACKETSZ);
if (server_shutting_down) {
if (txtbuf != NULL) {
len = res_query(domain, C_IN, T_TXT, answer, PACKETSZ);
if (server_shutting_down) {
if (txtbuf != NULL) {
- /* This seems to be a bit of magic data that we need to
- * skip. I wish there were good online documentation
- * for programming for libresolv, so I'd know what I'm
- * skipping here. Anyone reading this, feel free to
- * enlighten me.
- */
+ // This seems to be a bit of magic data that we need to
+ // skip. I wish there were good online documentation
+ // for programming for libresolv, so I'd know what I'm
+ // skipping here. Anyone reading this, feel free to
+ // enlighten me.
- /* Iterate over any multiple answers we might have. In
- * this context, it's unlikely, but anyway.
- */
+ // Iterate over any multiple answers we might have. In
+ // this context, it's unlikely, but anyway.
long len;
len = snprintf(txtbuf, txtbufsize, "%s", result);
long len;
len = snprintf(txtbuf, txtbufsize, "%s", result);
-/*
- * Check to see if the client host is on some sort of spam list (RBL)
- * If spammer, returns nonzero and places reason in 'message_to_spammer'
- */
-int rbl_check(char *cs_addr, char *message_to_spammer)
-{
+// Check to see if the client host is on some sort of spam list (RBL)
+// If spammer, returns nonzero and places reason in 'message_to_spammer'
+int rbl_check(char *cs_addr, char *message_to_spammer) {
safestrncpy(tbuf, cs_addr, sizeof tbuf);
num_colons = haschar(tbuf, ':');
if ((num_colons < 2) || (num_colons > 7))
safestrncpy(tbuf, cs_addr, sizeof tbuf);
num_colons = haschar(tbuf, ':');
if ((num_colons < 2) || (num_colons > 7))
for (rbl=0; rbl<num_rbl; ++rbl) {
extract_token(&tbuf[suffix_pos], rbl_domains, rbl, '|', (sizeof tbuf - suffix_pos));
for (rbl=0; rbl<num_rbl; ++rbl) {
extract_token(&tbuf[suffix_pos], rbl_domains, rbl, '|', (sizeof tbuf - suffix_pos));
gettimeofday(&tx_finish, NULL);
syslog(LOG_WARNING, "rbl: %s [%ld.%06ld] %s",
gettimeofday(&tx_finish, NULL);
syslog(LOG_WARNING, "rbl: %s [%ld.%06ld] %s",
-/*
- * Convert a host name to a dotted quad address.
- * Returns zero on success or nonzero on failure.
- *
- * FIXME this is obviously not IPv6 compatible.
- */
+// Convert a host name to a dotted quad address.
+// Returns zero on success or nonzero on failure.
+//
+// FIXME this is obviously not IPv6 compatible.