mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-07 09:41:09 +08:00
Improve(iobased): impl stack.GSOEndpoint
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var _ stack.LinkEndpoint = (*Endpoint)(nil)
|
var _ stack.LinkEndpoint = (*Endpoint)(nil)
|
||||||
|
var _ stack.GSOEndpoint = (*Endpoint)(nil)
|
||||||
|
|
||||||
// Endpoint implements the interface of stack.LinkEndpoint from io.ReadWriter.
|
// Endpoint implements the interface of stack.LinkEndpoint from io.ReadWriter.
|
||||||
type Endpoint struct {
|
type Endpoint struct {
|
||||||
@@ -81,8 +82,10 @@ func (e *Endpoint) dispatchLoop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *Endpoint) writePacket(pkt *stack.PacketBuffer) tcpip.Error {
|
func (e *Endpoint) writePacket(pkt *stack.PacketBuffer) tcpip.Error {
|
||||||
vView := buffer.NewVectorisedView(pkt.Size(), pkt.Views())
|
vView := buffer.NewVectorisedView(
|
||||||
|
pkt.Size(),
|
||||||
|
pkt.Views(),
|
||||||
|
)
|
||||||
if _, err := e.rw.Write(vView.ToView()); err != nil {
|
if _, err := e.rw.Write(vView.ToView()); err != nil {
|
||||||
return &tcpip.ErrInvalidEndpointState{}
|
return &tcpip.ErrInvalidEndpointState{}
|
||||||
}
|
}
|
||||||
@@ -132,3 +135,13 @@ func (e *Endpoint) AddHeader(*stack.PacketBuffer) {}
|
|||||||
|
|
||||||
// Wait implements stack.LinkEndpoint.Wait.
|
// Wait implements stack.LinkEndpoint.Wait.
|
||||||
func (e *Endpoint) Wait() {}
|
func (e *Endpoint) Wait() {}
|
||||||
|
|
||||||
|
// GSOMaxSize implements stack.GSOEndpoint.
|
||||||
|
func (e *Endpoint) GSOMaxSize() uint32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// SupportedGSO implements stack.GSOEndpoint.
|
||||||
|
func (e *Endpoint) SupportedGSO() stack.SupportedGSO {
|
||||||
|
return stack.GSONotSupported
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user