masqmail

annotate src/resolvtest.c @ 373:4cab237ce923

Fixed bug in matching of allowed recipients. Thanks to Juergen Daubert for finding and reporting the issue. The code had evaluated completely different data ...
author markus schnalke <meillo@marmaro.de>
date Sat, 14 Jan 2012 11:47:57 +0100
parents 116b0269c934
children
rev   line source
meillo@367 1 /*
meillo@367 2 ** MasqMail
meillo@367 3 ** Copyright (C) Oliver Kurth,
meillo@367 4 ** Copyright (C) 2010 markus schnalke <meillo@marmaro.de>
meillo@367 5 **
meillo@367 6 ** This program is free software; you can redistribute it and/or modify
meillo@367 7 ** it under the terms of the GNU General Public License as published by
meillo@367 8 ** the Free Software Foundation; either version 2 of the License, or
meillo@367 9 ** (at your option) any later version.
meillo@367 10 **
meillo@367 11 ** This program is distributed in the hope that it will be useful,
meillo@367 12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
meillo@367 13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
meillo@367 14 ** GNU General Public License for more details.
meillo@367 15 **
meillo@367 16 ** You should have received a copy of the GNU General Public License
meillo@367 17 ** along with this program; if not, write to the Free Software
meillo@367 18 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
meillo@367 19 */
meillo@200 20
meillo@200 21
meillo@200 22 #include <sys/types.h>
meillo@200 23 #include <netinet/in.h>
meillo@200 24 #include <arpa/nameser.h>
meillo@200 25 #include <resolv.h>
meillo@200 26
meillo@200 27 #include "masqmail.h"
meillo@200 28
meillo@200 29
meillo@200 30 masqmail_conf conf;
meillo@200 31
meillo@200 32
meillo@200 33 void
meillo@200 34 debugf(const char *fmt, ...)
meillo@200 35 {
meillo@200 36 va_list args;
meillo@200 37 va_start(args, fmt);
meillo@200 38
meillo@200 39 vfprintf(stdout, fmt, args);
meillo@200 40
meillo@200 41 va_end(args);
meillo@200 42
meillo@200 43 }
meillo@200 44
meillo@200 45
meillo@200 46 int
meillo@200 47 main(int argc, char *argv[])
meillo@200 48 {
meillo@200 49 GList *addr_list = NULL, *node;
meillo@200 50
meillo@200 51 conf.debug_level = -1; /* no debug messages */
meillo@200 52
meillo@200 53 if (argc != 2) {
meillo@200 54 fprintf(stderr, "usage: resolvtest HOSTNAME\n");
meillo@200 55 return 1;
meillo@200 56 }
meillo@200 57
meillo@200 58 if (res_init() != 0) {
meillo@200 59 printf("res_init() failed.\n");
meillo@200 60 return 1;
meillo@200 61 }
meillo@200 62
meillo@200 63 printf("A:\n");
meillo@200 64 addr_list = resolve_dns_a(NULL, argv[1]);
meillo@200 65 foreach(addr_list, node) {
meillo@200 66 mxip_addr *p_mxip = (mxip_addr *) (node->data);
meillo@200 67 printf("%s \t%s\n", p_mxip->name, inet_ntoa(*(struct in_addr *) &(p_mxip->ip)));
meillo@200 68 }
meillo@200 69
meillo@200 70 printf("\nMX:\n");
meillo@200 71 addr_list = resolve_dns_mx(NULL, argv[1]);
meillo@200 72 foreach(addr_list, node) {
meillo@200 73 mxip_addr *p_mxip = (mxip_addr *) (node->data);
meillo@200 74 printf("%s \t%s %d\n", p_mxip->name,
meillo@200 75 inet_ntoa(*(struct in_addr *) &(p_mxip->ip)), p_mxip->pref);
meillo@200 76 }
meillo@200 77
meillo@200 78 printf("\nIP resolved directly (assumed FQDN, no default domain added):\n");
meillo@200 79 {
meillo@200 80 guint32 ip;
meillo@200 81 if (dns_look_ip(argv[1], &ip) >= 0) {
meillo@200 82 printf("%s\n", inet_ntoa(*((struct in_addr *) (&ip))));
meillo@200 83 }
meillo@200 84 }
meillo@200 85
meillo@200 86 return 0;
meillo@200 87 }