models

package
v0.0.0-...-1e25372 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrVPNFieldEmpty           = errors.New("vpn field is empty")
	ErrHostnameFieldEmpty      = errors.New("hostname field is empty")
	ErrIPsFieldEmpty           = errors.New("ips field is empty")
	ErrNoNetworkProtocol       = errors.New("both TCP and UDP fields are false for OpenVPN")
	ErrNetworkProtocolSet      = errors.New("no network protocol should be set")
	ErrWireguardPublicKeyEmpty = errors.New("wireguard public key field is empty")
)

Functions

This section is empty.

Types

type AllServers

type AllServers struct {
	Version           uint16 // used for migration of the top level scheme
	ProviderToServers map[string]Servers
}

func (*AllServers) Count

func (a *AllServers) Count() (count int)

func (*AllServers) MarshalJSON

func (a *AllServers) MarshalJSON() (data []byte, err error)

MarshalJSON marshals all servers to JSON. Note you need to use a pointer to all servers for it to work with native json methods such as json.Marshal.

func (*AllServers) UnmarshalJSON

func (a *AllServers) UnmarshalJSON(data []byte) (err error)

type BuildInformation

type BuildInformation struct {
	Version string `json:"version"`
	Commit  string `json:"commit"`
	Created string `json:"created"`
}

type Connection

type Connection struct {
	// Type is the connection type and can be "openvpn" or "wireguard"
	Type string `json:"type"`
	// IP is the VPN server IP address.
	IP netip.Addr `json:"ip"`
	// Port is the VPN server port.
	Port uint16 `json:"port"`
	// Protocol can be "tcp" or "udp".
	Protocol string `json:"protocol"`
	// Hostname is used for IPVanish, IVPN, Privado
	// and Windscribe for TLS verification.
	Hostname string `json:"hostname"`
	// PubKey is the public key of the VPN server,
	// used only for Wireguard.
	PubKey string `json:"pubkey"`
	// ServerName is used for PIA for port forwarding
	ServerName string `json:"server_name,omitempty"`
	// PortForward is used for PIA for port forwarding
	PortForward bool `json:"port_forward"`
}

func (*Connection) Equal

func (c *Connection) Equal(other Connection) bool

func (*Connection) UpdateEmptyWith

func (c *Connection) UpdateEmptyWith(ip netip.Addr, port uint16, protocol string)

UpdateEmptyWith updates each field of the connection where the value is not set using the value given as arguments.

type FilterChoices

type FilterChoices struct {
	Countries  []string
	Regions    []string
	Cities     []string
	Categories []string
	ISPs       []string
	Names      []string
	Hostnames  []string
}

type LoopStatus

type LoopStatus string

LoopStatus status such as stopped or running.

func (LoopStatus) String

func (ls LoopStatus) String() string

type PublicIP

type PublicIP struct {
	IP           netip.Addr `json:"public_ip,omitempty"`
	Region       string     `json:"region,omitempty"`
	Country      string     `json:"country,omitempty"`
	City         string     `json:"city,omitempty"`
	Hostname     string     `json:"hostname,omitempty"`
	Location     string     `json:"location,omitempty"`
	Organization string     `json:"organization,omitempty"`
	PostalCode   string     `json:"postal_code,omitempty"`
	Timezone     string     `json:"timezone,omitempty"`
}

func (*PublicIP) Copy

func (p *PublicIP) Copy() (publicIPCopy PublicIP)

type Server

type Server struct {
	VPN string `json:"vpn,omitempty"`
	// Surfshark: country is also used for multi-hop
	Country     string       `json:"country,omitempty"`
	Region      string       `json:"region,omitempty"`
	City        string       `json:"city,omitempty"`
	ISP         string       `json:"isp,omitempty"`
	Categories  []string     `json:"categories,omitempty"`
	Owned       bool         `json:"owned,omitempty"`
	Number      uint16       `json:"number,omitempty"`
	ServerName  string       `json:"server_name,omitempty"`
	Hostname    string       `json:"hostname,omitempty"`
	TCP         bool         `json:"tcp,omitempty"`
	UDP         bool         `json:"udp,omitempty"`
	OvpnX509    string       `json:"x509,omitempty"`
	RetroLoc    string       `json:"retroloc,omitempty"` // TODO remove in v4
	MultiHop    bool         `json:"multihop,omitempty"`
	WgPubKey    string       `json:"wgpubkey,omitempty"`
	Free        bool         `json:"free,omitempty"`
	Stream      bool         `json:"stream,omitempty"`
	Premium     bool         `json:"premium,omitempty"`
	PortForward bool         `json:"port_forward,omitempty"`
	Keep        bool         `json:"keep,omitempty"`
	IPs         []netip.Addr `json:"ips,omitempty"`
}

func (*Server) Equal

func (s *Server) Equal(other Server) (equal bool)

func (*Server) HasMinimumInformation

func (s *Server) HasMinimumInformation() (err error)

func (*Server) Key

func (s *Server) Key() (key string)

func (*Server) ToMarkdown

func (s *Server) ToMarkdown(headers ...string) (markdown string)

type Servers

type Servers struct {
	Version   uint16   `json:"version"`
	Timestamp int64    `json:"timestamp"`
	Servers   []Server `json:"servers,omitempty"`
}

func (*Servers) ToMarkdown

func (s *Servers) ToMarkdown(vpnProvider string) (markdown string)

type SortableServers

type SortableServers []Server

func (SortableServers) Len

func (s SortableServers) Len() int

func (SortableServers) Less

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

func (SortableServers) Swap

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

Jump to

Keyboard shortcuts

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