Add broadcast filter

This commit is contained in:
世界 2023-11-06 21:33:35 +08:00
parent 1a00992d06
commit da350ecc72
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
4 changed files with 26 additions and 6 deletions

View file

@ -34,6 +34,7 @@ type GVisor struct {
tunMtu uint32
endpointIndependentNat bool
udpTimeout int64
broadcastAddr netip.Addr
handler Handler
logger logger.Logger
stack *stack.Stack
@ -59,6 +60,7 @@ func NewGVisor(
tunMtu: options.MTU,
endpointIndependentNat: options.EndpointIndependentNat,
udpTimeout: options.UDPTimeout,
broadcastAddr: BroadcastAddr(options.Inet4Address),
handler: options.Handler,
logger: options.Logger,
}
@ -70,7 +72,7 @@ func (t *GVisor) Start() error {
if err != nil {
return err
}
linkEndpoint = &LinkEndpointFilter{linkEndpoint, t.tun.CreateVectorisedWriter()}
linkEndpoint = &LinkEndpointFilter{linkEndpoint, t.broadcastAddr, t.tun.CreateVectorisedWriter()}
ipStack, err := newGVisorStack(linkEndpoint)
if err != nil {
return err