Documentation ¶
Index ¶
- Constants
- Variables
- func GetRelayAddrAndDstPeerAddr(addr ma.Multiaddr) (relayAddr, dstAddr ma.Multiaddr, err error)
- func IsRelayAddr(addr ma.Multiaddr) bool
- func PeerInfoToRelayPeer(peerId peer.ID, peerAddr []ma.Multiaddr) *pb.RelayMsg_Peer
- func ReadRelayMsg(stream network.Stream) (*pb.RelayMsg, error)
- func RelayPeerToPeerInfo(p *pb.RelayMsg_Peer) (peer.ID, []ma.Multiaddr, error)
- func WriteRelayMsg(s network.Stream, msg *pb.RelayMsg) error
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) Read(buf []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(buf []byte) (int, error)
- type NetAddr
- type Relay
- type RelayOpt
Constants ¶
const Relay_Protocol_ID = "liquid-relay"
Relay_Protocol_ID the relay protocolID
Variables ¶
var ( // RelayAcceptTimeout . RelayAcceptTimeout = 10 * time.Second // HopConnectTimeout the relay hop connect timeout HopConnectTimeout = 30 * time.Second // StopHandshakeTimeout the relay stop handshake timeout StopHandshakeTimeout = 1 * time.Minute // HopStreamLimit . HopStreamLimit = 1 << 19 // 512K hops for 1M goroutines )
Functions ¶
func GetRelayAddrAndDstPeerAddr ¶
GetRelayAddrAndDstPeerAddr cut to obtain the address of the relay source node and destination node
func IsRelayAddr ¶
IsRelayAddr is the relay's muliaddr addr
func PeerInfoToRelayPeer ¶
PeerInfoToRelayPeer return the pb.RelayMsg_Peer
func ReadRelayMsg ¶
ReadRelayMsg 在stream读出pb.RelayMsg格式的信息
func RelayPeerToPeerInfo ¶
RelayPeerToPeerInfo the pb.RelayMsg_Peer to peerId and addr
Types ¶
type Conn ¶
Conn the relay conn (sAR/sRB)
func (*Conn) LocalAddr ¶
LocalAddr return the relay stream LocalNetAddr
func (*Conn) RemoteAddr ¶
RemoteAddr return the relay stream RemoteNetAddr
func (*Conn) SetDeadline ¶
SetDeadline in order to implement the net.Conn interface
func (*Conn) SetReadDeadline ¶
SetReadDeadline in order to implement the net.Conn interface
func (*Conn) SetWriteDeadline ¶
SetWriteDeadline in order to implement the net.Conn interface
type Relay ¶
type Relay struct {
// contains filtered or unexported fields
}
Relay the relay struct
func NewRelay ¶
func NewRelay(ctx context.Context, peerId peer.ID, logger api.Logger, opts ...RelayOpt) (*Relay, error)
NewRelay return the relay struct
func (*Relay) Accept ¶
Accept deal with the received relay messages
func (*Relay) HandleHopStream ¶
HandleHopStream * 1) dial the target node and send a STOP message 2) wait for return and return a success message to the source node 3) copy the data from streams on both sides