p2p

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const Rendezvous = "tunsgo-peers-0009"

Variables

This section is empty.

Functions

func LoadOrCreateIdentity

func LoadOrCreateIdentity() (crypto.PrivKey, error)

Types

type P2PServer

type P2PServer struct {
	// contains filtered or unexported fields
}

func NewP2PServer

func NewP2PServer(opts *opts.Options) (*P2PServer, error)

func (*P2PServer) GinHandler

func (s *P2PServer) GinHandler(c *gin.Context)

GinHandler godoc

@Summary		Universal P2P Proxy Tunnel
@Description	Proxies any HTTP request (GET, POST, PUT, DELETE, etc.) through the P2P network.
@Description	Uses a smart routing logic: local fetch if the host is allowed locally,
@Description	otherwise tunnels the raw traffic to a candidate P2P node.
@Tags			Proxy
@Accept			*/*
@Produce		*/*
@Param			url	path		string	true	"Full target URL"
@Success		200	{string}	string	"Proxied response"
@Failure		429	{json}		string	"Remote node slots busy"
@Failure		502	{json}		string	"No proxy nodes available"
@Router			/proxy/{url} [get]
@Router			/proxy/{url} [post]
@Router			/proxy/{url} [put]
@Router			/proxy/{url} [delete]

func (*P2PServer) Status

func (s *P2PServer) Status() *P2PStatus

func (*P2PServer) Stop

func (s *P2PServer) Stop()

type P2PStatus

type P2PStatus struct {
	PeerID         string              `json:"peer_id"`
	ListenAddrs    []string            `json:"listen_addrs"`
	TotalConns     int                 `json:"total_conns"`
	TunsPeersCount int                 `json:"tuns_peers_count"`
	KnownDomains   map[string][]string `json:"known_domains"`
	Peers          []*PeerDetail       `json:"peers_list"`
	ConnectedPeers []*PeerDetail       `json:"connected_peers_list"`
	OurPeers       []*models.PeerInfo  `json:"our_peers_list"`
}

type PeerDetail

type PeerDetail struct {
	ID        string    `json:"id"`
	Addrs     []string  `json:"addrs"`
	IsTuns    bool      `json:"is_tuns"`
	Latency   string    `json:"latency"`
	LastSeen  time.Time `json:"last_seen,omitempty"`
	Protocols []string  `json:"protocols"`
	Hosts     []string  `json:"hosts,omitempty"`
}

Directories

Path Synopsis
pex

Jump to

Keyboard shortcuts

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