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 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.
var WsCodec = &manet.NetCodec{ NetAddrNetworks: []string{"websocket"}, ProtocolName: "ws", ConvertMultiaddr: ConvertWebsocketMultiaddrToNetAddr, ParseNetAddr: ParseWebsocketNetAddr, }
WsCodec is the multiaddr-net codec definition for the websocket transport
var WsFmt = mafmt.And(mafmt.TCP, mafmt.Base(WsProtocol.Code))
WsFmt is multiaddr formatter for WsProtocol
var WsProtocol = ma.ProtocolWithCode(ma.P_WS)
WsProtocol is the multiaddr protocol definition for this transport.
Deprecated: use `ma.ProtocolWithCode(ma.P_WS)
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 WebsocketTransport ¶
WebsocketTransport is the actual go-libp2p transport
func New ¶
func New(u *tptu.Upgrader) *WebsocketTransport
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