p2p

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ProtocolID = "/chatssh/ssh/1.0.0"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ListenPort  int
	Bootnodes   []string
	EnableRelay bool
}

Config configures libp2p node creation.

type Node

type Node struct {
	Host host.Host
}

Node wraps a libp2p host with ChatSSH transport helpers.

func NewNode

func NewNode(ctx context.Context, cfg Config) (*Node, error)

NewNode creates a libp2p host with NAT traversal support.

func (*Node) Addrs

func (n *Node) Addrs() []string

Addrs returns the node's advertised multiaddresses.

func (*Node) Close

func (n *Node) Close() error

Close shuts down the libp2p host.

func (*Node) DialPeerByIP

func (n *Node) DialPeerByIP(ctx context.Context, ip string, port int) (net.Conn, error)

DialPeerByIP attempts connection using IP-based multiaddr patterns.

func (*Node) DialSSH

func (n *Node) DialSSH(ctx context.Context, target string) (net.Conn, error)

DialSSH opens a libp2p stream and wraps it as net.Conn.

func (*Node) ID

func (n *Node) ID() string

ID returns the peer ID string.

func (*Node) ListenSSH

func (n *Node) ListenSSH() net.Listener

ListenSSH registers a stream handler and returns a net.Listener adapter.

type StreamConn

type StreamConn struct {
	network.Stream
	// contains filtered or unexported fields
}

StreamConn wraps a libp2p stream as net.Conn for SSH.

func NewStreamConn

func NewStreamConn(s network.Stream) *StreamConn

NewStreamConn wraps a libp2p stream.

func (*StreamConn) Close

func (c *StreamConn) Close() error

func (*StreamConn) LocalAddr

func (c *StreamConn) LocalAddr() net.Addr

func (*StreamConn) Read

func (c *StreamConn) Read(b []byte) (int, error)

func (*StreamConn) RemoteAddr

func (c *StreamConn) RemoteAddr() net.Addr

func (*StreamConn) SetDeadline

func (c *StreamConn) SetDeadline(t time.Time) error

func (*StreamConn) SetReadDeadline

func (c *StreamConn) SetReadDeadline(t time.Time) error

func (*StreamConn) SetWriteDeadline

func (c *StreamConn) SetWriteDeadline(t time.Time) error

func (*StreamConn) Write

func (c *StreamConn) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址