-
Notifications
You must be signed in to change notification settings - Fork 1
/
zonesign.c
69 lines (64 loc) · 2 KB
/
zonesign.c
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#define _LARGEFILE64_SOURCE
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ldns/ldns.h>
#include "uthash.h"
#include "proto.h"
#pragma GCC optimize ("O0")
void
prepare(names_view_type view, int newserial)
{
dictionary record;
struct dual changex;
struct dual* change;
change = &changex;
names_iterator iter;
for (iter=neighbors(view); names_iterate(&iter,&changex); names_advance(&iter,NULL)) {
assert(change->src != change->dst);
record = change->dst;
if(names_recordhasexpiry(record)) {
names_recordsetvalidupto(record, newserial);
names_own(view, &record);
names_recordsetvalidfrom(record, newserial);
}
}
for (iter=noexpiry(view); names_iterate(&iter,&changex); names_advance(&iter,NULL)) {
assert(change->src != change->dst);
if(change->src && !names_recordhasvalidupto(change->src)) {
names_amend(view, change->src);
names_recordsetvalidupto(change->src, newserial);
}
if(!names_recordhasvalidfrom(change->dst)) {
if(names_recordhasdata(change->dst, 0, NULL, 0)) {
names_amend(view, change->dst);
names_recordsetvalidfrom(change->dst, newserial);
} else {
names_remove(view, change->dst);
}
}
}
}
void
sign(names_view_type view, const char* apex)
{
dictionary domain;
names_iterator iter;
struct signconf* signconf;
signconf = createsignconf(1);
locatekeysignconf(signconf, 0, "Kexample.+008+24693.private", 0);
setupsignconf(signconf);
for(iter=expiring(view); names_iterate(&iter,&domain); names_advance(&iter,NULL)) {
names_amend(view, domain);
signrecord(signconf, domain, apex);
names_recordsetexpiry(domain, 1);
}
teardownsignconf(signconf);
destroysignconf(signconf);
}