2022-10-25 12:55:00 +08:00
|
|
|
package platform
|
|
|
|
|
|
|
|
import (
|
2023-04-18 14:04:09 +08:00
|
|
|
"context"
|
2022-10-25 12:55:00 +08:00
|
|
|
"io"
|
2023-04-18 14:04:09 +08:00
|
|
|
"net/netip"
|
2022-10-25 12:55:00 +08:00
|
|
|
|
2023-04-18 14:04:09 +08:00
|
|
|
"github.com/sagernet/sing-box/adapter"
|
2022-10-25 12:55:00 +08:00
|
|
|
"github.com/sagernet/sing-box/common/process"
|
2023-02-28 19:02:27 +08:00
|
|
|
"github.com/sagernet/sing-box/option"
|
2022-10-25 12:55:00 +08:00
|
|
|
"github.com/sagernet/sing-tun"
|
|
|
|
"github.com/sagernet/sing/common/control"
|
2023-04-18 14:04:09 +08:00
|
|
|
E "github.com/sagernet/sing/common/exceptions"
|
2022-10-25 12:55:00 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type Interface interface {
|
2023-04-18 14:04:09 +08:00
|
|
|
Initialize(ctx context.Context, router adapter.Router) error
|
2022-10-25 12:55:00 +08:00
|
|
|
AutoDetectInterfaceControl() control.Func
|
2023-04-17 19:05:02 +08:00
|
|
|
OpenTun(options *tun.Options, platformOptions option.TunPlatformOptions) (tun.Tun, error)
|
2023-04-18 14:04:09 +08:00
|
|
|
UsePlatformDefaultInterfaceMonitor() bool
|
|
|
|
CreateDefaultInterfaceMonitor(errorHandler E.Handler) tun.DefaultInterfaceMonitor
|
|
|
|
UsePlatformInterfaceGetter() bool
|
|
|
|
Interfaces() ([]NetworkInterface, error)
|
2022-10-25 12:55:00 +08:00
|
|
|
process.Searcher
|
|
|
|
io.Writer
|
|
|
|
}
|
2023-04-18 14:04:09 +08:00
|
|
|
|
|
|
|
type NetworkInterface struct {
|
|
|
|
Index int
|
|
|
|
MTU int
|
|
|
|
Name string
|
|
|
|
Addresses []netip.Prefix
|
|
|
|
}
|