5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-23 05:21:35 +00:00

Info logging when link connects/disconnects

This commit is contained in:
Neil Alexander 2019-01-31 23:18:02 +00:00
parent 05962b2cbd
commit e36f88c75f
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -3,10 +3,13 @@ package yggdrasil
import ( import (
"errors" "errors"
"fmt" "fmt"
"net"
"strings"
"sync" "sync"
//"sync/atomic" //"sync/atomic"
"time" "time"
"github.com/yggdrasil-network/yggdrasil-go/src/address"
"github.com/yggdrasil-network/yggdrasil-go/src/crypto" "github.com/yggdrasil-network/yggdrasil-go/src/crypto"
"github.com/yggdrasil-network/yggdrasil-go/src/util" "github.com/yggdrasil-network/yggdrasil-go/src/util"
) )
@ -143,7 +146,22 @@ func (intf *linkInterface) handler() error {
out <- msg out <- msg
} }
intf.peer.linkOut = make(chan []byte, 1) intf.peer.linkOut = make(chan []byte, 1)
intf.peer.close = func() { intf.msgIO.close() } intf.peer.close = func() {
intf.msgIO.close()
// Make output
themAddr := address.AddrForNodeID(crypto.GetNodeID(&intf.info.box))
themAddrString := net.IP(themAddr[:]).String()
themString := fmt.Sprintf("%s@%s", themAddrString, intf.info.remote)
intf.link.core.log.Infof("Disconnected %s: %s, source %s",
strings.ToUpper(intf.info.linkType), themString, intf.info.local)
}
// Make output
themAddr := address.AddrForNodeID(crypto.GetNodeID(&intf.info.box))
themAddrString := net.IP(themAddr[:]).String()
themString := fmt.Sprintf("%s@%s", themAddrString, intf.info.remote)
intf.link.core.log.Infof("Connected %s: %s, source %s",
strings.ToUpper(intf.info.linkType), themString, intf.info.local)
// Start the link loop
go intf.peer.linkLoop() go intf.peer.linkLoop()
// Start the writer // Start the writer
signalReady := make(chan struct{}, 1) signalReady := make(chan struct{}, 1)