2023-01-27 21:37:20 +00:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2021-06-23 04:53:43 +00:00
|
|
|
|
2021-08-17 17:21:52 +00:00
|
|
|
//go:build ts_macext && (darwin || ios)
|
2021-06-23 04:53:43 +00:00
|
|
|
|
|
|
|
package resolver
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"net"
|
|
|
|
|
2023-04-18 21:26:58 +00:00
|
|
|
"tailscale.com/net/netmon"
|
2021-06-23 04:53:43 +00:00
|
|
|
"tailscale.com/net/netns"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
initListenConfig = initListenConfigNetworkExtension
|
|
|
|
}
|
|
|
|
|
2023-04-18 21:26:58 +00:00
|
|
|
func initListenConfigNetworkExtension(nc *net.ListenConfig, mon *netmon.Monitor, tunName string) error {
|
2021-06-23 04:53:43 +00:00
|
|
|
nif, ok := mon.InterfaceState().Interface[tunName]
|
|
|
|
if !ok {
|
|
|
|
return errors.New("utun not found")
|
|
|
|
}
|
|
|
|
return netns.SetListenConfigInterfaceIndex(nc, nif.Interface.Index)
|
|
|
|
}
|