From 6eeb3bf97e57bb0f4d0942b9dd436eeb493c1e9f Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Thu, 17 May 2007 20:23:52 +0000 Subject: [PATCH] Add default DNS mappings --- lib/bind.dtl | 2 ++ lib/easy_domain.dtl | 3 +++ src/plugins/bind.sml | 9 +++++++++ 3 files changed, 14 insertions(+) diff --git a/lib/bind.dtl b/lib/bind.dtl index 69612d0..4f2c3c8 100644 --- a/lib/bind.dtl +++ b/lib/bind.dtl @@ -7,4 +7,6 @@ extern val dnsCNAME : host -> domain -> dnsRecord; extern val dnsMX : int -> domain -> dnsRecord; extern val dnsNS : domain -> dnsRecord; +extern val dnsDefaultA : ip -> dnsRecord; + extern val dns : dnsRecord -> [Domain] {TTL : int}; diff --git a/lib/easy_domain.dtl b/lib/easy_domain.dtl index 6025008..0b4027d 100644 --- a/lib/easy_domain.dtl +++ b/lib/easy_domain.dtl @@ -1,5 +1,6 @@ {{The most common kinds of domain configuration}} +val default_node : (node) = "mire"; val web_node : (web_node) = "mire"; val webAt = @@ -23,6 +24,8 @@ val dom = dns (dnsNS "deleuze.hcoop.net"); dns (dnsNS "mire.hcoop.net"); + dns (dnsDefaultA (ip_of_node default_node)); + handleMail; mailbox <- Mailbox; catchAllAlias mailbox; diff --git a/src/plugins/bind.sml b/src/plugins/bind.sml index 5ba7fed..b6a07b6 100644 --- a/src/plugins/bind.sml +++ b/src/plugins/bind.sml @@ -49,6 +49,7 @@ datatype dns_record = | CNAME of string * string | MX of int * string | NS of string + | DefaultA of string val record = fn (EApp ((EApp ((EVar "dnsA", _), e1), _), e2), _) => (case (Env.string e1, Domain.ip e2) of @@ -64,6 +65,8 @@ val record = fn (EApp ((EApp ((EVar "dnsA", _), e1), _), e2), _) => | _ => NONE) | (EApp ((EVar "dnsNS", _), e), _) => Option.map NS (Env.string e) + | (EApp ((EVar "dnsDefaultA", _), e), _) => + Option.map DefaultA (Env.string e) | _ => NONE fun writeRecord (evs, r) = @@ -84,6 +87,12 @@ fun writeRecord (evs, r) = write "\tIN\tA\t"; write to; write "\n") + | DefaultA to => (writeDom (); + write ".\t"; + write (Int.toString ttl); + write "\tIN\tA\t"; + write to; + write "\n") | CNAME (from, to) => (write from; write "."; writeDom (); -- 2.20.1