Client wraps ClientDeferred and immediately invokes the returned continuation with conn. This is a helper for when you don't need the fancy continuation-style handshake, and just want to synchronously upgrade a net.Conn to a secure transport.
(ctx context.Context, conn net.Conn, machineKey key.MachinePrivate, controlKey key.MachinePublic, protocolVersion uint16)
| 107 | // continuation-style handshake, and just want to synchronously |
| 108 | // upgrade a net.Conn to a secure transport. |
| 109 | func Client(ctx context.Context, conn net.Conn, machineKey key.MachinePrivate, controlKey key.MachinePublic, protocolVersion uint16) (*Conn, error) { |
| 110 | init, cont, err := ClientDeferred(machineKey, controlKey, protocolVersion) |
| 111 | if err != nil { |
| 112 | return nil, err |
| 113 | } |
| 114 | if _, err := conn.Write(init); err != nil { |
| 115 | return nil, err |
| 116 | } |
| 117 | return cont(ctx, conn) |
| 118 | } |
| 119 | |
| 120 | func continueClientHandshake(ctx context.Context, conn net.Conn, s *symmetricState, machineKey, machineEphemeral key.MachinePrivate, controlKey key.MachinePublic, protocolVersion uint16) (*Conn, error) { |
| 121 | // No matter what, this function can only run once per s. Ensure |
searching dependent graphs…