Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Acme Dns
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
t-personal
Acme Dns
Commits
f64de035
Unverified
Commit
f64de035
authored
Dec 13, 2018
by
Joona Hoikkala
Committed by
GitHub
Dec 13, 2018
Browse files
Options
Downloads
Patches
Plain Diff
Fix Docker instructions and add option to bind both UDP and TCP DNS listeners (#130)
parent
20411b65
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
Dockerfile
+1
-0
1 addition, 0 deletions
Dockerfile
README.md
+7
-2
7 additions, 2 deletions
README.md
config.cfg
+5
-4
5 additions, 4 deletions
config.cfg
docker-compose.yml
+1
-0
1 addition, 0 deletions
docker-compose.yml
main.go
+23
-5
23 additions, 5 deletions
main.go
main_test.go
+1
-1
1 addition, 1 deletion
main_test.go
with
38 additions
and
12 deletions
Dockerfile
+
1
−
0
View file @
f64de035
...
...
@@ -19,3 +19,4 @@ RUN apk --no-cache add ca-certificates && update-ca-certificates
VOLUME
["/etc/acme-dns", "/var/lib/acme-dns"]
ENTRYPOINT
["./acme-dns"]
EXPOSE
53 80 443
EXPOSE
53/udp
This diff is collapsed.
Click to expand it.
README.md
+
7
−
2
View file @
f64de035
...
...
@@ -149,6 +149,7 @@ See the INSTALL section for information on how to do this.
```
docker run --rm --name acmedns
\
-p 53:53
\
-p 53:53/udp
\
-p 80:80
\
-v /path/to/your/config:/etc/acme-dns:ro
\
-v /path/to/your/data:/var/lib/acme-dns
\
...
...
@@ -216,8 +217,8 @@ $ dig @auth.example.org d420c923-bbd7-4056-ab64-c3ca54c9b3cf.auth.example.org
# In this case acme-dns will error out and you will need to define the listening interface
# for example: listen = "127.0.0.1:53"
listen = ":53"
# protocol, "udp", "udp4", "udp6" or "tcp", "tcp4", "tcp6"
protocol = "
udp
"
# protocol,
"both", "both4", "both6",
"udp", "udp4", "udp6" or "tcp", "tcp4", "tcp6"
protocol = "
both
"
# domain name to serve the requests off of
domain = "auth.example.org"
# zone name server
...
...
@@ -300,6 +301,10 @@ logformat = "text"
## Changelog
- master
- Changed
- A new protocol selection for DNS server "both", that binds both - UDP and TCP ports.
- v0.6
- New
- Command line flag `-c` to specify location of config file.
...
...
This diff is collapsed.
Click to expand it.
config.cfg
+
5
−
4
View file @
f64de035
...
...
@@ -2,9 +2,9 @@
# DNS interface. Note that systemd-resolved may reserve port 53 on 127.0.0.53
# In this case acme-dns will error out and you will need to define the listening interface
# for example: listen = "127.0.0.1:53"
listen
=
":53"
# protocol, "udp", "udp4", "udp6" or "tcp", "tcp4", "tcp6"
protocol
=
"
udp
"
listen
=
"
127.0.0.1
:53"
# protocol,
"both", "both4", "both6",
"udp", "udp4", "udp6" or "tcp", "tcp4", "tcp6"
protocol
=
"
both
"
# domain name to serve the requests off of
domain
=
"auth.example.org"
# zone name server
...
...
@@ -26,7 +26,8 @@ debug = false
engine
=
"sqlite3"
# Connection string, filename for sqlite3 and postgres://$username:$password@$host/$db_name for postgres
# Please note that the default Docker image uses path /var/lib/acme-dns/acme-dns.db for sqlite3
connection
=
"/var/lib/acme-dns/acme-dns.db"
#connection = "/var/lib/acme-dns/acme-dns.db"
connection
=
"acme-dns.db"
# connection = "postgres://user:password@localhost/acmedns_db"
[api]
...
...
This diff is collapsed.
Click to expand it.
docker-compose.yml
+
1
−
0
View file @
f64de035
...
...
@@ -8,6 +8,7 @@ services:
ports
:
-
"
443:443"
-
"
53:53"
-
"
53:53/udp"
-
"
80:80"
volumes
:
-
./config:/etc/acme-dns:ro
...
...
This diff is collapsed.
Click to expand it.
main.go
+
23
−
5
View file @
f64de035
...
...
@@ -8,6 +8,7 @@ import (
stdlog
"log"
"net/http"
"os"
"strings"
"syscall"
"github.com/julienschmidt/httprouter"
...
...
@@ -60,8 +61,25 @@ func main() {
errChan
:=
make
(
chan
error
,
1
)
// DNS server
dnsServer
:=
setupDNSServer
()
if
strings
.
HasPrefix
(
Config
.
General
.
Proto
,
"both"
)
{
// Handle the case where DNS server should be started for both udp and tcp
udpProto
:=
"udp"
tcpProto
:=
"tcp"
if
strings
.
HasSuffix
(
Config
.
General
.
Proto
,
"4"
)
{
udpProto
+=
"4"
tcpProto
+=
"4"
}
else
if
strings
.
HasSuffix
(
Config
.
General
.
Proto
,
"6"
)
{
udpProto
+=
"6"
tcpProto
+=
"6"
}
dnsServerUDP
:=
setupDNSServer
(
udpProto
)
dnsServerTCP
:=
setupDNSServer
(
tcpProto
)
go
startDNS
(
dnsServerUDP
,
errChan
)
go
startDNS
(
dnsServerTCP
,
errChan
)
}
else
{
dnsServer
:=
setupDNSServer
(
Config
.
General
.
Proto
)
go
startDNS
(
dnsServer
,
errChan
)
}
// HTTP API
go
startHTTPAPI
(
errChan
)
...
...
@@ -79,15 +97,15 @@ func main() {
func
startDNS
(
server
*
dns
.
Server
,
errChan
chan
error
)
{
// DNS server part
dns
.
HandleFunc
(
"."
,
handleRequest
)
log
.
WithFields
(
log
.
Fields
{
"addr"
:
Config
.
General
.
Listen
})
.
Info
(
"Listening DNS"
)
log
.
WithFields
(
log
.
Fields
{
"addr"
:
Config
.
General
.
Listen
,
"proto"
:
server
.
Net
})
.
Info
(
"Listening DNS"
)
err
:=
server
.
ListenAndServe
()
if
err
!=
nil
{
errChan
<-
err
}
}
func
setupDNSServer
()
*
dns
.
Server
{
return
&
dns
.
Server
{
Addr
:
Config
.
General
.
Listen
,
Net
:
Config
.
General
.
P
roto
}
func
setupDNSServer
(
proto
string
)
*
dns
.
Server
{
return
&
dns
.
Server
{
Addr
:
Config
.
General
.
Listen
,
Net
:
p
roto
}
}
func
startHTTPAPI
(
errChan
chan
error
)
{
...
...
This diff is collapsed.
Click to expand it.
main_test.go
+
1
−
1
View file @
f64de035
...
...
@@ -43,7 +43,7 @@ func TestMain(m *testing.M) {
_
=
newDb
.
Init
(
"sqlite3"
,
":memory:"
)
}
DB
=
newDb
server
:=
setupDNSServer
()
server
:=
setupDNSServer
(
"udp"
)
// Make sure that we're not creating a race condition in tests
var
wg
sync
.
WaitGroup
wg
.
Add
(
1
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment