Mercurial > dnsbl
diff src/dnsbl.cpp @ 177:a4d313c2460b
start embedded dcc filtering
author | carl |
---|---|
date | Sun, 30 Sep 2007 10:27:14 -0700 |
parents | da0c41b9f672 |
children | d6531c702be3 |
line wrap: on
line diff
--- a/src/dnsbl.cpp Sun Sep 23 14:33:00 2007 -0700 +++ b/src/dnsbl.cpp Sun Sep 30 10:27:14 2007 -0700 @@ -7,6 +7,7 @@ Based on a sample milter Copyright (c) 2000-2003 Sendmail, Inc. and its suppliers. Inspired by the DCC by Rhyolite Software +-b port The port used to talk to the dcc interface daemon -r port The port used to talk to our internal dns resolver processes -p port The port through which the MTA will connect to this milter. -t sec The timeout value. @@ -95,6 +96,7 @@ const time_t ERROR_SOCKET_TIME = 60; // number of seconds between attempts to open a socket to the dns resolver process char *resolver_port = NULL; // unix domain socket to talk to the dns resolver process int resolver_socket = NULL_SOCKET; // socket used to listen for resolver requests +char *dccifd_port = NULL; // unix domain socket to talk to the dcc interface daemon time_t last_error_time; int resolver_sock_count = 0; // protected with fd_pool_mutex int resolver_pool_size = 0; // protected with fd_pool_mutex @@ -359,11 +361,11 @@ } } -int mlfiPriv::my_write(char *buf, int len) { +size_t mlfiPriv::my_write(const char *buf, size_t len) { if (err) return 0; - int rs = 0; + size_t rs = 0; while (len) { - int ws = write(fd, buf, len); + size_t ws = write(fd, buf, len); if (ws > 0) { rs += ws; len -= ws; @@ -379,11 +381,11 @@ return rs; } -int mlfiPriv::my_read(char *buf, int len) { +size_t mlfiPriv::my_read(char *buf, size_t len) { if (err) return 0; - int rs = 0; + size_t rs = 0; while (len) { - int ws = read(fd, buf, len); + size_t ws = read(fd, buf, len); if (ws > 0) { rs += ws; len -= ws; @@ -1319,7 +1321,9 @@ void usage(char *prog); void usage(char *prog) { - fprintf(stderr, "Usage: %s [-d [level]] [-c] [-s] [-e from|to] -r port -p sm-sock-addr [-t timeout]\n", prog); + fprintf(stderr, "Usage: %s [-d [level]] [-c] [-s] [-e from|to] [-b dccifd-addr] -r port -p sm-sock-addr [-t timeout]\n", prog); + fprintf(stderr, "where dccifd_addr is for the connection to dccifd\n"); + fprintf(stderr, " and should be local-domain-socket-file-name\n"); fprintf(stderr, "where port is for the connection to our own dns resolver processes\n"); fprintf(stderr, " and should be local-domain-socket-file-name\n"); fprintf(stderr, "where sm-sock-addr is for the connection to sendmail\n"); @@ -1366,12 +1370,20 @@ bool setreso = false; char *email = NULL; int c; - const char *args = "r:p:t:e:d:chs"; + const char *args = "b:r:p:t:e:d:chs"; extern char *optarg; // Process command line options while ((c = getopt(argc, argv, args)) != -1) { switch (c) { + case 'b': + if (optarg == NULL || *optarg == '\0') { + fprintf(stderr, "Illegal dccifd socket: %s\n", optarg); + exit(EX_USAGE); + } + dccifd_port = strdup(optarg); + break; + case 'r': if (optarg == NULL || *optarg == '\0') { fprintf(stderr, "Illegal resolver socket: %s\n", optarg);