diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2025-04-11 16:27:21 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2025-04-11 16:27:21 -0400 |
| commit | c96c4c73648ee4cad3761cb5c78ef0c87527966d (patch) | |
| tree | 367daa9b2fb01c0f572177b9872388a60be59492 /hosts | |
| parent | f1b5e0248df11839ae8b560f57eb5556ec3583ec (diff) | |
| download | hose-c96c4c73648ee4cad3761cb5c78ef0c87527966d.zip | |
split host and port when setting key of known host
Diffstat (limited to 'hosts')
| -rw-r--r-- | hosts/hosts.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/hosts/hosts.go b/hosts/hosts.go index d31ed5e..63433cb 100644 --- a/hosts/hosts.go +++ b/hosts/hosts.go @@ -17,8 +17,12 @@ var knownHostsFile = filepath.Join(xdg.DataHome, "hose", "known_hosts") // Set sets the public key of a remote host. // It replaces or creates an entry in the known hosts file. -func Set(host net.Addr, pubkey [32]byte) error { - addr, err := netip.ParseAddr(host.String()) +func Set(hostport net.Addr, pubkey [32]byte) error { + host, _, err := net.SplitHostPort(hostport.String()) + if err != nil { + return err + } + addr, err := netip.ParseAddr(host) if err != nil { return err } |