diff options
Diffstat (limited to 'handshake/receive.go')
| -rw-r--r-- | handshake/receive.go | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/handshake/receive.go b/handshake/receive.go index 986b967..b2a0aa7 100644 --- a/handshake/receive.go +++ b/handshake/receive.go @@ -12,6 +12,7 @@ import ( "git.samanthony.xyz/hose/hosts" "git.samanthony.xyz/hose/key" + hose_net "git.samanthony.xyz/hose/net" "git.samanthony.xyz/hose/util" ) @@ -27,7 +28,7 @@ var errVerifyKey = errors.New("host key verification failed") // receive receives the public keys of a remote host. // The user is asked to verify the keys before they are saved to the known hosts file. func receive(rhost string) error { - conn, err := acceptConnection() + conn, err := hose_net.AcceptConnection(network, port) if err != nil { return err } @@ -56,17 +57,6 @@ func receive(rhost string) error { return hosts.Add(hosts.Host{raddr, rBoxPubKey, rSigPubKey}) } -func acceptConnection() (net.Conn, error) { - laddr := net.JoinHostPort("", port) - ln, err := net.Listen(network, laddr) - if err != nil { - return nil, err - } - defer ln.Close() - util.Logf("listening on %s", laddr) - return ln.Accept() -} - func receiveKeys(conn net.Conn) (key.BoxPublicKey, key.SigPublicKey, error) { // Receive public box (encryption) key from remote host. var rBoxPubKey key.BoxPublicKey |