Fix tiebreak in Yggdrasil demo (uses wrong key)
This commit is contained in:
parent
ce2517b9fb
commit
89d61c4877
|
@ -128,6 +128,10 @@ func (n *Node) DerivedServerName() string {
|
||||||
return hex.EncodeToString(n.SigningPublicKey())
|
return hex.EncodeToString(n.SigningPublicKey())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *Node) DerivedSessionName() string {
|
||||||
|
return hex.EncodeToString(n.EncryptionPublicKey())
|
||||||
|
}
|
||||||
|
|
||||||
func (n *Node) EncryptionPublicKey() []byte {
|
func (n *Node) EncryptionPublicKey() []byte {
|
||||||
edkey := n.SigningPublicKey()
|
edkey := n.SigningPublicKey()
|
||||||
return convert.Ed25519PublicKeyToCurve25519(edkey)
|
return convert.Ed25519PublicKeyToCurve25519(edkey)
|
||||||
|
|
|
@ -42,7 +42,7 @@ func (n *Node) listenFromYgg() {
|
||||||
var session *yamux.Session
|
var session *yamux.Session
|
||||||
// If the remote address is lower than ours then we'll be the
|
// If the remote address is lower than ours then we'll be the
|
||||||
// server. Otherwse we'll be the client.
|
// server. Otherwse we'll be the client.
|
||||||
if strings.Compare(conn.RemoteAddr().String(), n.DerivedServerName()) < 0 {
|
if strings.Compare(conn.RemoteAddr().String(), n.DerivedSessionName()) < 0 {
|
||||||
session, err = yamux.Server(conn, n.yamuxConfig())
|
session, err = yamux.Server(conn, n.yamuxConfig())
|
||||||
} else {
|
} else {
|
||||||
session, err = yamux.Client(conn, n.yamuxConfig())
|
session, err = yamux.Client(conn, n.yamuxConfig())
|
||||||
|
@ -105,7 +105,7 @@ func (n *Node) DialContext(ctx context.Context, network, address string) (net.Co
|
||||||
}
|
}
|
||||||
// If the remote address is lower than ours then we will be the
|
// If the remote address is lower than ours then we will be the
|
||||||
// server. Otherwise we'll be the client.
|
// server. Otherwise we'll be the client.
|
||||||
if strings.Compare(conn.RemoteAddr().String(), n.DerivedServerName()) < 0 {
|
if strings.Compare(conn.RemoteAddr().String(), n.DerivedSessionName()) < 0 {
|
||||||
session, err = yamux.Server(conn, n.yamuxConfig())
|
session, err = yamux.Server(conn, n.yamuxConfig())
|
||||||
} else {
|
} else {
|
||||||
session, err = yamux.Client(conn, n.yamuxConfig())
|
session, err = yamux.Client(conn, n.yamuxConfig())
|
||||||
|
|
Loading…
Reference in a new issue