-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathldnsbash.c
More file actions
38 lines (30 loc) · 979 Bytes
/
ldnsbash.c
File metadata and controls
38 lines (30 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <loadables.h>
#include <ldns/ldns.h>
/* The builtin function */
int ldnsbash_builtin(list) WORD_LIST *list;
{
ldns_pkt *p;
ldns_resolver *res;
ldns_status s = ldns_resolver_new_frm_file(&res, "/tmp/ldns.conf");
ldns_rdf *qry = ldns_dname_new_frm_str("whoami.cloudflare");
ldns_resolver_set_retry(res, 1);
p = ldns_resolver_query(res, qry, LDNS_RR_TYPE_TXT, LDNS_RR_CLASS_CH, LDNS_RD);
/* bind to a bash global variable called $LDNSBASH */
if(p) bind_global_variable("LDNSBASH", ldns_pkt2str(p), 0);
ldns_rdf_deep_free(ldns_resolver_pop_nameserver(res));
ldns_resolver_deep_free(res);
return 0;
}
/* Tell bash what to do when loading the builtin */
int ldnsbash_builtin_load(name) char *name; { return 1; }
/* Tell bash what to do when unloading the builtin */
void ldnsbash_builtin_unload(name) char *name; {}
/* Options for bash */
struct builtin ldnsbash_struct = {
"ldnsbash",
ldnsbash_builtin,
BUILTIN_ENABLED,
NULL,
"ldnsbash",
0
};