mirror of https://github.com/v2ray/v2ray-core
parent
58bcfcee4e
commit
eee23e6718
|
@ -145,7 +145,7 @@ func (v *UDPNameServer) HandleResponse(dest v2net.Destination, payload *buf.Buff
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *UDPNameServer) BuildQueryA(domain string, id uint16) *buf.Buffer {
|
func (v *UDPNameServer) BuildQueryA(domain string, id uint16) *buf.Buffer {
|
||||||
buffer := buf.New()
|
|
||||||
msg := new(dns.Msg)
|
msg := new(dns.Msg)
|
||||||
msg.Id = id
|
msg.Id = id
|
||||||
msg.RecursionDesired = true
|
msg.RecursionDesired = true
|
||||||
|
@ -156,8 +156,11 @@ func (v *UDPNameServer) BuildQueryA(domain string, id uint16) *buf.Buffer {
|
||||||
Qclass: dns.ClassINET,
|
Qclass: dns.ClassINET,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
writtenBuffer, _ := msg.PackBuffer(buffer.Bytes())
|
buffer := buf.New()
|
||||||
buffer.Append(writtenBuffer)
|
buffer.AppendSupplier(func(b []byte) (int, error) {
|
||||||
|
writtenBuffer, err := msg.PackBuffer(b)
|
||||||
|
return len(writtenBuffer), err
|
||||||
|
})
|
||||||
|
|
||||||
return buffer
|
return buffer
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ func ReadUserPassRequest(reader io.Reader) (request Socks5UserPassRequest, err e
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
request.username = string(buffer.Bytes())
|
request.username = buffer.String()
|
||||||
|
|
||||||
err = buffer.AppendSupplier(buf.ReadFullFrom(reader, 1))
|
err = buffer.AppendSupplier(buf.ReadFullFrom(reader, 1))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -147,7 +147,7 @@ func ReadUserPassRequest(reader io.Reader) (request Socks5UserPassRequest, err e
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
request.password = string(buffer.Bytes())
|
request.password = buffer.String()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,8 +58,10 @@ func (*HeaderReader) Read(reader io.Reader) (*buf.Buffer, error) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if buffer.Len() >= len(ENDING) {
|
if buffer.Len() >= len(ENDING) {
|
||||||
copy(buffer.Bytes(), buffer.BytesFrom(buffer.Len()-len(ENDING)))
|
leftover := buffer.BytesFrom(buffer.Len() - len(ENDING))
|
||||||
buffer.Slice(0, len(ENDING))
|
buffer.Reset(func(b []byte) (int, error) {
|
||||||
|
return copy(b, leftover), nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if buffer.IsEmpty() {
|
if buffer.IsEmpty() {
|
||||||
|
|
|
@ -92,8 +92,7 @@ func (o *ClientConnection) Run() {
|
||||||
defer payload.Release()
|
defer payload.Release()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
payload.Clear()
|
err := payload.Reset(buf.ReadFrom(o.Conn))
|
||||||
err := payload.AppendSupplier(buf.ReadFrom(o.Conn))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
payload.Release()
|
payload.Release()
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue