mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
add metric to metadata exchange, but currently left at default 0 value
This commit is contained in:
parent
6bc2044ced
commit
58af92812e
2 changed files with 9 additions and 1 deletions
|
@ -158,6 +158,8 @@ func (intf *link) handler() (chan struct{}, error) {
|
|||
defer intf.conn.Close()
|
||||
meta := version_getBaseMetadata()
|
||||
meta.key = intf.links.core.public
|
||||
// TODO set meta.metric
|
||||
metric := uint64(meta.metric)
|
||||
metaBytes := meta.encode()
|
||||
// TODO timeouts on send/recv (goroutine for send/recv, channel select w/ timer)
|
||||
var err error
|
||||
|
@ -190,6 +192,9 @@ func (intf *link) handler() (chan struct{}, error) {
|
|||
if !meta.decode(metaBytes) {
|
||||
return nil, errors.New("failed to decode metadata")
|
||||
}
|
||||
if metric < uint64(meta.metric) {
|
||||
metric = uint64(meta.metric)
|
||||
}
|
||||
if !meta.check() {
|
||||
intf.links.core.log.Errorf("Failed to connect to node: %s is incompatible version (local %s, remote %s)",
|
||||
intf.lname,
|
||||
|
@ -250,7 +255,6 @@ func (intf *link) handler() (chan struct{}, error) {
|
|||
intf.links.core.log.Infof("Connected %s: %s, source %s",
|
||||
strings.ToUpper(intf.info.linkType), themString, intf.info.local)
|
||||
// Run the handler
|
||||
var metric uint64 // TODO exchange metric in matadata, use max value
|
||||
err = intf.links.core.PacketConn.HandleConn(ed25519.PublicKey(intf.info.key[:]), intf.conn, metric)
|
||||
// TODO don't report an error if it's just a 'use of closed network connection'
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue