Fix serverlist issues
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
68632e9ca3
commit
b0efa7143c
22
.drone.yml
22
.drone.yml
|
@ -18,27 +18,6 @@ steps:
|
||||||
tags:
|
tags:
|
||||||
- amd64-latest
|
- amd64-latest
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: arm64
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: arm64
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: docker
|
|
||||||
image: plugins/docker
|
|
||||||
settings:
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
repo: registry.meow.tf/joker/godns
|
|
||||||
registry: registry.meow.tf
|
|
||||||
tags:
|
|
||||||
- arm64-latest
|
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: manifest
|
name: manifest
|
||||||
|
@ -59,7 +38,6 @@ steps:
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- amd64
|
- amd64
|
||||||
- arm64
|
|
||||||
|
|
||||||
image_pull_secrets:
|
image_pull_secrets:
|
||||||
- dockerconfigjson
|
- dockerconfigjson
|
|
@ -2,3 +2,4 @@
|
||||||
godns
|
godns
|
||||||
godns.log
|
godns.log
|
||||||
etc/godns.conf
|
etc/godns.conf
|
||||||
|
godns.exe
|
2
cache.go
2
cache.go
|
@ -4,8 +4,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/miekg/dns"
|
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
|
"github.com/miekg/dns"
|
||||||
)
|
)
|
||||||
|
|
||||||
type KeyNotFound struct {
|
type KeyNotFound struct {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
"sync"
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MemoryCache struct {
|
type MemoryCache struct {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#Toml config file
|
#Toml config file
|
||||||
title = "GODNS"
|
title = "GODNS"
|
||||||
Version = "0.2.2"
|
Version = "0.2.3"
|
||||||
Author = "kenshin, tystuyfzand"
|
Author = "kenshin, tystuyfzand"
|
||||||
|
|
||||||
debug = false
|
debug = false
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
module godns
|
||||||
|
|
||||||
|
go 1.12
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/BurntSushi/toml v0.3.1
|
||||||
|
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b
|
||||||
|
github.com/caarlos0/env v3.5.0+incompatible
|
||||||
|
github.com/fsnotify/fsnotify v1.4.7
|
||||||
|
github.com/hoisie/redis v0.0.0-20160730154456-b5c6e81454e0
|
||||||
|
github.com/miekg/dns v1.1.18
|
||||||
|
github.com/ryanuber/go-glob v1.0.0
|
||||||
|
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337
|
||||||
|
github.com/stretchr/testify v1.4.0 // indirect
|
||||||
|
)
|
|
@ -0,0 +1,53 @@
|
||||||
|
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||||
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b h1:L/QXpzIa3pOvUGt1D1lA5KjYhPBAN/3iWdP7xeFS9F0=
|
||||||
|
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA=
|
||||||
|
github.com/caarlos0/env v3.5.0+incompatible h1:Yy0UN8o9Wtr/jGHZDpCBLpNrzcFLLM2yixi/rBrKyJs=
|
||||||
|
github.com/caarlos0/env v3.5.0+incompatible/go.mod h1:tdCsowwCzMLdkqRYDlHpZCp2UooDD3MspDBjZ2AD02Y=
|
||||||
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||||
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||||
|
github.com/hoisie/redis v0.0.0-20160730154456-b5c6e81454e0 h1:mjZV3MTu2A5gwfT5G9IIiLGdwZNciyVq5qqnmJJZ2JI=
|
||||||
|
github.com/hoisie/redis v0.0.0-20160730154456-b5c6e81454e0/go.mod h1:pMYMxVaKJqCDC1JUg/XbPJ4/fSazB25zORpFzqsIGIc=
|
||||||
|
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||||
|
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||||
|
github.com/miekg/dns v1.1.18 h1:RP3QrPVgq8fLiw0mjYwVGNaIsCc9MxNFlRHu8PlAeiY=
|
||||||
|
github.com/miekg/dns v1.1.18/go.mod h1:WgzbA6oji13JREwiNsRDNfl7jYdPnmz+VEuLrA+/48M=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk=
|
||||||
|
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
|
||||||
|
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
||||||
|
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||||
|
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 h1:WN9BUFbdyOsSH/XohnWpXOlq9NBD5sGAB2FciQMUEe8=
|
||||||
|
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||||
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 h1:Gv7RPwsi3eZ2Fgewe3CBsuOebPwO27PoXzRpJPsvSSM=
|
||||||
|
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM=
|
||||||
|
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd h1:DBH9mDw0zluJT/R+nGuV3jWFWLFaHyYZWD4tOT+cjn0=
|
||||||
|
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
4
hosts.go
4
hosts.go
|
@ -5,10 +5,10 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hoisie/redis"
|
"github.com/hoisie/redis"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Hosts struct {
|
type Hosts struct {
|
||||||
providers []HostProvider
|
providers []HostProvider
|
||||||
refreshInterval time.Duration
|
refreshInterval time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
|
||||||
"github.com/fsnotify/fsnotify"
|
|
||||||
"strings"
|
|
||||||
"os"
|
|
||||||
"bufio"
|
"bufio"
|
||||||
"regexp"
|
"github.com/fsnotify/fsnotify"
|
||||||
"github.com/ryanuber/go-glob"
|
"github.com/ryanuber/go-glob"
|
||||||
|
"os"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FileHosts struct {
|
type FileHosts struct {
|
||||||
|
|
|
@ -2,9 +2,9 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hoisie/redis"
|
"github.com/hoisie/redis"
|
||||||
"sync"
|
"github.com/ryanuber/go-glob"
|
||||||
"strings"
|
"strings"
|
||||||
"github.com/ryanuber/go-glob"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RedisHosts struct {
|
type RedisHosts struct {
|
||||||
|
@ -19,7 +19,7 @@ type RedisHosts struct {
|
||||||
func NewRedisProvider(rc *redis.Client, key string) HostProvider {
|
func NewRedisProvider(rc *redis.Client, key string) HostProvider {
|
||||||
rh := &RedisHosts{
|
rh := &RedisHosts{
|
||||||
redis: rc,
|
redis: rc,
|
||||||
key: key,
|
key: key,
|
||||||
hosts: make(map[string]string),
|
hosts: make(map[string]string),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ func NewRedisProvider(rc *redis.Client, key string) HostProvider {
|
||||||
go rc.Subscribe(sub, nil, nil, nil, messages)
|
go rc.Subscribe(sub, nil, nil, nil, messages)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
msg := <- messages
|
msg := <-messages
|
||||||
|
|
||||||
if msg.Channel == "godns:update" {
|
if msg.Channel == "godns:update" {
|
||||||
logger.Debug("Refreshing redis records due to update")
|
logger.Debug("Refreshing redis records due to update")
|
||||||
|
@ -89,7 +89,7 @@ func (r *RedisHosts) Get(domain string) ([]string, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if idx := strings.Index(domain, "."); idx != -1 {
|
if idx := strings.Index(domain, "."); idx != -1 {
|
||||||
wildcard := "*." + domain[strings.Index(domain, ".") + 1:]
|
wildcard := "*." + domain[strings.Index(domain, ".")+1:]
|
||||||
|
|
||||||
if ip, ok := r.hosts[wildcard]; ok {
|
if ip, ok := r.hosts[wildcard]; ok {
|
||||||
return strings.Split(ip, ","), true
|
return strings.Split(ip, ","), true
|
||||||
|
|
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -50,6 +51,8 @@ func NewResolver(c ResolvSettings) *Resolver {
|
||||||
|
|
||||||
if len(c.ServerListFile) > 0 {
|
if len(c.ServerListFile) > 0 {
|
||||||
r.ReadServerListFile(c.ServerListFile)
|
r.ReadServerListFile(c.ServerListFile)
|
||||||
|
|
||||||
|
log.Println("Read servers", strings.Join(r.servers, ", "))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(c.ResolvFile) > 0 {
|
if len(c.ResolvFile) > 0 {
|
||||||
|
@ -112,7 +115,7 @@ func (r *Resolver) parseServerListFile(buf *os.File) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
line = strings.TrimSpace(line[idx:])
|
line = strings.TrimSpace(line[idx+1:])
|
||||||
|
|
||||||
if strings.HasPrefix(line, "https://") {
|
if strings.HasPrefix(line, "https://") {
|
||||||
r.servers = append(r.servers, line)
|
r.servers = append(r.servers, line)
|
||||||
|
|
20
server.go
20
server.go
|
@ -6,7 +6,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
host string
|
host string
|
||||||
|
@ -29,19 +29,19 @@ func (s *Server) Run() {
|
||||||
udpHandler.HandleFunc(".", handler.DoUDP)
|
udpHandler.HandleFunc(".", handler.DoUDP)
|
||||||
|
|
||||||
tcpServer := &dns.Server{
|
tcpServer := &dns.Server{
|
||||||
Addr: s.Addr(),
|
Addr: s.Addr(),
|
||||||
Net: "tcp",
|
Net: "tcp",
|
||||||
Handler: tcpHandler,
|
Handler: tcpHandler,
|
||||||
ReadTimeout: s.rTimeout,
|
ReadTimeout: s.rTimeout,
|
||||||
WriteTimeout: s.wTimeout,
|
WriteTimeout: s.wTimeout,
|
||||||
}
|
}
|
||||||
|
|
||||||
udpServer := &dns.Server{
|
udpServer := &dns.Server{
|
||||||
Addr: s.Addr(),
|
Addr: s.Addr(),
|
||||||
Net: "udp",
|
Net: "udp",
|
||||||
Handler: udpHandler,
|
Handler: udpHandler,
|
||||||
UDPSize: 65535,
|
UDPSize: 65535,
|
||||||
ReadTimeout: s.rTimeout,
|
ReadTimeout: s.rTimeout,
|
||||||
WriteTimeout: s.wTimeout,
|
WriteTimeout: s.wTimeout,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue