Source File
connection.go
Belonging Package
golang.org/x/crypto/ssh
// Copyright 2013 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package sshimport ()// OpenChannelError is returned if the other side rejects an// OpenChannel request.type OpenChannelError struct {Reason RejectionReasonMessage string}func ( *OpenChannelError) () string {return fmt.Sprintf("ssh: rejected: %s (%q)", .Reason, .Message)}// ConnMetadata holds metadata for the connection.type ConnMetadata interface {// User returns the user ID for this connection.User() string// SessionID returns the session hash, also denoted by H.SessionID() []byte// ClientVersion returns the client's version string as hashed// into the session ID.ClientVersion() []byte// ServerVersion returns the server's version string as hashed// into the session ID.ServerVersion() []byte// RemoteAddr returns the remote address for this connection.RemoteAddr() net.Addr// LocalAddr returns the local address for this connection.LocalAddr() net.Addr}// Conn represents an SSH connection for both server and client roles.// Conn is the basis for implementing an application layer, such// as ClientConn, which implements the traditional shell access for// clients.type Conn interface {ConnMetadata// SendRequest sends a global request, and returns the// reply. If wantReply is true, it returns the response status// and payload. See also RFC 4254, section 4.SendRequest(name string, wantReply bool, payload []byte) (bool, []byte, error)// OpenChannel tries to open an channel. If the request is// rejected, it returns *OpenChannelError. On success it returns// the SSH Channel and a Go channel for incoming, out-of-band// requests. The Go channel must be serviced, or the// connection will hang.OpenChannel(name string, data []byte) (Channel, <-chan *Request, error)// Close closes the underlying network connectionClose() error// Wait blocks until the connection has shut down, and returns the// error causing the shutdown.Wait() error// TODO(hanwen): consider exposing:// RequestKeyChange// Disconnect}// AlgorithmsConnMetadata is a ConnMetadata that can return the algorithms// negotiated between client and server in the last completed key exchange.// The ConnMetadata passed to the ServerConfig callbacks implements it, as do// the Conn returned by NewClientConn and the Conn embedded in Client and// ServerConn. For a Conn returned by NewControlClientConn, Algorithms returns// the zero value.type AlgorithmsConnMetadata interface {ConnMetadataAlgorithms() NegotiatedAlgorithms}// DiscardRequests consumes and rejects all requests from the// passed-in channel.func ( <-chan *Request) {for := range {if .WantReply {.Reply(false, nil)}}}// A connTransport represents the transport for a connection.type connTransport interface {packetConngetAlgorithms() NegotiatedAlgorithmsgetSessionID() []bytewaitSession() error}// A connection represents an incoming connection.type connection struct {transport connTransportsshConn// The connection protocol.*mux}func ( *connection) () error {return .sshConn.conn.Close()}// sshConn provides net.Conn metadata, but disallows direct reads and// writes.type sshConn struct {conn net.Connuser stringsessionID []byteclientVersion []byteserverVersion []byte}func dup( []byte) []byte {:= make([]byte, len())copy(, )return}func ( *sshConn) () string {return .user}func ( *sshConn) () net.Addr {return .conn.RemoteAddr()}func ( *sshConn) () error {return .conn.Close()}func ( *sshConn) () net.Addr {return .conn.LocalAddr()}func ( *sshConn) () []byte {return dup(.sessionID)}func ( *sshConn) () []byte {return dup(.clientVersion)}func ( *sshConn) () []byte {return dup(.serverVersion)}func ( *connection) () NegotiatedAlgorithms {return .transport.getAlgorithms()}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |