-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ use a pool of rotating upstream name servers
- Loading branch information
Showing
8 changed files
with
103 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package dns | ||
|
||
import ( | ||
_ "embed" | ||
"strings" | ||
) | ||
|
||
const maxReqPerResolver = 5 | ||
|
||
//go:embed resolvers.txt | ||
var resolvers string | ||
|
||
type Resolver struct { | ||
resolvers []string | ||
current int | ||
currentRequests int | ||
} | ||
|
||
func (r *Resolver) Get() string { | ||
if r.currentRequests >= maxReqPerResolver { | ||
r.current++ | ||
r.currentRequests = 0 | ||
} | ||
if r.current >= len(r.resolvers) { | ||
r.current = 0 | ||
} | ||
r.currentRequests++ | ||
return r.resolvers[r.current] | ||
} | ||
|
||
func NewResolver() *Resolver { | ||
r := &Resolver{} | ||
for _, line := range strings.Split(resolvers, "\n") { | ||
line = strings.TrimSpace(line) | ||
if line != "" && !strings.HasPrefix(line, "#") { | ||
r.resolvers = append(r.resolvers, line+":53") | ||
} | ||
} | ||
return r | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
8.8.8.8 | ||
8.8.4.4 | ||
|
||
# Quad9 | ||
9.9.9.9 | ||
149.112.112.112 | ||
|
||
# OpenDNS | ||
208.67.222.222 | ||
208.67.220.220 | ||
208.67.222.220 | ||
208.67.220.222 | ||
|
||
# Cloudflare | ||
1.1.1.1 | ||
1.0.0.1 | ||
|
||
# Verisign | ||
64.6.64.6 | ||
64.6.65.6 | ||
|
||
# Level3 | ||
209.244.0.3 | ||
209.244.0.4 | ||
|
||
# HE | ||
74.82.42.42 | ||
|
||
# OpenNIC | ||
216.87.84.211 | ||
23.90.4.6 |