mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 06:05:06 +03:00
Accept some golint suggestions (#690)
* Fixed some linter issues * Simplified isBetter method * Accept some linter suggestions * Fix typo Co-authored-by: klesomik <klesomiks@gmail.com> Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
This commit is contained in:
parent
1492738c9e
commit
d6d2d9c19a
15 changed files with 75 additions and 94 deletions
|
@ -51,7 +51,7 @@ func main() {
|
|||
|
||||
for {
|
||||
newKey := <-newKeys
|
||||
if isBetter(currentBest[:], newKey.id[:]) || len(currentBest) == 0 {
|
||||
if isBetter(currentBest, newKey.id[:]) || len(currentBest) == 0 {
|
||||
currentBest = newKey.id
|
||||
for _, channel := range threadChannels {
|
||||
select {
|
||||
|
@ -61,13 +61,13 @@ func main() {
|
|||
fmt.Println("--------------------------------------------------------------------------------")
|
||||
switch {
|
||||
case *doSig:
|
||||
fmt.Println("sigPriv:", hex.EncodeToString(newKey.priv[:]))
|
||||
fmt.Println("sigPub:", hex.EncodeToString(newKey.pub[:]))
|
||||
fmt.Println("TreeID:", hex.EncodeToString(newKey.id[:]))
|
||||
fmt.Println("sigPriv:", hex.EncodeToString(newKey.priv))
|
||||
fmt.Println("sigPub:", hex.EncodeToString(newKey.pub))
|
||||
fmt.Println("TreeID:", hex.EncodeToString(newKey.id))
|
||||
default:
|
||||
fmt.Println("boxPriv:", hex.EncodeToString(newKey.priv[:]))
|
||||
fmt.Println("boxPub:", hex.EncodeToString(newKey.pub[:]))
|
||||
fmt.Println("NodeID:", hex.EncodeToString(newKey.id[:]))
|
||||
fmt.Println("boxPriv:", hex.EncodeToString(newKey.priv))
|
||||
fmt.Println("boxPub:", hex.EncodeToString(newKey.pub))
|
||||
fmt.Println("NodeID:", hex.EncodeToString(newKey.id))
|
||||
fmt.Println("IP:", newKey.ip)
|
||||
}
|
||||
}
|
||||
|
@ -76,11 +76,8 @@ func main() {
|
|||
|
||||
func isBetter(oldID, newID []byte) bool {
|
||||
for idx := range oldID {
|
||||
if newID[idx] > oldID[idx] {
|
||||
return true
|
||||
}
|
||||
if newID[idx] < oldID[idx] {
|
||||
return false
|
||||
if newID[idx] != oldID[idx] {
|
||||
return newID[idx] > oldID[idx]
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
|
|
@ -60,8 +60,8 @@ func readConfig(useconf *bool, useconffile *string, normaliseconf *bool) *config
|
|||
// throwing everywhere when it's converting things into UTF-16 for the hell
|
||||
// of it - remove it and decode back down into UTF-8. This is necessary
|
||||
// because hjson doesn't know what to do with UTF-16 and will panic
|
||||
if bytes.Compare(conf[0:2], []byte{0xFF, 0xFE}) == 0 ||
|
||||
bytes.Compare(conf[0:2], []byte{0xFE, 0xFF}) == 0 {
|
||||
if bytes.Equal(conf[0:2], []byte{0xFF, 0xFE}) ||
|
||||
bytes.Equal(conf[0:2], []byte{0xFE, 0xFF}) {
|
||||
utf := unicode.UTF16(unicode.BigEndian, unicode.UseBOM)
|
||||
decoder := utf.NewDecoder()
|
||||
conf, err = decoder.Bytes(conf)
|
||||
|
@ -222,7 +222,7 @@ func main() {
|
|||
getNodeID := func() *crypto.NodeID {
|
||||
if pubkey, err := hex.DecodeString(cfg.EncryptionPublicKey); err == nil {
|
||||
var box crypto.BoxPubKey
|
||||
copy(box[:], pubkey[:])
|
||||
copy(box[:], pubkey)
|
||||
return crypto.GetNodeID(&box)
|
||||
}
|
||||
return nil
|
||||
|
@ -328,9 +328,9 @@ func main() {
|
|||
// deferred Stop function above will run which will shut down TUN/TAP.
|
||||
for {
|
||||
select {
|
||||
case _ = <-c:
|
||||
case <-c:
|
||||
goto exit
|
||||
case _ = <-r:
|
||||
case <-r:
|
||||
if *useconffile != "" {
|
||||
cfg = readConfig(useconf, useconffile, normaliseconf)
|
||||
logger.Infoln("Reloading configuration from", *useconffile)
|
||||
|
|
|
@ -78,8 +78,8 @@ func run() int {
|
|||
|
||||
if *server == endpoint {
|
||||
if config, err := ioutil.ReadFile(defaults.GetDefaults().DefaultConfigFile); err == nil {
|
||||
if bytes.Compare(config[0:2], []byte{0xFF, 0xFE}) == 0 ||
|
||||
bytes.Compare(config[0:2], []byte{0xFE, 0xFF}) == 0 {
|
||||
if bytes.Equal(config[0:2], []byte{0xFF, 0xFE}) ||
|
||||
bytes.Equal(config[0:2], []byte{0xFE, 0xFF}) {
|
||||
utf := unicode.UTF16(unicode.BigEndian, unicode.UseBOM)
|
||||
decoder := utf.NewDecoder()
|
||||
config, err = decoder.Bytes(config)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue