mirror of
				https://git.zx2c4.com/wireguard-go
				synced 2025-10-31 11:56:22 +08:00 
			
		
		
		
	(*NativeTun).operateOnFd is only used on darwin and freebsd. Adjust the build tags accordingly. Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
		
			
				
	
	
		
			26 lines
		
	
	
		
			535 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			535 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| //go:build darwin || freebsd
 | |
| // +build darwin freebsd
 | |
| 
 | |
| /* SPDX-License-Identifier: MIT
 | |
|  *
 | |
|  * Copyright (C) 2017-2021 WireGuard LLC. All Rights Reserved.
 | |
|  */
 | |
| 
 | |
| package tun
 | |
| 
 | |
| import (
 | |
| 	"fmt"
 | |
| )
 | |
| 
 | |
| func (tun *NativeTun) operateOnFd(fn func(fd uintptr)) {
 | |
| 	sysconn, err := tun.tunFile.SyscallConn()
 | |
| 	if err != nil {
 | |
| 		tun.errors <- fmt.Errorf("unable to find sysconn for tunfile: %s", err.Error())
 | |
| 		return
 | |
| 	}
 | |
| 	err = sysconn.Control(fn)
 | |
| 	if err != nil {
 | |
| 		tun.errors <- fmt.Errorf("unable to control sysconn for tunfile: %s", err.Error())
 | |
| 	}
 | |
| }
 |