Compare commits

...

2 commits

2 changed files with 5 additions and 22 deletions

View file

@ -3,7 +3,6 @@ package bufio
import (
"io"
"net"
"time"
"github.com/sagernet/sing/common/buf"
M "github.com/sagernet/sing/common/metadata"
@ -60,13 +59,6 @@ func (c *CachedConn) WriteTo(w io.Writer) (n int64, err error) {
return
}
func (c *CachedConn) SetReadDeadline(t time.Time) error {
if c.buffer != nil && !c.buffer.IsEmpty() {
return nil
}
return c.Conn.SetReadDeadline(t)
}
func (c *CachedConn) ReadFrom(r io.Reader) (n int64, err error) {
return Copy(c.Conn, r)
}

View file

@ -25,7 +25,11 @@ func NewMatcher(domains []string, domainSuffix []string) *Matcher {
domainList = append(domainList, reverseDomainSuffix(domain))
} else {
domainList = append(domainList, reverseDomain(domain))
domainList = append(domainList, reverseRootDomainSuffix(domain))
suffixDomain := "." + domain
if !seen[suffixDomain] {
seen[suffixDomain] = true
domainList = append(domainList, reverseDomainSuffix(suffixDomain))
}
}
}
for _, domain := range domains {
@ -139,16 +143,3 @@ func reverseDomainSuffix(domain string) string {
b[l] = prefixLabel
return string(b)
}
func reverseRootDomainSuffix(domain string) string {
l := len(domain)
b := make([]byte, l+2)
for i := 0; i < l; {
r, n := utf8.DecodeRuneInString(domain[i:])
i += n
utf8.EncodeRune(b[l-i:], r)
}
b[l] = '.'
b[l+1] = prefixLabel
return string(b)
}