diff options
author | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-03 15:48:04 +0200 |
---|---|---|
committer | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-03 15:48:04 +0200 |
commit | 89b7b67a13ebb7965cc7f13ad0595e2194a2d34c (patch) | |
tree | 25efd77a90ae87236e6730d8ea3846bbe0fd126f /src/dnsptr.c |
add sqmail-4.2.29asqmail-4.2
Diffstat (limited to 'src/dnsptr.c')
-rw-r--r-- | src/dnsptr.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/dnsptr.c b/src/dnsptr.c new file mode 100644 index 0000000..25a4731 --- /dev/null +++ b/src/dnsptr.c @@ -0,0 +1,37 @@ +#include <unistd.h> +#include "buffer.h" +#include "stralloc.h" +#include "str.h" +#include "dnsresolv.h" +#include "dns.h" +#include "ip.h" +#include "exit.h" +#include "logmsg.h" + +#define WHO "dnsptr" + +stralloc out = {0}; +char ip4[4]; +char ip6[16]; + +int main(int argc,char **argv) +{ + if (!argv[1]) + logmsg(WHO,100,USAGE,"dnsptr ipv4 || ipv6 (compactified)"); + + DNS_INIT + if (str_chr(argv[1],':') < str_len(argv[1])) { + if (!ip6_scan(argv[1],ip6)) + logmsg(WHO,111,FATAL,"wrong IPv6 format"); + if (dns_name6(&out,ip6) > 0) + buffer_put(buffer_1,out.s,out.len); + } else { + if (!ip4_scan(argv[1],ip4)) + logmsg(WHO,111,FATAL,"wrong IPv4 format"); + if (dns_name4(&out,ip4) > 0) + buffer_put(buffer_1,out.s,out.len); + } + buffer_putsflush(buffer_1,"\n"); + + _exit(0); +} |