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