mirror of
				https://github.com/tailscale/tailscale.git
				synced 2025-10-31 08:11:32 +01:00 
			
		
		
		
	So wgengine/router is just the docs + entrypoint + types, and then underscore importing wgengine/router/osrouter registers the constructors with the wgengine/router package. Then tsnet can not pull those in. Updates #17313 Change-Id: If313226f6987d709ea9193c8f16a909326ceefe7 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
		
			
				
	
	
		
			28 lines
		
	
	
		
			825 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			825 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright (c) Tailscale Inc & AUTHORS
 | |
| // SPDX-License-Identifier: BSD-3-Clause
 | |
| 
 | |
| package osrouter
 | |
| 
 | |
| import (
 | |
| 	"tailscale.com/net/netmon"
 | |
| 	"tailscale.com/types/logger"
 | |
| 	"tailscale.com/wgengine/router"
 | |
| )
 | |
| 
 | |
| func init() {
 | |
| 	router.HookCleanUp.Set(func(logf logger.Logf, netMon *netmon.Monitor, ifName string) {
 | |
| 		cleanUp(logf, ifName)
 | |
| 	})
 | |
| }
 | |
| 
 | |
| func cleanUp(logf logger.Logf, interfaceName string) {
 | |
| 	// If the interface was left behind, ifconfig down will not remove it.
 | |
| 	// In fact, this will leave a system in a tainted state where starting tailscaled
 | |
| 	// will result in "interface tailscale0 already exists"
 | |
| 	// until the defunct interface is ifconfig-destroyed.
 | |
| 	ifup := []string{"ifconfig", interfaceName, "destroy"}
 | |
| 	if out, err := cmd(ifup...).CombinedOutput(); err != nil {
 | |
| 		logf("ifconfig destroy: %v\n%s", err, out)
 | |
| 	}
 | |
| }
 |