diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2025-04-11 16:07:37 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2025-04-11 16:07:37 -0400 |
| commit | fe46729489026b3c26dda79280e7b876ee09ae37 (patch) | |
| tree | 5b4f904807174bc7619205ae5c338910cae4274c | |
| parent | 51936d969e9469b30c04fec46ef5582d0e52b766 (diff) | |
| download | hose-fe46729489026b3c26dda79280e7b876ee09ae37.zip | |
split host and port of remote addr
| -rw-r--r-- | handshake.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/handshake.go b/handshake.go index 66fed12..09408ec 100644 --- a/handshake.go +++ b/handshake.go @@ -74,7 +74,7 @@ func handshakeRecv(rhost string) error { if err != nil { return err } - util.Logf("received public key from $s", conn.RemoteAddr()) + util.Logf("received public key from %s", conn.RemoteAddr()) // Ask user to verify the fingerprint of the key. ok, err := verifyPublicKey(conn.RemoteAddr(), rpubkey) @@ -93,7 +93,11 @@ func handshakeRecv(rhost string) error { // It returns true if the user accepts the fingerprint, or false if they don't, or a non-nil error. func verifyPublicKey(addr net.Addr, pubkey [32]byte) (bool, error) { // Lookup human-friendly name of remote host, or fall back to the address. - hostname, err := lookupAddr(addr.String()) + host, _, err := net.SplitHostPort(addr.String()) + if err != nil { + return false, err + } + hostname, err := lookupAddr(host) if err != nil { return false, err } |