5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-10 06:20:26 +00:00

version check/warning adjustments

This commit is contained in:
Arceliar 2018-06-09 18:38:30 -05:00
parent 076350f963
commit 72cca4ea43

View File

@ -157,18 +157,14 @@ func (iface *tcpInterface) handler(sock net.Conn, incoming bool) {
} }
timeout := time.Now().Add(6 * time.Second) timeout := time.Now().Add(6 * time.Second)
sock.SetReadDeadline(timeout) sock.SetReadDeadline(timeout)
n, err := sock.Read(metaBytes) _, err = sock.Read(metaBytes)
if err != nil { if err != nil {
return return
} }
if n != version_getMetaLength() {
return
}
meta = version_metadata{} // Reset to zero value meta = version_metadata{} // Reset to zero value
if !meta.decode(metaBytes) { if !meta.decode(metaBytes) || !meta.check() {
return // Failed to decode and check the metadata
} // If it's a version mismatch issue, then print an error message
if !meta.check() {
base := version_getBaseMetadata() base := version_getBaseMetadata()
if meta.meta == base.meta { if meta.meta == base.meta {
if meta.ver > base.ver { if meta.ver > base.ver {
@ -177,6 +173,7 @@ func (iface *tcpInterface) handler(sock net.Conn, incoming bool) {
iface.core.log.Println("Failed to connect to node:", sock.RemoteAddr().String(), "version:", fmt.Sprintf("%d.%d", meta.ver, meta.minorVer)) iface.core.log.Println("Failed to connect to node:", sock.RemoteAddr().String(), "version:", fmt.Sprintf("%d.%d", meta.ver, meta.minorVer))
} }
} }
// TODO? Block forever to prevent future connection attempts? suppress future messages about the same node?
return return
} }
info := tcpInfo{ // used as a map key, so don't include ephemeral link key info := tcpInfo{ // used as a map key, so don't include ephemeral link key