vpn

package
v0.0.0-...-9d07e48 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InterfaceName = "utun8"
)

Functions

func AddDefaultRoute

func AddDefaultRoute(interfaceName, gateway string) error

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

func AddEndpointRoute(node host.Host, dht *dht.IpfsDHT, peerId string) error

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

func Connect(node host.Host, dht *dht.IpfsDHT) gin.HandlerFunc

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

func Disconnect(node host.Host, dht *dht.IpfsDHT) gin.HandlerFunc

Disconnect function to handle the disconnect endpoint

func DiscoverPeersWithKademlia

func DiscoverPeersWithKademlia(ctx context.Context, h host.Host, dht *dht.IpfsDHT)

DiscoverPeers performs a general Kademlia DHT discovery for Skypier peers.

func GetConnectedPeersCount

func GetConnectedPeersCount(node host.Host, mydht *dht.IpfsDHT) gin.HandlerFunc

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

func GetPeerIPAddresses(node host.Host, dht *dht.IpfsDHT) gin.HandlerFunc

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 GetVPNStatus(c *gin.Context)

func HandleExit

func HandleExit()

func IsTUNInterfaceUp

func IsTUNInterfaceUp(interfaceName string) (bool, error)

IsTUNInterfaceUp checks if a TUN interface is up on the machine for a given name.

func LoadPrivateKey

func LoadPrivateKey() (crypto.PrivKey, error)

TODO turn function private

func QuitSkypier

func QuitSkypier(c *gin.Context)

func RemoveInterface

func RemoveInterface(ifaceName string) error

func SetInterfaceDown

func SetInterfaceDown() error

func SetInterfaceUp

func SetInterfaceUp() *water.Interface

func SetNodeUp

func SetNodeUp(ctx context.Context, config utils.InnerConfig) (host.Host, *dht.IpfsDHT)

func StartNode

func StartNode(innerConfig utils.InnerConfig, pk crypto.PrivKey, tcpPort string, udpPort string) (host.Host, *dht.IpfsDHT, error)

func TestConnectivity

func TestConnectivity(node host.Host, dht *dht.IpfsDHT) gin.HandlerFunc

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]

Types

type SkypierNode

type SkypierNode struct {
	PeerId          string `json:"peerId"`
	Nickname        string `json:"nickname,omitempty"`
	Version         string `json:"version"`
	OperatingSystem string `json:"os"`
	Status          string `json:"status"`
}

type VPNStatus

type VPNStatus struct {
	Status  string `json:"status"`
	IP      string `json:"ip,omitempty"`
	PeerID  string `json:"peer_id,omitempty"`
	Country string `json:"country,omitempty"`
}

Jump to

Keyboard shortcuts

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