mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	Tidy some lint errors
This commit is contained in:
		
							parent
							
								
									b9f35c5530
								
							
						
					
					
						commit
						fb6b828916
					
				
					 33 changed files with 125 additions and 656 deletions
				
			
		| 
						 | 
				
			
			@ -54,9 +54,7 @@ func main() {
 | 
			
		|||
		if isBetter(currentBest, newKey.id[:]) || len(currentBest) == 0 {
 | 
			
		||||
			currentBest = newKey.id
 | 
			
		||||
			for _, channel := range threadChannels {
 | 
			
		||||
				select {
 | 
			
		||||
				case channel <- newKey.id:
 | 
			
		||||
				}
 | 
			
		||||
				channel <- newKey.id
 | 
			
		||||
			}
 | 
			
		||||
			fmt.Println("--------------------------------------------------------------------------------")
 | 
			
		||||
			switch {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -106,7 +106,7 @@ func readConfig(useconf *bool, useconffile *string, normaliseconf *bool) *config
 | 
			
		|||
	if err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
	json.Unmarshal(confJson, &cfg)
 | 
			
		||||
	_ = json.Unmarshal(confJson, &cfg)
 | 
			
		||||
	// Overlay our newly mapped configuration onto the autoconf node config that
 | 
			
		||||
	// we generated above.
 | 
			
		||||
	if err = mapstructure.Decode(dat, &cfg); err != nil {
 | 
			
		||||
| 
						 | 
				
			
			@ -285,25 +285,29 @@ func main() {
 | 
			
		|||
	n.multicast = &multicast.Multicast{}
 | 
			
		||||
	n.tuntap = &tuntap.TunAdapter{}
 | 
			
		||||
	// Start the admin socket
 | 
			
		||||
	n.admin.Init(&n.core, n.state, logger, nil)
 | 
			
		||||
	if err := n.admin.Start(); err != nil {
 | 
			
		||||
	if err := n.admin.Init(&n.core, n.state, logger, nil); err != nil {
 | 
			
		||||
		logger.Errorln("An error occured initialising the admin module:", err)
 | 
			
		||||
	} else if err := n.admin.Start(); err != nil {
 | 
			
		||||
		logger.Errorln("An error occurred starting admin socket:", err)
 | 
			
		||||
	}
 | 
			
		||||
	n.admin.SetupAdminHandlers(n.admin.(*admin.AdminSocket))
 | 
			
		||||
	// Start the multicast interface
 | 
			
		||||
	n.multicast.Init(&n.core, n.state, logger, nil)
 | 
			
		||||
	if err := n.multicast.Start(); err != nil {
 | 
			
		||||
	if err := n.multicast.Init(&n.core, n.state, logger, nil); err != nil {
 | 
			
		||||
		logger.Errorln("An error occured initialising the multicast module:", err)
 | 
			
		||||
	} else if err := n.multicast.Start(); err != nil {
 | 
			
		||||
		logger.Errorln("An error occurred starting multicast:", err)
 | 
			
		||||
	}
 | 
			
		||||
	n.multicast.SetupAdminHandlers(n.admin.(*admin.AdminSocket))
 | 
			
		||||
	// Start the TUN/TAP interface
 | 
			
		||||
	if listener, err := n.core.ConnListen(); err == nil {
 | 
			
		||||
		if dialer, err := n.core.ConnDialer(); err == nil {
 | 
			
		||||
			n.tuntap.Init(&n.core, n.state, logger, tuntap.TunOptions{Listener: listener, Dialer: dialer})
 | 
			
		||||
			if err := n.tuntap.Start(); err != nil {
 | 
			
		||||
			if err := n.tuntap.Init(&n.core, n.state, logger, tuntap.TunOptions{Listener: listener, Dialer: dialer}); err != nil {
 | 
			
		||||
				logger.Errorln("An error occured initialising the TUN module:", err)
 | 
			
		||||
			} else if err := n.tuntap.Start(); err != nil {
 | 
			
		||||
				logger.Errorln("An error occurred starting TUN/TAP:", err)
 | 
			
		||||
			} else {
 | 
			
		||||
				n.tuntap.SetupAdminHandlers(n.admin.(*admin.AdminSocket))
 | 
			
		||||
			}
 | 
			
		||||
			n.tuntap.SetupAdminHandlers(n.admin.(*admin.AdminSocket))
 | 
			
		||||
		} else {
 | 
			
		||||
			logger.Errorln("Unable to get Dialer:", err)
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -346,9 +350,9 @@ exit:
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func (n *node) shutdown() {
 | 
			
		||||
	n.admin.Stop()
 | 
			
		||||
	n.multicast.Stop()
 | 
			
		||||
	n.tuntap.Stop()
 | 
			
		||||
	_ = n.admin.Stop()
 | 
			
		||||
	_ = n.multicast.Stop()
 | 
			
		||||
	_ = n.tuntap.Stop()
 | 
			
		||||
	n.core.Stop()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,8 +47,11 @@ func run() int {
 | 
			
		|||
		fmt.Fprintf(flag.CommandLine.Output(), "Usage: %s [options] command [key=value] [key=value] ...\n\n", os.Args[0])
 | 
			
		||||
		fmt.Println("Options:")
 | 
			
		||||
		flag.PrintDefaults()
 | 
			
		||||
		fmt.Println("\nPlease note that options must always specified BEFORE the command\non the command line or they will be ignored.\n")
 | 
			
		||||
		fmt.Println("Commands:\n  - Use \"list\" for a list of available commands\n")
 | 
			
		||||
		fmt.Println()
 | 
			
		||||
		fmt.Println("Please note that options must always specified BEFORE the command\non the command line or they will be ignored.")
 | 
			
		||||
		fmt.Println()
 | 
			
		||||
		fmt.Println("Commands:\n  - Use \"list\" for a list of available commands")
 | 
			
		||||
		fmt.Println()
 | 
			
		||||
		fmt.Println("Examples:")
 | 
			
		||||
		fmt.Println("  - ", os.Args[0], "list")
 | 
			
		||||
		fmt.Println("  - ", os.Args[0], "getPeers")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"sort"
 | 
			
		||||
	"time"
 | 
			
		||||
| 
						 | 
				
			
			@ -29,7 +30,7 @@ func dialTest(sendNode, recvNode *simNode) {
 | 
			
		|||
		mask[idx] = 0xff
 | 
			
		||||
	}
 | 
			
		||||
	for {
 | 
			
		||||
		c, err := sendNode.dialer.DialByNodeIDandMask(nil, &recvNode.nodeID, &mask)
 | 
			
		||||
		c, err := sendNode.dialer.DialByNodeIDandMask(context.TODO(), &recvNode.nodeID, &mask)
 | 
			
		||||
		if c != nil {
 | 
			
		||||
			c.Close()
 | 
			
		||||
			return
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,9 @@ type simNode struct {
 | 
			
		|||
 | 
			
		||||
func newNode(id int) *simNode {
 | 
			
		||||
	n := simNode{id: id}
 | 
			
		||||
	n.core.Start(config.GenerateConfig(), log.New(ioutil.Discard, "", 0))
 | 
			
		||||
	if _, err := n.core.Start(config.GenerateConfig(), log.New(ioutil.Discard, "", 0)); err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
	n.nodeID = *n.core.NodeID()
 | 
			
		||||
	n.dialer, _ = n.core.ConnDialer()
 | 
			
		||||
	n.listener, _ = n.core.ConnListen()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,19 +2,21 @@ package main
 | 
			
		|||
 | 
			
		||||
type nodeStore map[int]*simNode
 | 
			
		||||
 | 
			
		||||
func makeStoreSingle() nodeStore {
 | 
			
		||||
	s := make(nodeStore)
 | 
			
		||||
	s[0] = newNode(0)
 | 
			
		||||
	return s
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func linkNodes(a *simNode, b *simNode) {
 | 
			
		||||
	la := a.core.NewSimlink()
 | 
			
		||||
	lb := b.core.NewSimlink()
 | 
			
		||||
	la.SetDestination(lb)
 | 
			
		||||
	lb.SetDestination(la)
 | 
			
		||||
	la.Start()
 | 
			
		||||
	lb.Start()
 | 
			
		||||
	if err := la.SetDestination(lb); err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
	if err := lb.SetDestination(la); err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
	if err := la.Start(); err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
	if err := lb.Start(); err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func makeStoreSquareGrid(sideLength int) nodeStore {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue