summaryrefslogtreecommitdiffstats
path: root/main/augeas/0001-Dnsmasq-add-structure-to-address-and-server-options.patch
blob: 941c8c51daf00384a1c48b0ec68a8e4a9be742af (plain)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
From f52aea2430e31d39c6b454d3387bae8cb62fa02d Mon Sep 17 00:00:00 2001
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Date: Mon, 16 Jun 2014 15:15:55 +0300
Subject: [PATCH] Dnsmasq: add structure to 'address' and 'server' options

This is a backwards incompatible change.
---
 lenses/dnsmasq.aug            | 34 ++++++++++++++++++++++---------
 lenses/tests/test_dnsmasq.aug | 47 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 9 deletions(-)

diff --git a/lenses/dnsmasq.aug b/lenses/dnsmasq.aug
index e19aab8..78ae23a 100644
--- a/lenses/dnsmasq.aug
+++ b/lenses/dnsmasq.aug
@@ -17,26 +17,42 @@ module Dnsmasq =
  *                           USEFUL PRIMITIVES
  *************************************************************************)
 
-let eol        = Util.eol
-let spc        = Util.del_ws_spc
-let comment    = Util.comment
-let empty      = Util.empty
+let eol          = Util.eol
+let spc          = Util.del_ws_spc
+let comment      = Util.comment
+let empty        = Util.empty
 
-let sep_eq     = del /=/ "="
-let sto_to_eol = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+let sep_eq       = Sep.equal
+let sto_to_eol   = store /([^ \t\n].*[^ \t\n]|[^ \t\n])/
+
+let slash        = Util.del_str "/"
+let sto_no_slash = store /([^\/ \t\n]+)/
+let domains      = slash . [ label "domain" . sto_no_slash . slash ]+
 
 (************************************************************************
- *                               ENTRIES
+ *                            SIMPLE ENTRIES
  *************************************************************************)
 
-let entry_re   = /[A-Za-z0-9._-]+/
+let entry_re   = Rx.word - /(address|server)/
 let entry      = [ key entry_re . (sep_eq . sto_to_eol)? . eol ]
 
 (************************************************************************
+ *                          STRUCTURED ENTRIES
+ *************************************************************************)
+
+let address       = [ key "address" . sep_eq . domains . sto_no_slash . eol ]
+
+let server        =
+     let port     = [ Build.xchgs "#" "port" . store Rx.integer ]?
+  in let source   = [ Build.xchgs "@" "source" . store /[^#\/ \t\n]+/ . port ]?
+  in let srv_spec = ( store /(#|([^#@\/ \t\n]+))/ . port . source )?
+  in [ key "server" . sep_eq . domains? . srv_spec . eol ]
+
+(************************************************************************
  *                                LENS
  *************************************************************************)
 
-let lns = (comment|empty|entry) *
+let lns = (comment|empty|address|server|entry) *
 
 let filter            = incl "/etc/dnsmasq.conf"
                       . incl "/etc/dnsmasq.d/*"
diff --git a/lenses/tests/test_dnsmasq.aug b/lenses/tests/test_dnsmasq.aug
index 0abfa6b..c6a63d9 100644
--- a/lenses/tests/test_dnsmasq.aug
+++ b/lenses/tests/test_dnsmasq.aug
@@ -6,6 +6,16 @@ let conf = "# Configuration file for dnsmasq.
 
 conf-dir=/etc/dnsmasq.d
 selfmx
+
+address=/foo.com/bar.net/10.1.2.3
+
+server=10.4.5.6#1234
+server=/bar.com/foo.net/10.7.8.9
+server=/foo.org/bar.org/10.3.2.1@eth0#5678
+server=/baz.org/#
+server=/baz.net/#@eth1
+server=10.6.5.4#1234@eth0#5678
+server=/qux.com/qux.net/
 "
 
 test Dnsmasq.lns get conf =
@@ -15,3 +25,40 @@ test Dnsmasq.lns get conf =
   {}
   { "conf-dir" = "/etc/dnsmasq.d" }
   { "selfmx" }
+  {}
+  { "address" = "10.1.2.3"
+    { "domain" = "foo.com" }
+    { "domain" = "bar.net" }
+  }
+  {}
+  { "server" = "10.4.5.6"
+    { "port" = "1234" }
+  }
+  { "server" = "10.7.8.9"
+    { "domain" = "bar.com" }
+    { "domain" = "foo.net" }
+  }
+  { "server" = "10.3.2.1"
+    { "domain" = "foo.org" }
+    { "domain" = "bar.org" }
+    { "source" = "eth0"
+      { "port" = "5678" }
+    }
+  }
+  { "server" = "#"
+    { "domain" = "baz.org" }
+  }
+  { "server" = "#"
+    { "domain" = "baz.net" }
+    { "source" = "eth1" }
+  }
+  { "server" = "10.6.5.4"
+    { "port" = "1234" }
+    { "source" = "eth0"
+      { "port" = "5678" }
+    }
+  }
+  { "server"
+    { "domain" = "qux.com" }
+    { "domain" = "qux.net" }
+  }
-- 
1.8.3.1