mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	Try to convert TUN/TAP to use new yggdrasil.Conn, search masks are still broken
This commit is contained in:
		
							parent
							
								
									319366513c
								
							
						
					
					
						commit
						d01662c1fb
					
				
					 14 changed files with 502 additions and 366 deletions
				
			
		| 
						 | 
				
			
			@ -18,7 +18,7 @@ import (
 | 
			
		|||
// Configures the "utun" adapter with the correct IPv6 address and MTU.
 | 
			
		||||
func (tun *TunAdapter) setup(ifname string, iftapmode bool, addr string, mtu int) error {
 | 
			
		||||
	if iftapmode {
 | 
			
		||||
		tun.Log.Warnln("TAP mode is not supported on this platform, defaulting to TUN")
 | 
			
		||||
		tun.log.Warnln("TAP mode is not supported on this platform, defaulting to TUN")
 | 
			
		||||
	}
 | 
			
		||||
	config := water.Config{DeviceType: water.TUN}
 | 
			
		||||
	iface, err := water.New(config)
 | 
			
		||||
| 
						 | 
				
			
			@ -69,7 +69,7 @@ func (tun *TunAdapter) setupAddress(addr string) error {
 | 
			
		|||
	var err error
 | 
			
		||||
 | 
			
		||||
	if fd, err = unix.Socket(unix.AF_INET6, unix.SOCK_DGRAM, 0); err != nil {
 | 
			
		||||
		tun.Log.Printf("Create AF_SYSTEM socket failed: %v.", err)
 | 
			
		||||
		tun.log.Printf("Create AF_SYSTEM socket failed: %v.", err)
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -98,19 +98,19 @@ func (tun *TunAdapter) setupAddress(addr string) error {
 | 
			
		|||
	copy(ir.ifr_name[:], tun.iface.Name())
 | 
			
		||||
	ir.ifru_mtu = uint32(tun.mtu)
 | 
			
		||||
 | 
			
		||||
	tun.Log.Infof("Interface name: %s", ar.ifra_name)
 | 
			
		||||
	tun.Log.Infof("Interface IPv6: %s", addr)
 | 
			
		||||
	tun.Log.Infof("Interface MTU: %d", ir.ifru_mtu)
 | 
			
		||||
	tun.log.Infof("Interface name: %s", ar.ifra_name)
 | 
			
		||||
	tun.log.Infof("Interface IPv6: %s", addr)
 | 
			
		||||
	tun.log.Infof("Interface MTU: %d", ir.ifru_mtu)
 | 
			
		||||
 | 
			
		||||
	if _, _, errno := unix.Syscall(unix.SYS_IOCTL, uintptr(fd), uintptr(darwin_SIOCAIFADDR_IN6), uintptr(unsafe.Pointer(&ar))); errno != 0 {
 | 
			
		||||
		err = errno
 | 
			
		||||
		tun.Log.Errorf("Error in darwin_SIOCAIFADDR_IN6: %v", errno)
 | 
			
		||||
		tun.log.Errorf("Error in darwin_SIOCAIFADDR_IN6: %v", errno)
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if _, _, errno := unix.Syscall(unix.SYS_IOCTL, uintptr(fd), uintptr(unix.SIOCSIFMTU), uintptr(unsafe.Pointer(&ir))); errno != 0 {
 | 
			
		||||
		err = errno
 | 
			
		||||
		tun.Log.Errorf("Error in SIOCSIFMTU: %v", errno)
 | 
			
		||||
		tun.log.Errorf("Error in SIOCSIFMTU: %v", errno)
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue