Feature: add support for multicast (#245)

* add support for multicast (#243)

* adjust setup

---------

Co-authored-by: xjasonlyu <xjasonlyu@gmail.com>
This commit is contained in:
Amaindex
2023-08-28 03:40:49 +08:00
committed by GitHub
parent fffcbbea10
commit 90f77548ed
6 changed files with 96 additions and 0 deletions

View File

@@ -1,6 +1,8 @@
package core
import (
"net"
"gvisor.dev/gvisor/pkg/tcpip"
"gvisor.dev/gvisor/pkg/tcpip/network/ipv4"
"gvisor.dev/gvisor/pkg/tcpip/network/ipv6"
@@ -23,6 +25,10 @@ type Config struct {
// stack to set transport handlers.
TransportHandler adapter.TransportHandler
// MulticastGroups is used by internal stack to add
// nic to given groups.
MulticastGroups []net.IP
// Options are supplement options to apply settings
// for the internal stack.
Options []option.Option
@@ -88,6 +94,9 @@ func CreateStack(cfg *Config) (*stack.Stack, error) {
// Add default route table for IPv4 and IPv6. This will handle
// all incoming ICMP packets.
withRouteTable(nicID),
// Add default NIC to the given multicast groups.
withMulticastGroups(nicID, cfg.MulticastGroups),
)
for _, opt := range opts {