Documentation ¶
Index ¶
- Variables
- func AddDefaultRoute(interfaceName, gateway string) error
- func AddEndpointRoute(node host.Host, dht *dht.IpfsDHT, peerId string) error
- func CloseAllStreams()
- func Connect(node host.Host, dht *dht.IpfsDHT) gin.HandlerFunc
- func Disconnect(node host.Host, dht *dht.IpfsDHT) gin.HandlerFunc
- func DiscoverPeersWithKademlia(ctx context.Context, h host.Host, dht *dht.IpfsDHT)
- func GetConnectedPeersCount(node host.Host, mydht *dht.IpfsDHT) gin.HandlerFunc
- func GetLocalPeerDetails(node host.Host) gin.HandlerFunc
- func GetLocalPeerId(node host.Host) gin.HandlerFunc
- func GetPeerIPAddresses(node host.Host, dht *dht.IpfsDHT) gin.HandlerFunc
- func GetVPNStatus(c *gin.Context)
- func HandleExit()
- func IsTUNInterfaceUp(interfaceName string) (bool, error)
- func LoadPrivateKey() (crypto.PrivKey, error)
- func QuitSkypier(c *gin.Context)
- func RemoveInterface(ifaceName string) error
- func SetInterfaceDown() error
- func SetInterfaceUp() *water.Interface
- func SetNodeUp(ctx context.Context, config utils.InnerConfig) (host.Host, *dht.IpfsDHT)
- func StartNode(innerConfig utils.InnerConfig, pk crypto.PrivKey, tcpPort string, ...) (host.Host, *dht.IpfsDHT, error)
- func TestConnectivity(node host.Host, dht *dht.IpfsDHT) gin.HandlerFunc
- type SkypierNode
- type VPNStatus
Constants ¶
This section is empty.
Variables ¶
var (
InterfaceName = "utun8"
)
Functions ¶
func AddDefaultRoute ¶
AddDefaultRoute adds default routes to the specified network interface using the provided gateway. It does not remove the existing default route on the host but instead adds routes that cover the entire IPv4 address space.
Parameters: - interfaceName: The name of the network interface to which the routes will be added. - gateway: The IP address of the gateway to be used for the routes.
Returns: - error: An error object if any step in the process fails, otherwise nil.
The function performs the following steps: 1. Retrieves the network interface by its name. 2. Parses the gateway IP address. 3. Defines routes that cover the entire IPv4 address space using CIDR 0.0.0.0/1 and 128.0.0.0/1. 4. Parses each destination CIDR and creates a route object. 5. Adds each route to the network interface.
func AddEndpointRoute ¶
Add a static route to the endpoint using the main network interface for instance eth0 or en0 This is useful for setting up a VPN connection to a remote server The IP address of the remote server is passed as a string The function returns an error if the route could not be added AddEndpointRoute adds a route to the destination peer IP
func CloseAllStreams ¶
func CloseAllStreams()
CloseAllStreams closes all active streams in the streams mapping.
func Connect ¶
Connect godoc @Summary Connect to a remote libp2p peer and enable new Stream @Description Connect to a remote libp2p peer and enable new Stream @Tags VPN @Produce json @Param peerId path string true "Peer ID" @Router /connect/{peerId} [get]
func Disconnect ¶
Disconnect function to handle the disconnect endpoint
func DiscoverPeersWithKademlia ¶
DiscoverPeers performs a general Kademlia DHT discovery for Skypier peers.
func GetConnectedPeersCount ¶
GetConnectedPeersCount godoc @Summary Get the ConnectedPeers Count @Description Get the ConnectedPeers Count @Tags VPN @Produce json @Router /connected_peers_count [get]
func GetLocalPeerDetails ¶
func GetLocalPeerDetails(node host.Host) gin.HandlerFunc
GetLocalPeerDetails godoc @Summary Get the local peer details @Description Get the local libp2p peer ID and details (OS, uptime, version, etc.) @Tags VPN @Produce json @Router /me [get]
func GetLocalPeerId ¶
func GetLocalPeerId(node host.Host) gin.HandlerFunc
GetLocalPeerId godoc @Summary Get the local peer ID @Description Get the local libp2p peer ID (this is the identity of your node on the Skypier Network) @Tags VPN @Produce json @Router /id [get]
func GetPeerIPAddresses ¶
GetPeerIPAddresses godoc @Summary Get the IP addresses of a remote peer through the DHT @Description Get the IP addresses of a remote peer through the DHT @Tags VPN @Produce json @Param peerId path string true "Peer ID" @Router /peer/{peerId}/info [get]
func GetVPNStatus ¶
func HandleExit ¶
func HandleExit()
func IsTUNInterfaceUp ¶
IsTUNInterfaceUp checks if a TUN interface is up on the machine for a given name.
func QuitSkypier ¶
func RemoveInterface ¶
func SetInterfaceDown ¶
func SetInterfaceDown() error
func SetInterfaceUp ¶
func TestConnectivity ¶
TestConnectivity godoc @Summary Test the connectivity of a remote host (using Libp2p Connect) @Description Find the addresses from a multiaddr and try to connect to the peer @Tags VPN @Produce json @Param peerId path string true "Peer ID" @Router /ping/{peerId} [get]