ipvanish

package
v0.0.0-...-eee4225 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect()

Connect connects to selected ipvanish vpn server

func CreateCredentials

func CreateCredentials(username, password string)

CreateCredentials creates a new credentials file. It replaces the previous file if it exists.

func Disconnect

func Disconnect()

Disconnect kills the vpn process

func GenerateVPNConfig

func GenerateVPNConfig(hostname, protocol string)

GenerateVPNConfig generate OpenVPN config file for hostname

func GetServers

func GetServers(countryCode string) *[]IPVServer

GetServers returns pointer to a slice of ipvanish servers. Pointer is returned as slice holds many elements.

func IsVPNProcessRunning

func IsVPNProcessRunning() (bool, int, error)

IsVPNProcessRunning checks if VPN process is running. It returns a boolean, an int (pid) and error (if any).

func PingAllServers

func PingAllServers(servers *[]IPVServer) *[]IPVServer

PingAllServers records latencies (RTT) for all ipvanish servers. When the number of servers passed is large, ping might not complete for all servers. Hence, ping is run multiple times. Whenever, maxRTT is passed, OnIdle is called where the server IPs for which latencies have been recorded are removed. And ping runs again. factor is used to compute the number of ping cycles. It is assumed that in one cycle atleast 25 servers are being pinged successfully.

func SelectServerPrompt

func SelectServerPrompt(servers *[]IPVServer, n int) string

SelectServerPrompt asks user to choose a server to connect to and returns the hostname of the chosen server.

Types

type ByLatency

type ByLatency []IPVServer

ByLatency implements sort.Interface based on Latency field

func (ByLatency) Len

func (s ByLatency) Len() int

Len returns number of servers

func (ByLatency) Less

func (s ByLatency) Less(i, j int) bool

Less compares latency of two servers

func (ByLatency) Swap

func (s ByLatency) Swap(i, j int)

Swap exchanges servers to order them

type ClientInfo

type ClientInfo struct {
	IPAddress string `json:"ip_address"`
	Location  struct {
		CountryName string  `json:"country_name"`
		Region      string  `json:"region"`
		City        string  `json:"city"`
		Latitude    float64 `json:"latitude"`
		Longitude   float64 `json:"longitude"`
	} `json:"location"`
	VPN struct {
		Enabled bool `json:"enabled"`
		Secure  bool `json:"secure"`
	} `json:"vpn"`
}

ClientInfo represents current connection info of user

func GetClientInfo

func GetClientInfo() ClientInfo

GetClientInfo returns current connection info of user

type IPVServer

type IPVServer struct {
	IP       string
	Hostname string
	Latency  time.Duration
}

IPVServer represents Ipvanish Server

func (IPVServer) String

func (i IPVServer) String() string

Implement stringer interface

Jump to

Keyboard shortcuts

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