Documentation ¶
Index ¶
- Constants
- func AddCircuitAddrsToPeer(peer *peer.AddrInfo, relayPeers RelayMap) error
- func AppendMultiaddrs(maddrs []ma.Multiaddr, dest ma.Multiaddr) []ma.Multiaddr
- func BootstrapConnect(ctx context.Context, ph p2phost.Host, bootstrapPeers RelayMap) error
- func CreateLimitOpt(config *v1alpha1.TunnelLimitConfig, opts ...rcmgr.Option) (libp2p.Option, error)
- func FilterCircuitMaddr(maddrs []ma.Multiaddr) []ma.Multiaddr
- func FilterPrivateMaddr(maddrs []ma.Multiaddr) []ma.Multiaddr
- func GenerateKeyPairWithString(s string) (crypto.PrivKey, error)
- func GenerateMultiAddrString(protocol, ip string, port int) string
- func GeneratePSKReader(path string) (io.Reader, error)
- func GeneratePeerInfo(hostname string, addrs []string) (*peer.AddrInfo, error)
- func GenerateTransportOption(protocol string) libp2p.Option
- func GetIPsFromInterfaces(listenInterfaces, extraFilteredInterfaces string) (ips []string, err error)
- func IsNoFindPeerError(err error) bool
- func PeerIDFromString(s string) (peer.ID, error)
- func Register(c *v1alpha1.EdgeTunnelConfig) error
- func StringsToMaddrs(addrStrings []string) (mas []ma.Multiaddr, err error)
- type EdgeTunnel
- func (t *EdgeTunnel) CNIAdapterStreamHandler(stream network.Stream)
- func (t *EdgeTunnel) Enable() bool
- func (t *EdgeTunnel) GetCNIAdapterStream(opts ProxyOptions) (*StreamConn, error)
- func (t *EdgeTunnel) GetProxyStream(opts ProxyOptions) (*StreamConn, error)
- func (t *EdgeTunnel) Group() string
- func (t *EdgeTunnel) Name() string
- func (t *EdgeTunnel) Run()
- func (t *EdgeTunnel) Shutdown()
- func (t *EdgeTunnel) Start()
- type ProxyOptions
- type RelayMap
- type StreamAddr
- type StreamConn
Constants ¶
const ( MaxReadSize = 4096 DailRetryTime = 3 DailSleepTime = 500 * time.Microsecond RetryTime = 3 RetryInterval = 2 * time.Second )
const ( UDP = "udp" TCP = "tcp" Websocket = "ws" Quic = "quic" )
Variables ¶
This section is empty.
Functions ¶
func AddCircuitAddrsToPeer ¶
func AppendMultiaddrs ¶
AppendMultiaddrs append a maddr into maddrs, do nothing if contains
func BootstrapConnect ¶
BootstrapConnect tries to connect to a list of bootstrap peers in a relay map. The function runs a loop to attempt connecting to each peer, and will retry if some peers fail to connect. The function returns an error if it fails to connect to all bootstrap peers after a certain period of time.
func CreateLimitOpt ¶ added in v1.13.0
func CreateLimitOpt(config *v1alpha1.TunnelLimitConfig, opts ...rcmgr.Option) (libp2p.Option, error)
func GenerateMultiAddrString ¶
GenerateMultiAddrString generate an IPv4 multi-address string by protocol, ip and port supported protocols: ["tcp", "ws", "quic"]
func GeneratePeerInfo ¶
func GenerateTransportOption ¶
func GenerateTransportOption(protocol string) libp2p.Option
GenerateTransportOption generate Transport option from protocol supported protocols: ["tcp", "ws", "quic"]
func GetIPsFromInterfaces ¶ added in v1.13.2
func IsNoFindPeerError ¶
func Register ¶
func Register(c *v1alpha1.EdgeTunnelConfig) error
Register edgetunnel to beehive modules
Types ¶
type EdgeTunnel ¶
type EdgeTunnel struct { Config *v1alpha1.EdgeTunnelConfig // contains filtered or unexported fields }
EdgeTunnel is used for solving cross subset communication
var Agent *EdgeTunnel
Agent expose the tunnel ability. TODO convert var to func
func (*EdgeTunnel) CNIAdapterStreamHandler ¶ added in v1.15.0
func (t *EdgeTunnel) CNIAdapterStreamHandler(stream network.Stream)
func (*EdgeTunnel) Enable ¶
func (t *EdgeTunnel) Enable() bool
Enable indicates whether enable this module
func (*EdgeTunnel) GetCNIAdapterStream ¶ added in v1.15.0
func (t *EdgeTunnel) GetCNIAdapterStream(opts ProxyOptions) (*StreamConn, error)
GetCNIAdapterStream establishes a new stream with a destination peer, either directly or through a relay node, use net.conn to get income data
func (*EdgeTunnel) GetProxyStream ¶
func (t *EdgeTunnel) GetProxyStream(opts ProxyOptions) (*StreamConn, error)
GetProxyStream establishes a new stream with a destination peer, either directly or through a relay node, by performing a handshake with the destination peer over the stream to confirm the connection. It first looks up the destination peer's ID in a cache, and if not found, generates the peer ID and adds circuit addresses to it. It then opens a new stream using the libp2p host, and performs a handshake with the destination peer over the stream. If the handshake is successful, it returns a new StreamConn object representing the stream. If any errors occur during the process, it returns an error.
func (*EdgeTunnel) Run ¶
func (t *EdgeTunnel) Run()
func (*EdgeTunnel) Shutdown ¶ added in v1.13.1
func (t *EdgeTunnel) Shutdown()
type ProxyOptions ¶
type StreamAddr ¶
type StreamAddr struct {
// contains filtered or unexported fields
}
StreamAddr implements the net.Addr interface
func (*StreamAddr) Network ¶
func (sa *StreamAddr) Network() string
func (*StreamAddr) String ¶
func (sa *StreamAddr) String() string
type StreamConn ¶
StreamConn is libp2p network.Stream wrapper, which implements the Golang net.Conn interface
func NewStreamConn ¶
func NewStreamConn(s network.Stream) *StreamConn
func (*StreamConn) LocalAddr ¶
func (ns *StreamConn) LocalAddr() net.Addr
LocalAddr returns the local network address.
func (*StreamConn) RemoteAddr ¶
func (ns *StreamConn) RemoteAddr() net.Addr
RemoteAddr returns the remote network address.