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