60295b2e97686a0fbc80795070ebd5ae02861ba0
[hcoop/domtool2.git] / lib / easy_domain.dtl
1 {{The most common kinds of domain configuration}}
2
3 val default_node : (node) = "navajos";
4 val web_node : (web_node) = "navajos";
5 val web_ip = ip_of_node (web_node_to_node web_node);
6
7 val webAt =
8 \ n : (web_node) ->
9 \ host : (host) ->
10 \\ config : Vhost -> begin
11 dns (dnsA (literal host) (ip_of_node (web_node_to_node n)));
12
13 vhost host where
14 WebPlaces = [web_place_default n]
15 with
16 config
17 end
18 end;
19
20 val web = \ host -> \\ config : Vhost -> begin
21 n <- DefaultWebNode;
22 webAt n host with config end;
23 end;
24
25 val webAtIp =
26 \ ip : (your_ip) ->
27 \ host : (host) ->
28 \\ config : Vhost -> begin
29 dns (dnsA (literal host) (your_ip_to_ip ip));
30
31 vhost host where
32 WebPlaces = [web_place web_node ip]
33 with
34 config
35 end
36 end;
37
38 val addDefaultAlias = begin
39 mailbox <- Mailbox;
40 defaultAlias mailbox
41 end;
42
43 val addWww = begin
44 web "www" with
45 serverAliasDefault;
46 www : [Vhost] <- WWW;
47 www
48 end
49 end;
50
51 val dom =
52 \ d : (your_domain) ->
53 \\ config : Domain ->
54 domain d with
55 dns (dnsNS "ns1.hcoop.net");
56 dns (dnsNS "ns2.hcoop.net");
57
58 user_web_node <- DefaultWebNode;
59
60 defa : bool <- DefaultA;
61 if defa then
62 dns (dnsA default (ip_of_node (web_node_to_node user_web_node)))
63 else
64 Skip
65 end;
66
67 hmail : bool <- HandleMail;
68 if hmail then
69 handleMail
70 else
71 Skip
72 end;
73
74 amx : bool <- AddMX;
75 if amx then
76 dns (dnsMX 1 "mail.hcoop.net")
77 else
78 Skip
79 end;
80
81 createWWW : bool <- CreateWWW;
82 if createWWW then
83 addWww
84 else
85 Skip
86 end;
87
88 defAl : bool <- DefaultAlias;
89 if defAl then
90 addDefaultAlias
91 else
92 Skip
93 end;
94
95 config
96 end;
97
98 val nameserver = \host -> dns (dnsNS host);
99 val dnsIP = \from -> \to -> dns (dnsA (literal from) to);
100 val dnsIPv6 = \from -> \to -> dns (dnsAAAA (literal from) to);
101 val dnsMail = \num -> \host -> dns (dnsMX num host);
102 val dnsAlias = \from -> \to -> dns (dnsCNAME (literal from) to);
103 val dnsDefault = \to -> dns (dnsA default to);
104 val dnsDefaultv6 = \to -> dns (dnsAAAA default to);
105 val dnsText = \from -> \to -> dns (dnsTXT (srv_literal from) to);
106 val dnsDefaultText = \to -> dns (dnsTXT srv_default to);
107
108 val dnsWildcardIP = \to -> dns (dnsA wildcard to);
109
110 val addDefaultSPF = dnsDefaultText "v=spf1 mx -all";