Revert "platform: Implement set underlying networks for android"

This reverts commit eb4a184b7e.
This commit is contained in:
世界 2024-12-26 14:39:57 +08:00
parent 1ab255d636
commit 6f73096972
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
8 changed files with 0 additions and 43 deletions

View file

@ -51,5 +51,4 @@ type NetworkInterface struct {
DNSServers []string DNSServers []string
Expensive bool Expensive bool
Constrained bool Constrained bool
RawNetwork any
} }

View file

@ -82,10 +82,6 @@ func (s *platformInterfaceStub) Interfaces() ([]adapter.NetworkInterface, error)
return nil, os.ErrInvalid return nil, os.ErrInvalid
} }
func (s *platformInterfaceStub) SetUnderlyingNetworks(networks []adapter.NetworkInterface) error {
return os.ErrInvalid
}
func (s *platformInterfaceStub) UnderNetworkExtension() bool { func (s *platformInterfaceStub) UnderNetworkExtension() bool {
return false return false
} }

View file

@ -18,7 +18,6 @@ type PlatformInterface interface {
StartDefaultInterfaceMonitor(listener InterfaceUpdateListener) error StartDefaultInterfaceMonitor(listener InterfaceUpdateListener) error
CloseDefaultInterfaceMonitor(listener InterfaceUpdateListener) error CloseDefaultInterfaceMonitor(listener InterfaceUpdateListener) error
GetInterfaces() (NetworkInterfaceIterator, error) GetInterfaces() (NetworkInterfaceIterator, error)
SetUnderlyingNetworks(networks RawNetworkIterator) error
UnderNetworkExtension() bool UnderNetworkExtension() bool
IncludeAllNetworks() bool IncludeAllNetworks() bool
ReadWIFIState() *WIFIState ReadWIFIState() *WIFIState
@ -52,8 +51,6 @@ type NetworkInterface struct {
Type int32 Type int32
DNSServer StringIterator DNSServer StringIterator
Metered bool Metered bool
RawNetwork RawNetwork
} }
type WIFIState struct { type WIFIState struct {
@ -70,11 +67,6 @@ type NetworkInterfaceIterator interface {
HasNext() bool HasNext() bool
} }
type RawNetworkIterator interface {
Next() RawNetwork
HasNext() bool
}
type Notification struct { type Notification struct {
Identifier string Identifier string
TypeName string TypeName string

View file

@ -16,7 +16,6 @@ type Interface interface {
UpdateRouteOptions(options *tun.Options, platformOptions option.TunPlatformOptions) error UpdateRouteOptions(options *tun.Options, platformOptions option.TunPlatformOptions) error
CreateDefaultInterfaceMonitor(logger logger.Logger) tun.DefaultInterfaceMonitor CreateDefaultInterfaceMonitor(logger logger.Logger) tun.DefaultInterfaceMonitor
Interfaces() ([]adapter.NetworkInterface, error) Interfaces() ([]adapter.NetworkInterface, error)
SetUnderlyingNetworks(networks []adapter.NetworkInterface) error
UnderNetworkExtension() bool UnderNetworkExtension() bool
IncludeAllNetworks() bool IncludeAllNetworks() bool
ClearDNSCache() ClearDNSCache()

View file

@ -1,3 +0,0 @@
package libbox
type RawNetwork interface{}

View file

@ -1,7 +0,0 @@
//go:build !android
package libbox
type RawNetwork interface {
stub()
}

View file

@ -220,18 +220,11 @@ func (w *platformInterfaceWrapper) Interfaces() ([]adapter.NetworkInterface, err
DNSServers: iteratorToArray[string](netInterface.DNSServer), DNSServers: iteratorToArray[string](netInterface.DNSServer),
Expensive: netInterface.Metered || isDefault && w.isExpensive, Expensive: netInterface.Metered || isDefault && w.isExpensive,
Constrained: isDefault && w.isConstrained, Constrained: isDefault && w.isConstrained,
RawNetwork: netInterface.RawNetwork,
}) })
} }
return interfaces, nil return interfaces, nil
} }
func (w *platformInterfaceWrapper) SetUnderlyingNetworks(networks []adapter.NetworkInterface) error {
return w.iif.SetUnderlyingNetworks(newIterator(common.Map(networks, func(it adapter.NetworkInterface) RawNetwork {
return it.RawNetwork.(RawNetwork)
})))
}
func (w *platformInterfaceWrapper) UnderNetworkExtension() bool { func (w *platformInterfaceWrapper) UnderNetworkExtension() bool {
return w.iif.UnderNetworkExtension() return w.iif.UnderNetworkExtension()
} }

View file

@ -237,9 +237,6 @@ func (r *NetworkManager) UpdateInterfaces() error {
newInterfaces := common.Filter(interfaces, func(it adapter.NetworkInterface) bool { newInterfaces := common.Filter(interfaces, func(it adapter.NetworkInterface) bool {
return it.Flags&net.FlagUp != 0 return it.Flags&net.FlagUp != 0
}) })
for _, networkInterface := range newInterfaces {
networkInterface.RawNetwork = nil
}
r.networkInterfaces.Store(newInterfaces) r.networkInterfaces.Store(newInterfaces)
if len(newInterfaces) > 0 && !slices.EqualFunc(oldInterfaces, newInterfaces, func(oldInterface adapter.NetworkInterface, newInterface adapter.NetworkInterface) bool { if len(newInterfaces) > 0 && !slices.EqualFunc(oldInterfaces, newInterfaces, func(oldInterface adapter.NetworkInterface, newInterface adapter.NetworkInterface) bool {
return oldInterface.Interface.Index == newInterface.Interface.Index && return oldInterface.Interface.Index == newInterface.Interface.Index &&
@ -260,15 +257,6 @@ func (r *NetworkManager) UpdateInterfaces() error {
} }
return F.ToString(it.Name, " (", strings.Join(options, ", "), ")") return F.ToString(it.Name, " (", strings.Join(options, ", "), ")")
}), ", ")) }), ", "))
if C.IsAndroid {
err = r.platformInterface.SetUnderlyingNetworks(newInterfaces)
if err != nil {
r.logger.Error("set underlying networks: ", err)
}
}
}
for _, networkInterface := range interfaces {
networkInterface.RawNetwork = nil
} }
return nil return nil
} }