Skip to content
Snippets Groups Projects
Commit 6acec35f authored by capossele's avatar capossele
Browse files

:art: adds pubIP to the transport

parent 16c7e44d
No related branches found
No related tags found
No related merge requests found
......@@ -56,7 +56,7 @@ func (t *TCP) validateHandshakeRequest(reqData []byte, fromAddr string) bool {
)
return false
}
if m.GetTo() != t.LocalAddr().String() {
if m.GetTo() != t.pubIP {
t.log.Debugw("invalid handshake",
"to", m.GetTo(),
)
......
......@@ -41,6 +41,7 @@ const (
// TCP establishes verified incoming and outgoing TCP connections to other peers.
type TCP struct {
local *peer.Local
pubIP string
listener *net.TCPListener
log *zap.SugaredLogger
......@@ -85,6 +86,8 @@ func Listen(local *peer.Local, log *zap.SugaredLogger) (*TCP, error) {
return nil, ErrNoGossip
}
t.pubIP = gossipAddr.String()
host, port, _ := net.SplitHostPort(gossipAddr.String())
if host != "127.0.0.1" {
host = "0.0.0.0"
......@@ -300,7 +303,10 @@ func (t *TCP) listenLoop() {
}
func (t *TCP) doHandshake(key peer.PublicKey, remoteAddr string, conn net.Conn) error {
reqData, err := newHandshakeRequest(conn.LocalAddr().String(), remoteAddr)
_, connPort, _ := net.SplitHostPort(conn.LocalAddr().String())
from, _, _ := net.SplitHostPort(t.pubIP)
reqData, err := newHandshakeRequest(from+":"+connPort, remoteAddr)
if err != nil {
return err
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment