remove metric stuff, there's already enough new stuff to test, maybe revisit this in a future release

This commit is contained in:
Arceliar 2021-05-24 18:53:54 -05:00
parent c60dd42baa
commit 8a60c605f6
6 changed files with 8 additions and 31 deletions

2
go.mod
View File

@ -3,7 +3,7 @@ module github.com/yggdrasil-network/yggdrasil-go
go 1.16
require (
github.com/Arceliar/ironwood v0.0.0-20210523223424-d320cf0ed78e
github.com/Arceliar/ironwood v0.0.0-20210522034542-c2e274961490
github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979
github.com/cheggaaa/pb/v3 v3.0.6
github.com/fatih/color v1.10.0 // indirect

4
go.sum
View File

@ -1,5 +1,5 @@
github.com/Arceliar/ironwood v0.0.0-20210523223424-d320cf0ed78e h1:EoZ4Dfm3xBDFjXRUzZUH+44NVvQ8tLf/VyESuC0BijI=
github.com/Arceliar/ironwood v0.0.0-20210523223424-d320cf0ed78e/go.mod h1:RP72rucOFm5udrnEzTmIWLRVGQiV/fSUAQXJ0RST/nk=
github.com/Arceliar/ironwood v0.0.0-20210522034542-c2e274961490 h1:z1Rd8RMNVrpNYIXHn7f62wz8nbuPkJFs9Z24sHIhNrc=
github.com/Arceliar/ironwood v0.0.0-20210522034542-c2e274961490/go.mod h1:RP72rucOFm5udrnEzTmIWLRVGQiV/fSUAQXJ0RST/nk=
github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979 h1:WndgpSW13S32VLQ3ugUxx2EnnWmgba1kCqPkd4Gk1yQ=
github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979/go.mod h1:6Lkn+/zJilRMsKmbmG1RPoamiArC6HS73xbwRyp3UyI=
github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM=

View File

@ -8,7 +8,6 @@ import (
"io"
"net"
"net/url"
"strconv"
"strings"
"sync"
@ -53,7 +52,6 @@ type link struct {
type linkOptions struct {
pinnedEd25519Keys map[keyArray]struct{}
metric uint8
}
func (l *links) init(c *Core) error {
@ -91,10 +89,6 @@ func (l *links) call(u *url.URL, sintf string) error {
}
}
}
if ms := u.Query()["metric"]; len(ms) == 1 {
m64, _ := strconv.ParseUint(ms[0], 10, 8)
tcpOpts.metric = uint8(m64)
}
switch u.Scheme {
case "tcp":
l.tcp.call(u.Host, tcpOpts, sintf)
@ -147,8 +141,6 @@ func (intf *link) handler() (chan struct{}, error) {
defer intf.conn.Close()
meta := version_getBaseMetadata()
meta.key = intf.links.core.public
meta.metric = intf.options.metric
metric := uint64(meta.metric)
metaBytes := meta.encode()
// TODO timeouts on send/recv (goroutine for send/recv, channel select w/ timer)
var err error
@ -181,9 +173,6 @@ 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,
@ -244,7 +233,7 @@ 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
err = intf.links.core.PacketConn.HandleConn(ed25519.PublicKey(intf.info.key[:]), intf.conn, metric)
err = intf.links.core.PacketConn.HandleConn(ed25519.PublicKey(intf.info.key[:]), intf.conn)
// TODO don't report an error if it's just a 'use of closed network connection'
if err != nil {
intf.links.core.log.Infof("Disconnected %s: %s, source %s; error: %s",

View File

@ -20,7 +20,6 @@ import (
"math/rand"
"net"
"net/url"
"strconv"
"strings"
"sync"
"time"
@ -172,11 +171,6 @@ func (t *tcp) reconfigure() {
}
func (t *tcp) listenURL(u *url.URL, sintf string) (*TcpListener, error) {
var metric uint8
if ms := u.Query()["metric"]; len(ms) == 1 {
m64, _ := strconv.ParseUint(ms[0], 10, 8)
metric = uint8(m64)
}
var listener *TcpListener
var err error
hostport := u.Host // Used for tcp and tls
@ -188,16 +182,16 @@ func (t *tcp) listenURL(u *url.URL, sintf string) (*TcpListener, error) {
}
switch u.Scheme {
case "tcp":
listener, err = t.listen(hostport, nil, metric)
listener, err = t.listen(hostport, nil)
case "tls":
listener, err = t.listen(hostport, t.tls.forListener, metric)
listener, err = t.listen(hostport, t.tls.forListener)
default:
t.links.core.log.Errorln("Failed to add listener: listener", u.String(), "is not correctly formatted, ignoring")
}
return listener, err
}
func (t *tcp) listen(listenaddr string, upgrade *TcpUpgrade, metric uint8) (*TcpListener, error) {
func (t *tcp) listen(listenaddr string, upgrade *TcpUpgrade) (*TcpListener, error) {
var err error
ctx := context.Background()
@ -211,7 +205,6 @@ func (t *tcp) listen(listenaddr string, upgrade *TcpUpgrade, metric uint8) (*Tcp
opts: tcpOptions{upgrade: upgrade},
stop: make(chan struct{}),
}
l.opts.metric = metric
t.waitgroup.Add(1)
go t.listener(&l, listenaddr)
return &l, nil

View File

@ -14,7 +14,6 @@ type version_metadata struct {
ver uint8 // 1 byte in this version
// Everything after this point potentially depends on the version number, and is subject to change in future versions
minorVer uint8 // 1 byte in this version
metric uint8 // 1 byte in this version
key ed25519.PublicKey
}
@ -32,7 +31,6 @@ func version_getMetaLength() (mlen int) {
mlen += 4 // meta
mlen++ // ver, as long as it's < 127, which it is in this version
mlen++ // minorVer, as long as it's < 127, which it is in this version
mlen++ // metric
mlen += ed25519.PublicKeySize // key
return
}
@ -43,7 +41,6 @@ func (m *version_metadata) encode() []byte {
bs = append(bs, m.meta[:]...)
bs = append(bs, m.ver)
bs = append(bs, m.minorVer)
bs = append(bs, m.metric)
bs = append(bs, m.key[:]...)
if len(bs) != version_getMetaLength() {
panic("Inconsistent metadata length")
@ -60,7 +57,6 @@ func (m *version_metadata) decode(bs []byte) bool {
offset += copy(m.meta[:], bs[offset:])
m.ver, offset = bs[offset], offset+1
m.minorVer, offset = bs[offset], offset+1
m.metric, offset = bs[offset], offset+1
m.key = append([]byte(nil), bs[offset:]...)
return true
}

View File

@ -274,8 +274,7 @@ func (m *Multicast) _announce() {
var info *listenerInfo
if nfo, ok := m.listeners[iface.Name]; !ok || nfo.listener.Listener == nil {
// No listener was found - let's create one
var metric uint8 // TODO parse this from the config
urlString := fmt.Sprintf("tcp://[%s]:%d/?metric=%d", addrIP, m.listenPort, metric)
urlString := fmt.Sprintf("tcp://[%s]:%d", addrIP, m.listenPort)
u, err := url.Parse(urlString)
if err != nil {
panic(err)