feat: support custom ComponentID for Windows TAP device configuration

This commit is contained in:
eWloYW8
2025-09-21 15:14:27 +08:00
committed by ginuerzh
parent 1c1f092a14
commit eae322c7ba
3 changed files with 22 additions and 16 deletions
+15 -10
View File
@@ -19,23 +19,28 @@ type metadata struct {
func (l *tapListener) parseMetadata(md mdata.Metadata) (err error) {
const (
name = "name"
netKey = "net"
mtu = "mtu"
route = "route"
routes = "routes"
gateway = "gw"
name = "name"
netKey = "net"
mtu = "mtu"
route = "route"
routes = "routes"
gateway = "gw"
componentID = "componentID"
)
config := &tap_util.Config{
Name: mdutil.GetString(md, name),
Net: mdutil.GetString(md, netKey),
MTU: mdutil.GetInt(md, mtu),
Gateway: mdutil.GetString(md, gateway),
Name: mdutil.GetString(md, name),
Net: mdutil.GetString(md, netKey),
MTU: mdutil.GetInt(md, mtu),
Gateway: mdutil.GetString(md, gateway),
ComponentID: mdutil.GetString(md, componentID),
}
if config.MTU <= 0 {
config.MTU = DefaultMTU
}
if config.ComponentID == "" {
config.ComponentID = "tap0901"
}
gw := net.ParseIP(config.Gateway)
+1 -1
View File
@@ -17,7 +17,7 @@ func (l *tapListener) createTap() (dev io.ReadWriteCloser, name string, ip net.I
ifce, err := water.New(water.Config{
DeviceType: water.TAP,
PlatformSpecificParams: water.PlatformSpecificParams{
ComponentID: "tap0901",
ComponentID: l.md.config.ComponentID,
InterfaceName: l.md.config.Name,
Network: l.md.config.Net,
},