Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertWebsocketMultiaddrToNetAddr(maddr ma.Multiaddr) (net.Addr, error)
- func ParseWebsocketNetAddr(a net.Addr) (ma.Multiaddr, error)
- func PrivKey2SSH(key ic.PrivKey) (ssh.Signer, error)
- type Addr
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) Read(b []byte) (int, error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) Write(b []byte) (n int, err error)
- type SSHConn
- func (c *SSHConn) AcceptStream() (mux.MuxedStream, error)
- func (c *SSHConn) Close() error
- func (c *SSHConn) GetStreams() []network.Stream
- func (c *SSHConn) ID() string
- func (c *SSHConn) IsClosed() bool
- func (c *SSHConn) LocalMultiaddr() ma.Multiaddr
- func (c *SSHConn) LocalPeer() peer.ID
- func (c *SSHConn) LocalPrivateKey() ic.PrivKey
- func (c *SSHConn) NewStream() (network.Stream, error)
- func (c *SSHConn) OpenStream() (mux.MuxedStream, error)
- func (c *SSHConn) RemoteMultiaddr() ma.Multiaddr
- func (c *SSHConn) RemotePeer() peer.ID
- func (c *SSHConn) RemotePublicKey() ic.PubKey
- func (c *SSHConn) Stat() network.Stat
- func (c *SSHConn) Transport() transport.Transport
- type SSHTransport
- func (t *SSHTransport) CanDial(a ma.Multiaddr) bool
- func (t *SSHTransport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (transport.CapableConn, error)
- func (t *SSHTransport) Listen(a ma.Multiaddr) (transport.Listener, error)
- func (t *SSHTransport) NewCapableConn(nc net.Conn, isServer bool) (transport.CapableConn, error)
- func (t *SSHTransport) NewConn(nc net.Conn, isServer bool) (mux.MuxedConn, error)
- func (t *SSHTransport) Protocols() []int
- func (t *SSHTransport) Proxy() bool
Constants ¶
const PROTO_SSH = "/ssh/1.0"
Variables ¶
var GracefulCloseTimeout = 100 * time.Millisecond
GracefulCloseTimeout is the time to wait trying to gracefully close a connection before simply cutting it.
var WsCodec = &manet.NetCodec{ NetAddrNetworks: []string{"ws"}, ProtocolName: "ws", ConvertMultiaddr: ConvertWebsocketMultiaddrToNetAddr, ParseNetAddr: ParseWebsocketNetAddr, }
WsCodec is the multiaddr-net codec definition for the websocket transport
WsFmt is multiaddr formatter for WsProtocol
Functions ¶
Types ¶
type Addr ¶
Addr is an implementation of net.Addr for WebSocket.
type Conn ¶
Conn implements net.Conn interface for gorilla/websocket.
func (*Conn) Close ¶
Close closes the connection. Only the first call to Close will receive the close error, subsequent and concurrent calls will return nil. This method is thread-safe.
func (*Conn) RemoteAddr ¶
type SSHConn ¶
type SSHConn struct { LastSeen time.Time ConnectTime time.Time // contains filtered or unexported fields }
Conn is a connection to a remote peer, implements CapableConn ( MuxedConn, network.ConnSecurity, network.ConnMultiaddrs Transport())
implements MuxedConn (OpenStream/AcceptStream, Close/IsClosed)
func (*SSHConn) AcceptStream ¶
func (c *SSHConn) AcceptStream() (mux.MuxedStream, error)
AcceptStream accepts a stream opened by the other side.
func (*SSHConn) GetStreams ¶
func (*SSHConn) LocalMultiaddr ¶
func (*SSHConn) LocalPrivateKey ¶
func (*SSHConn) OpenStream ¶
func (c *SSHConn) OpenStream() (mux.MuxedStream, error)
OpenStream creates a new stream. This uses the same channel in both directions.
func (*SSHConn) RemoteMultiaddr ¶
func (*SSHConn) RemotePeer ¶
func (*SSHConn) RemotePublicKey ¶
type SSHTransport ¶
type SSHTransport struct { Prefix string Mux *http.ServeMux Gater connmgr.ConnectionGater Psk pnet.PSK Key ic.PrivKey // contains filtered or unexported fields }
SSHTransport is the actual go-libp2p transport
func NewSSHTransport ¶
func NewSSHTransport(key ic.PrivKey, psk pnet.PSK, gater connmgr.ConnectionGater) (*SSHTransport, error)
NewWsSshTransport creates a new transport using Websocket and SSH Based on QUIC transport.
func (*SSHTransport) Dial ¶
func (t *SSHTransport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (transport.CapableConn, error)
Dial creates a secure multiplexed CapableConn to the peer identified by a public key, using an address. The ID is derived from the proto-representation of the key - either SHA256 or the actual key if len <= 42
func (*SSHTransport) NewCapableConn ¶
func (t *SSHTransport) NewCapableConn(nc net.Conn, isServer bool) (transport.CapableConn, error)
NewConn wraps a net.Conn using SSH for MUX and security.
func (*SSHTransport) NewConn ¶
SSH transport implements the Multiplexer interface, can be used with other transports. The result is also a CapableConn, so no need for the extra security.
func (*SSHTransport) Protocols ¶
func (t *SSHTransport) Protocols() []int
func (*SSHTransport) Proxy ¶
func (t *SSHTransport) Proxy() bool