mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Implement a tun interface to reduce dependency on Water library
This commit is contained in:
		
							parent
							
								
									b3ebe76b59
								
							
						
					
					
						commit
						c3600d14d6
					
				
					 1 changed files with 11 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -2,16 +2,25 @@ package yggdrasil
 | 
			
		|||
 | 
			
		||||
// This manages the tun driver to send/recv packets to/from applications
 | 
			
		||||
 | 
			
		||||
import water "github.com/songgao/water"
 | 
			
		||||
// import water "github.com/songgao/water"
 | 
			
		||||
 | 
			
		||||
const IPv6_HEADER_LENGTH = 40
 | 
			
		||||
 | 
			
		||||
type tunInterface interface {
 | 
			
		||||
	IsTUN() bool
 | 
			
		||||
	IsTAP() bool
 | 
			
		||||
	Name() string
 | 
			
		||||
	Read(to []byte) (int, error)
 | 
			
		||||
	Write(from []byte) (int, error)
 | 
			
		||||
	Close() error
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type tunDevice struct {
 | 
			
		||||
	core  *Core
 | 
			
		||||
	send  chan<- []byte
 | 
			
		||||
	recv  <-chan []byte
 | 
			
		||||
	mtu   int
 | 
			
		||||
	iface *water.Interface
 | 
			
		||||
	iface tunInterface
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (tun *tunDevice) init(core *Core) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue