mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-04 12:27:37 +03:00
Check socksaddr domain is valid
This commit is contained in:
parent
27ddefbb89
commit
a606585cf7
3 changed files with 8 additions and 3 deletions
|
@ -40,7 +40,7 @@ func (ap Socksaddr) Unwrap() Socksaddr {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ap Socksaddr) IsFqdn() bool {
|
func (ap Socksaddr) IsFqdn() bool {
|
||||||
return !ap.Addr.IsValid() && ap.Fqdn != ""
|
return !ap.Addr.IsValid() && IsDomainName(ap.Fqdn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ap Socksaddr) IsValid() bool {
|
func (ap Socksaddr) IsValid() bool {
|
||||||
|
|
6
common/metadata/domain.go
Normal file
6
common/metadata/domain.go
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
package metadata
|
||||||
|
|
||||||
|
import _ "unsafe" // for linkname
|
||||||
|
|
||||||
|
//go:linkname IsDomainName net.isDomainName
|
||||||
|
func IsDomainName(domain string) bool
|
|
@ -53,8 +53,8 @@ func (c *ClientConn) Write(p []byte) (n int, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ClientConn) WriteBuffer(buffer *buf.Buffer) error {
|
func (c *ClientConn) WriteBuffer(buffer *buf.Buffer) error {
|
||||||
defer buffer.Release()
|
|
||||||
if c.headerWritten {
|
if c.headerWritten {
|
||||||
|
defer buffer.Release()
|
||||||
return common.Error(c.Conn.Write(buffer.Bytes()))
|
return common.Error(c.Conn.Write(buffer.Bytes()))
|
||||||
}
|
}
|
||||||
err := ClientHandshakeBuffer(c.Conn, c.key, c.destination, buffer)
|
err := ClientHandshakeBuffer(c.Conn, c.key, c.destination, buffer)
|
||||||
|
@ -105,7 +105,6 @@ func (c *ClientPacketConn) ReadPacket(buffer *buf.Buffer) (M.Socksaddr, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ClientPacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) error {
|
func (c *ClientPacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) error {
|
||||||
defer buffer.Release()
|
|
||||||
if !c.headerWritten {
|
if !c.headerWritten {
|
||||||
err := ClientHandshakePacket(c.Conn, c.key, destination, buffer)
|
err := ClientHandshakePacket(c.Conn, c.key, destination, buffer)
|
||||||
c.headerWritten = true
|
c.headerWritten = true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue