Skip to content

Commit

Permalink
Add support for user name password
Browse files Browse the repository at this point in the history
  • Loading branch information
gabber12 committed Aug 14, 2024
1 parent 6f4952c commit 7a44ac6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 27 deletions.
19 changes: 2 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ make
drovedns {
endpoint [URL]
accesstoken [TOKEN]
user [USERNAME]
pass [PASSWORD]
user_pass [USERNAME] [PASSWORD]
skip_ssl_check
}
~~~
Expand Down Expand Up @@ -83,25 +82,12 @@ example.drove.gateway.com {

## Docker
Docker image containing coredns compiled with the plugin are available on ghcr.
<<<<<<< HEAD
~~ bash
=======

~~~ bash
>>>>>>> 276fcdd (Add Docker support)
docker run -p1053:1053/udp -p1053:1053 \
-e DROVE_ENDPOINT="https://drovecontrol001.exmaple.com:8080,https://drovecontrol002.exmaple.com:8080,https://drovecontrol003.exmaple.com:8080" \
-e DROVE_ACCESS_TOKEN="Bearer <token>" \
-e DROVE_USERNAME="<USERNAME>" -e DROVE_PASSWORD="<PASSWORD>" \
-it ghcr.io/phonepe/coredns-drove:<VERSION>
<<<<<<< HEAD
~~
Alternatively you can provide your own Corefile
~~ bash
docker run -p1053:1053/udp -p1053:1053 \
-v /path/to/Corefile:/opt/Corefile \
-it ghcr.io/phonepe/coredns-drove:<VERSION>
~~
=======
~~~

Alternatively you can provide your own Corefile
Expand All @@ -111,7 +97,6 @@ docker run -p1053:1053/udp -p1053:1053 \
-v /path/to/Corefile:/opt/Corefile \
-it ghcr.io/phonepe/coredns-drove:<VERSION>
~~~
>>>>>>> 276fcdd (Add Docker support)

## Also See

Expand Down
1 change: 1 addition & 0 deletions cmd/coredns/Corefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
drove {
endpoint {$DROVE_ENDPOINT}
access_token {$DROVE_ACCESS_TOKEN}
user_pass {$DROVE_USERNAME} {$DROVE_PASSWORD}
skip_ssl_check
}
}
13 changes: 3 additions & 10 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ func (e *DroveHandler) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dn
if e.DroveEndpoints.getApps() == nil {
return dns.RcodeServerFailure, fmt.Errorf("Drove DNS not ready")
}
if len(r.Question) == 0 {
return plugin.NextOrFailure(e.Name(), e.Next, ctx, w, r)
}
app := e.DroveEndpoints.searchApps(r.Question[0].Name)
if app != nil {
ips := iplist(app.Hosts)

a.SetReply(r)
a.Authoritative = true

state := request.Request{W: w, Req: r}

log.Debugf("IPS %+v", ips[0])
srv := make([]dns.RR, len(app.Hosts))

for i, h := range app.Hosts {
Expand Down Expand Up @@ -71,14 +72,6 @@ func (e *DroveHandler) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dn
return plugin.NextOrFailure(e.Name(), e.Next, ctx, w, r)
}

func iplist(res []DroveServiceHost) []string {
ips := make([]string, len(res))
for i, inst := range res {
ips[i] = inst.Host
}
return ips
}

// Name implements the Handler interface.
type CombiningResponseWriter struct {
dns.ResponseWriter
Expand Down

0 comments on commit 7a44ac6

Please sign in to comment.