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
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/* ISC license. */
#include <stdint.h>
#include "shibari-cache-config-internal.h"
struct defaults_s
{
char const *key ;
char const *value ;
uint32_t vlen ;
} ;
#define REC(k, v, n) { .key = (k), .value = (v), .vlen = (n) }
#define RECS(k, v) REC(k, (v), sizeof(v))
#define RECU32(k, u) { .key = (k), .value = (char const [4]){ (u) >> 24 & 0xffu, (u) >> 16 & 0xffu, (u) >> 8 & 0xffu, (u) & 0xffu }, .vlen = 4 }
static struct defaults_s const defaults[] =
{
RECU32("G:logv", 1),
RECU32("G:maxtcp", 256),
REC("G:listen4", "\177\0\0\1", 4),
REC("G:listen6", "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1", 16),
REC("R4:",
"\0\306\51\0\4"
"\0\252\367\252\2"
"\0\300\41\4\14"
"\0\307\7\133\15"
"\0\300\313\346\12"
"\0\300\5\5\361"
"\0\300\160\44\4"
"\0\306\141\276\65"
"\0\300\44\224\21"
"\0\300\72\200\36"
"\0\301\0\16\201"
"\0\307\7\123\52"
"\0\312\14\33\41"
, 65),
REC("R6:",
"\0\40\1\5\3\272\76\0\0\0\0\0\0\0\2\0\60"
"\0\50\1\1\270\0\20\0\0\0\0\0\0\0\0\0\13"
"\0\40\1\5\0\0\2\0\0\0\0\0\0\0\0\0\14"
"\0\40\1\5\0\0\55\0\0\0\0\0\0\0\0\0\15"
"\0\40\1\5\0\0\250\0\0\0\0\0\0\0\0\0\16"
"\0\40\1\5\0\0\57\0\0\0\0\0\0\0\0\0\17"
"\0\40\1\5\0\0\22\0\0\0\0\0\0\0\0\15\15"
"\0\40\1\5\0\0\1\0\0\0\0\0\0\0\0\0\123"
"\0\40\1\7\376\0\0\0\0\0\0\0\0\0\0\0\123"
"\0\40\1\5\3\14\47\0\0\0\0\0\0\0\2\0\60"
"\0\40\1\7\375\0\0\0\0\0\0\0\0\0\0\0\1"
"\0\40\1\5\0\0\237\0\0\0\0\0\0\0\0\0\102"
"\0\40\1\15\303\0\0\0\0\0\0\0\0\0\0\0\65"
, 221),
REC(0, 0, 0)
} ;
void conf_defaults (void)
{
{
size_t n = genalloc_len(node, &conf.list) ;
for (size_t i = 0 ; i < n ; i++)
if (conf.storage.s[genalloc_s(node, &conf.list)[i].key.left] == 'A') goto cont ;
}
{
node *nod = repo_searchs(&conf, "G:listen4") ;
if (!nod) nod = repo_searchs(&conf, "G:listen6") ;
if (!nod)
{
repo_add_new(&conf, "A4:\b\177\0\0\1", 8, "", 0, 0, 0) ;
repo_add_new(&conf, "A6:\200\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1", 20, "", 0, 0, 0) ;
}
else strerr_warnw1x("listen directives without accept directives") ;
}
cont:
for (struct defaults_s const *p = defaults ; p->key ; p++)
if (!repo_searchs(&conf, p->key))
repo_adds_new(&conf, p->key, p->value, p->vlen, 0, 0) ;
}
|