mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Tidy up
This commit is contained in:
		
							parent
							
								
									962665189c
								
							
						
					
					
						commit
						69632bacb5
					
				
					 9 changed files with 25 additions and 87 deletions
				
			
		| 
						 | 
				
			
			@ -2,25 +2,15 @@ package core
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"crypto/ed25519"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"sync/atomic"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	//"encoding/hex"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	//"errors"
 | 
			
		||||
	//"fmt"
 | 
			
		||||
	"net"
 | 
			
		||||
	"net/url"
 | 
			
		||||
 | 
			
		||||
	//"sort"
 | 
			
		||||
	//"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/Arceliar/phony"
 | 
			
		||||
	"github.com/yggdrasil-network/yggdrasil-go/src/address"
 | 
			
		||||
	"github.com/yggdrasil-network/yggdrasil-go/src/util"
 | 
			
		||||
	//"github.com/yggdrasil-network/yggdrasil-go/src/crypto"
 | 
			
		||||
	//"github.com/Arceliar/phony"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type SelfInfo struct {
 | 
			
		||||
| 
						 | 
				
			
			@ -176,7 +166,7 @@ func (c *Core) Subnet() net.IPNet {
 | 
			
		|||
// may be useful if you want to redirect the output later. Note that this
 | 
			
		||||
// expects a Logger from the github.com/gologme/log package and not from Go's
 | 
			
		||||
// built-in log package.
 | 
			
		||||
func (c *Core) SetLogger(log util.Logger) {
 | 
			
		||||
func (c *Core) SetLogger(log Logger) {
 | 
			
		||||
	c.log = log
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,9 +14,7 @@ import (
 | 
			
		|||
	"github.com/Arceliar/phony"
 | 
			
		||||
	"github.com/gologme/log"
 | 
			
		||||
 | 
			
		||||
	"github.com/yggdrasil-network/yggdrasil-go/src/util"
 | 
			
		||||
	"github.com/yggdrasil-network/yggdrasil-go/src/version"
 | 
			
		||||
	//"github.com/yggdrasil-network/yggdrasil-go/src/crypto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// The Core object represents the Yggdrasil node. You should create a Core
 | 
			
		||||
| 
						 | 
				
			
			@ -33,7 +31,7 @@ type Core struct {
 | 
			
		|||
	public       ed25519.PublicKey
 | 
			
		||||
	links        links
 | 
			
		||||
	proto        protoHandler
 | 
			
		||||
	log          util.Logger
 | 
			
		||||
	log          Logger
 | 
			
		||||
	addPeerTimer *time.Timer
 | 
			
		||||
	config       struct {
 | 
			
		||||
		_peers             map[Peer]*linkInfo         // configurable after startup
 | 
			
		||||
| 
						 | 
				
			
			@ -44,7 +42,7 @@ type Core struct {
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func New(secret ed25519.PrivateKey, logger util.Logger, opts ...SetupOption) (*Core, error) {
 | 
			
		||||
func New(secret ed25519.PrivateKey, logger Logger, opts ...SetupOption) (*Core, error) {
 | 
			
		||||
	c := &Core{
 | 
			
		||||
		log: logger,
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -193,3 +191,16 @@ func (c *Core) WriteTo(p []byte, addr net.Addr) (n int, err error) {
 | 
			
		|||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type Logger interface {
 | 
			
		||||
	Printf(string, ...interface{})
 | 
			
		||||
	Println(...interface{})
 | 
			
		||||
	Infof(string, ...interface{})
 | 
			
		||||
	Infoln(...interface{})
 | 
			
		||||
	Warnf(string, ...interface{})
 | 
			
		||||
	Warnln(...interface{})
 | 
			
		||||
	Errorf(string, ...interface{})
 | 
			
		||||
	Errorln(...interface{})
 | 
			
		||||
	Debugf(string, ...interface{})
 | 
			
		||||
	Debugln(...interface{})
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@ package core
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	"net/http"
 | 
			
		||||
	_ "net/http/pprof"
 | 
			
		||||
	"os"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,15 +9,11 @@ import (
 | 
			
		|||
	"net"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	//"sync/atomic"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"sync/atomic"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/Arceliar/phony"
 | 
			
		||||
	"github.com/yggdrasil-network/yggdrasil-go/src/address"
 | 
			
		||||
	//"github.com/Arceliar/phony" // TODO? use instead of mutexes
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type links struct {
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +24,6 @@ type links struct {
 | 
			
		|||
	unix   *linkUNIX          // UNIX interface support
 | 
			
		||||
	socks  *linkSOCKS         // SOCKS interface support
 | 
			
		||||
	_links map[linkInfo]*link // *link is nil if connection in progress
 | 
			
		||||
	// TODO timeout (to remove from switch), read from config.ReadTimeout
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// linkInfo is used as a map key
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,9 +11,6 @@ import (
 | 
			
		|||
 | 
			
		||||
	iwt "github.com/Arceliar/ironwood/types"
 | 
			
		||||
	"github.com/Arceliar/phony"
 | 
			
		||||
 | 
			
		||||
	//"github.com/yggdrasil-network/yggdrasil-go/src/crypto"
 | 
			
		||||
 | 
			
		||||
	"github.com/yggdrasil-network/yggdrasil-go/src/version"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue