Skip to content

Commit

Permalink
proxy: imp docs
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Dec 14, 2021
1 parent f25b898 commit b4d5393
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ A simple DNS proxy server that supports all existing DNS protocols including `DN

## How to build

You will need go v1.16 or later.
You will need Go v1.16 or later.

```shell
$ go build -mod=vendor
Expand Down
10 changes: 6 additions & 4 deletions proxy/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func genSOA(request *dns.Msg, retry uint32) []dns.RR {
return []dns.RR{&soa}
}

// parseECS parses ECS option from m.
// parseECS parses the EDNS client subnet option from m.
func parseECS(m *dns.Msg) (addr net.IP, mask uint8, scope uint8) {
opt := m.IsEdns0()
if opt == nil {
Expand All @@ -92,15 +92,17 @@ func parseECS(m *dns.Msg) (addr net.IP, mask uint8, scope uint8) {
return nil, 0, 0
}

// setECS sets EDNS client subnet option into m. It returns masked IP and mask
// length.
// setECS sets the EDNS client subnet option based on ip and scope into m. It
// returns masked IP and mask length.
func setECS(m *dns.Msg, ip net.IP, scope uint8) (net.IP, uint8) {
const (
// defaultECSv4 is the default length of network mask for IPv4 address
// in EDNS client subnet option.
defaultECSv4 = 24
// defaultECSv6 is the default length of network mask for IPv6 address
// in EDNS client subnet option.
// in EDNS client subnet option. The size of 7 bytes is chosen as a
// reasonable minimum since at least Google's public DNS refuses
// requests containing the options with longer network masks.
defaultECSv6 = 56
)

Expand Down
2 changes: 1 addition & 1 deletion proxy/ratelimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (p *Proxy) isRatelimited(addr net.Addr) bool {
if len(p.RatelimitWhitelist) > 0 {
i := sort.SearchStrings(p.RatelimitWhitelist, ipStr)
if i < len(p.RatelimitWhitelist) && p.RatelimitWhitelist[i] == ipStr {
// Don't ratelimit if the ip is whitelisted.
// Don't ratelimit if the ip is allowlisted.
return false
}
}
Expand Down

0 comments on commit b4d5393

Please sign in to comment.