TUN-857: Pull the brotli-go dependency from Github

This commit is contained in:
Areg Harutyunyan
2018-08-07 13:08:39 -05:00
parent 6fff7b436f
commit 8c704abd41
59 changed files with 16 additions and 15378 deletions

View File

@@ -125,8 +125,7 @@ func SplitHostPort(s string) (host, port string, ipnet *net.IPNet, err error) {
// Get the first lower octet boundary to see what encompassing zone we should be authoritative for.
mod := (bits - ones) % sizeDigit
nearest := (bits - ones) + mod
offset := 0
var end bool
offset, end := 0, false
for i := 0; i < nearest/sizeDigit; i++ {
offset, end = dns.NextLabel(rev, offset)
if end {

View File

@@ -263,16 +263,12 @@ func (r *Request) Scrub(reply *dns.Msg) (*dns.Msg, Result) {
// Account for the OPT record that gets added in SizeAndDo(), subtract that length.
sub := 0
if r.Req.IsEdns0() != nil {
if r.Do() {
sub = optLen
}
// substract to make spaces for re-added EDNS0 OPT RR.
re := len(reply.Extra) - sub
size -= sub
l, m := 0, 0
origExtra := reply.Extra
re := len(reply.Extra) - sub
l, m := 0, 0
for l < re {
m = (l + re) / 2
reply.Extra = origExtra[:m]
@@ -301,9 +297,9 @@ func (r *Request) Scrub(reply *dns.Msg) (*dns.Msg, Result) {
return reply, ScrubExtra
}
origAnswer := reply.Answer
ra := len(reply.Answer)
l, m = 0, 0
origAnswer := reply.Answer
for l < ra {
m = (l + ra) / 2
reply.Answer = origAnswer[:m]
@@ -328,12 +324,14 @@ func (r *Request) Scrub(reply *dns.Msg) (*dns.Msg, Result) {
// this extra m-1 step does make it fit in the client's buffer however.
}
r.SizeAndDo(reply)
// It now fits, but Truncated. We can't call sizeAndDo() because that adds a new record (OPT)
// in the additional section.
reply.Truncated = true
return reply, ScrubAnswer
}
// Type returns the type of the question as a string. If the request is malformed the empty string is returned.
// Type returns the type of the question as a string. If the request is malformed
// the empty string is returned.
func (r *Request) Type() string {
if r.Req == nil {
return ""