mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Add IPReadWriteCloser interface
This commit is contained in:
		
							parent
							
								
									cbb6dc1b7d
								
							
						
					
					
						commit
						ebe366ef3b
					
				
					 1 changed files with 11 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -11,6 +11,7 @@ package tuntap
 | 
			
		|||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io"
 | 
			
		||||
	"net"
 | 
			
		||||
 | 
			
		||||
	//"sync"
 | 
			
		||||
| 
						 | 
				
			
			@ -22,17 +23,23 @@ import (
 | 
			
		|||
	"github.com/yggdrasil-network/yggdrasil-go/src/address"
 | 
			
		||||
	"github.com/yggdrasil-network/yggdrasil-go/src/config"
 | 
			
		||||
	"github.com/yggdrasil-network/yggdrasil-go/src/defaults"
 | 
			
		||||
	"github.com/yggdrasil-network/yggdrasil-go/src/ipv6rwc"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type MTU uint16
 | 
			
		||||
type IPReadWriteCloser interface {
 | 
			
		||||
	io.ReadWriteCloser
 | 
			
		||||
	MaxMTU() uint64
 | 
			
		||||
	SetMTU(mtu uint64)
 | 
			
		||||
	MTU() uint64
 | 
			
		||||
	Address() address.Address
 | 
			
		||||
	Subnet() address.Subnet
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TunAdapter represents a running TUN interface and extends the
 | 
			
		||||
// yggdrasil.Adapter type. In order to use the TUN adapter with Yggdrasil, you
 | 
			
		||||
// should pass this object to the yggdrasil.SetRouterAdapter() function before
 | 
			
		||||
// calling yggdrasil.Start().
 | 
			
		||||
type TunAdapter struct {
 | 
			
		||||
	rwc         *ipv6rwc.ReadWriteCloser
 | 
			
		||||
	rwc         IPReadWriteCloser
 | 
			
		||||
	config      *config.NodeConfig
 | 
			
		||||
	log         *log.Logger
 | 
			
		||||
	addr        address.Address
 | 
			
		||||
| 
						 | 
				
			
			@ -93,7 +100,7 @@ func MaximumMTU() uint64 {
 | 
			
		|||
 | 
			
		||||
// Init initialises the TUN module. You must have acquired a Listener from
 | 
			
		||||
// the Yggdrasil core before this point and it must not be in use elsewhere.
 | 
			
		||||
func (tun *TunAdapter) Init(rwc *ipv6rwc.ReadWriteCloser, config *config.NodeConfig, log *log.Logger, options interface{}) error {
 | 
			
		||||
func (tun *TunAdapter) Init(rwc IPReadWriteCloser, config *config.NodeConfig, log *log.Logger, options interface{}) error {
 | 
			
		||||
	tun.rwc = rwc
 | 
			
		||||
	tun.config = config
 | 
			
		||||
	tun.log = log
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue