djbdnscurve6 53
djbdnscurve6
Loading...
Searching...
No Matches
serverok.c
Go to the documentation of this file.
1#include <sys/types.h>
2#include <sys/stat.h>
3#include "byte.h"
4#include "stralloc.h"
5#include "serverok.h"
6#include "ip.h"
7#include "query.h"
8
9static char fnserver[4 + IPFMT];
10static char fncurve[4 + IPFMT];
11static char fnedns0[4 + IPFMT];
12static char fnctxtq[4 + IPFMT];
13
14/* To invoke 'serverok' $FLAGSERVER has to be set!
15
16 -1 no curve server
17 -2 toggle DNSCurve native/txt format (flagusetxtformat)
18 1 omitt server
19 2 toggle EDNS0 option (flagedns0)
20*/
21
22int serverok(char ip[16])
23{
24 struct stat st;
25
26 fnserver[0] = fncurve[0] = fnctxtq[0] = fnedns0[0] = 'i';
27 fnserver[1] = fncurve[1] = fnctxtq[1] = fnedns0[1] = 'p';
28 fnserver[2] = fncurve[2] = fnctxtq[2] = fnedns0[2] = '/';
29
30 fnserver[3] = '%'; // ommit NS (commented out)
31 fncurve[3] = '-'; // no DNSCurve NS, + => DNSCurve, - => std
32 fnctxtq[3] = '*'; // toggle $USETXTFORMAT (DNSCurve only)
33 fnedns0[3] = '~'; // toggle $DNSOPTRR (EDNS0)
34
35 if (byte_equal(ip,12,V4mappedprefix)) {
36 fnserver[4 + ip4_fmt(fnserver + 4,ip + 12)] = 0;
37 fncurve[4 + ip4_fmt(fncurve + 4,ip + 12)] = 0;
38 fnedns0[4 + ip4_fmt(fnedns0 + 4,ip + 12)] = 0;
39 fnctxtq[4 + ip4_fmt(fnctxtq + 4,ip + 12)] = 0;
40 } else {
41 fnserver[4 + ip6_fmt(fnserver + 4,ip)] = 0;
42 fncurve[4 + ip6_fmt(fncurve + 4,ip)] = 0;
43 fnedns0[4 + ip6_fmt(fnedns0 + 4,ip)] = 0;
44 fnctxtq[4 + ip6_fmt(fnctxtq + 4,ip)] = 0;
45 }
46
47 if (stat(fnedns0,&st) == 0) return 2;
48 if (stat(fnserver,&st) == 0) return 1;
49 if (stat(fncurve,&st) == 0) return -1;
50 if (stat(fnctxtq,&st) == 0) return -2;
51
52 return 0;
53}
char ip[16]
Definition: axfrdns.c:128
int serverok(char ip[16])
Definition: serverok.c:22