mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-05 04:47:40 +03:00
Compare commits
2 commits
dev
...
v0.5.0-rc.
Author | SHA1 | Date | |
---|---|---|---|
|
f7cd94b14d | ||
|
1f376ac005 |
2 changed files with 5 additions and 22 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue