Documentation ¶
Overview ¶
Package websocket implements a websocket based transport for go-libp2p.
Index ¶
- Variables
- func ConvertWebsocketMultiaddrToNetAddr(maddr ma.Multiaddr) (net.Addr, error)
- func ParseWebsocketNetAddr(a net.Addr) (ma.Multiaddr, 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 Option
- type WebsocketTransport
- func (t *WebsocketTransport) CanDial(a ma.Multiaddr) bool
- func (t *WebsocketTransport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (transport.CapableConn, error)
- func (t *WebsocketTransport) Listen(a ma.Multiaddr) (transport.Listener, error)
- func (t *WebsocketTransport) Protocols() []int
- func (t *WebsocketTransport) Proxy() bool
Constants ¶
This section is empty.
Variables ¶
var GracefulCloseTimeout = 100 * time.Millisecond
GracefulCloseTimeout is the time to wait trying to gracefully close a connection before simply cutting it.
WsFmt is multiaddr formatter for WsProtocol
Functions ¶
Types ¶
type Addr ¶
Addr is an implementation of net.Addr for WebSocket.
func NewAddr ¶
NewAddr creates an Addr with `ws` scheme (insecure).
Deprecated. Use NewAddrWithScheme.
func NewAddrWithScheme ¶
NewAddrWithScheme creates a new Addr using the given host string. isSecure should be true for WSS connections and false for WS.
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 Option ¶
type Option func(*WebsocketTransport) error
func WithTLSClientConfig ¶
WithTLSClientConfig sets a TLS client configuration on the WebSocket Dialer. Only relevant for non-browser usages.
Some useful use cases include setting InsecureSkipVerify to `true`, or setting user-defined trusted CA certificates.
func WithTLSConfig ¶
WithTLSConfig sets a TLS configuration for the WebSocket listener.
type WebsocketTransport ¶
type WebsocketTransport struct {
// contains filtered or unexported fields
}
WebsocketTransport is the actual go-libp2p transport
func New ¶
func New(u transport.Upgrader, rcmgr network.ResourceManager, opts ...Option) (*WebsocketTransport, error)
func (*WebsocketTransport) Dial ¶
func (t *WebsocketTransport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (transport.CapableConn, error)
func (*WebsocketTransport) Protocols ¶
func (t *WebsocketTransport) Protocols() []int
func (*WebsocketTransport) Proxy ¶
func (t *WebsocketTransport) Proxy() bool