pritunl

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerStatusOnline  = "online"
	ServerStatusOffline = "offline"

	ServerNetworkModeTunnel = "tunnel"
	ServerNetworkModeBridge = "bridge"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	TestApiCall() error

	GetOrganizations() ([]Organization, error)
	GetOrganization(id string) (*Organization, error)
	CreateOrganization(name string) (*Organization, error)
	UpdateOrganization(id string, organization *Organization) error
	DeleteOrganization(name string) error

	GetUser(id string, orgId string) (*User, error)
	CreateUser(newUser User) (*User, error)
	UpdateUser(id string, user *User) error
	DeleteUser(id string, orgId string) error

	GetServers() ([]Server, error)
	GetServer(id string) (*Server, error)
	CreateServer(serverData map[string]interface{}) (*Server, error)
	UpdateServer(id string, server *Server) error
	DeleteServer(id string) error

	GetOrganizationsByServer(serverId string) ([]Organization, error)
	AttachOrganizationToServer(organizationId, serverId string) error
	DetachOrganizationFromServer(organizationId, serverId string) error

	GetRoutesByServer(serverId string) ([]Route, error)
	AddRouteToServer(serverId string, route Route) error
	AddRoutesToServer(serverId string, route []Route) error
	DeleteRouteFromServer(serverId string, route Route) error
	UpdateRouteOnServer(serverId string, route Route) error

	GetHosts() ([]Host, error)
	GetHostsByServer(serverId string) ([]Host, error)
	AttachHostToServer(hostId, serverId string) error
	DetachHostFromServer(hostId, serverId string) error

	StartServer(serverId string) error
	StopServer(serverId string) error
}

func NewClient

func NewClient(baseUrl, apiToken, apiSecret string, insecure bool) Client

type Host added in v0.1.0

type Host struct {
	ID                string `json:"id,omitempty"`
	Name              string `json:"name"`
	Hostname          string `json:"hostname"`
	PublicAddr        string `json:"public_addr"`
	PublicAddr6       string `json:"public_addr6"`
	RoutedSubnet6     string `json:"routed_subnet6"`
	RoutedSubnet6WG   string `json:"routed_subnet6_wg"`
	LocalAddr         string `json:"local_addr"`
	LocalAddr6        string `json:"local_addr6"`
	AvailabilityGroup string `json:"availability_group"`
	LinkAddr          string `json:"link_addr"`
	SyncAddress       string `json:"sync_address"`
	Status            string `json:"status"`
}

type Organization

type Organization struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name"`
}

type Pin added in v0.2.1

type Pin struct {
	IsSet  bool
	Secret string
}

func (*Pin) MarshalJSON added in v0.2.1

func (p *Pin) MarshalJSON() ([]byte, error)

MarshalJSON customizes the JSON encoding of the Pin struct.

When marshaling a User JSON, the "pin" field will contain the PIN secret if it is set, otherwise the field is excluded. This is used when making a user create or update request to the Pritunl API.

func (*Pin) UnmarshalJSON added in v0.2.1

func (p *Pin) UnmarshalJSON(data []byte) error

UnmarshalJSON customizes the JSON decoding of the Pin struct.

When unmarshaling a User JSON, the "pin" field will contain a boolean indicating whether the user has a PIN set or not. This is used when reading a user response from the Pritunl API.

type PortForwarding

type PortForwarding struct {
	Dport    string `json:"dport"`
	Protocol string `json:"protocol"`
	Port     string `json:"port"`
}

type Route

type Route struct {
	Network        string `json:"network"`
	Nat            bool   `json:"nat"`
	Comment        string `json:"comment,omitempty"`
	VirtualNetwork bool   `json:"virtual_network,omitempty"`
	WgNetwork      string `json:"wg_network,omitempty"`
	NetworkLink    bool   `json:"network_link,omitempty"`
	ServerLink     bool   `json:"server_link,omitempty"`
	NetGateway     bool   `json:"net_gateway,omitempty"`
	VpcID          string `json:"vpc_id,omitempty"`
	VpcRegion      string `json:"vpc_region,omitempty"`
	Metric         string `json:"metric,omitempty"`
	Advertise      bool   `json:"advertise,omitempty"`
	NatInterface   string `json:"nat_interface,omitempty"`
	NatNetmap      string `json:"nat_netmap,omitempty"`
}

func ConvertMapToRoute

func ConvertMapToRoute(data map[string]interface{}) Route

func (Route) GetID

func (r Route) GetID() string

type Server

type Server struct {
	ID               string   `json:"id,omitempty"`
	Name             string   `json:"name"`
	Protocol         string   `json:"protocol,omitempty"`
	Cipher           string   `json:"cipher,omitempty"`
	Hash             string   `json:"hash,omitempty"`
	Port             int      `json:"port,omitempty"`
	Network          string   `json:"network,omitempty"`
	WG               bool     `json:"wg,omitempty"`
	PortWG           int      `json:"port_wg,omitempty"`
	NetworkWG        string   `json:"network_wg,omitempty"`
	NetworkMode      string   `json:"network_mode,omitempty"`
	NetworkStart     string   `json:"network_start,omitempty"`
	NetworkEnd       string   `json:"network_end,omitempty"`
	RestrictRoutes   bool     `json:"restrict_routes,omitempty"`
	IPv6             bool     `json:"ipv6,omitempty"`
	IPv6Firewall     bool     `json:"ipv6_firewall,omitempty"`
	BindAddress      string   `json:"bind_address,omitempty"`
	DhParamBits      int      `json:"dh_param_bits,omitempty"`
	Groups           []string `json:"groups,omitempty"`
	MultiDevice      bool     `json:"multi_device,omitempty"`
	DnsServers       []string `json:"dns_servers,omitempty"`
	SearchDomain     string   `json:"search_domain,omitempty"`
	InterClient      bool     `json:"inter_client,omitempty"`
	PingInterval     int      `json:"ping_interval,omitempty"`
	PingTimeout      int      `json:"ping_timeout,omitempty"`
	LinkPingInterval int      `json:"link_ping_interval,omitempty"`
	LinkPingTimeout  int      `json:"link_ping_timeout,omitempty"`
	InactiveTimeout  int      `json:"inactive_timeout,omitempty"`
	SessionTimeout   int      `json:"session_timeout,omitempty"`
	AllowedDevices   string   `json:"allowed_devices,omitempty"`
	MaxClients       int      `json:"max_clients,omitempty"`
	MaxDevices       int      `json:"max_devices,omitempty"`
	ReplicaCount     int      `json:"replica_count,omitempty"`
	VxLan            bool     `json:"vxlan,omitempty"`
	DnsMapping       bool     `json:"dns_mapping,omitempty"`
	PreConnectMsg    string   `json:"pre_connect_msg,omitempty"`
	SsoAuth          bool     `json:"sso_auth,omitempty"`
	OtpAuth          bool     `json:"otp_auth,omitempty"`
	DeviceAuth       bool     `json:"device_auth,omitempty"`
	DynamicFirewall  bool     `json:"dynamic_firewall,omitempty"`
	MssFix           int      `json:"mss_fix,omitempty"`
	LzoCompression   bool     `json:"lzo_compression,omitempty"`
	BlockOutsideDns  bool     `json:"block_outside_dns,omitempty"`
	JumboFrames      bool     `json:"jumbo_frames,omitempty"`
	Debug            bool     `json:"debug,omitempty"`
	Status           string   `json:"status,omitempty"`
}

func (*Server) MarshalJSON

func (s *Server) MarshalJSON() ([]byte, error)

type User

type User struct {
	ID              string                   `json:"id,omitempty"`
	Name            string                   `json:"name"`
	Type            string                   `json:"type,omitempty"`
	AuthType        string                   `json:"auth_type,omitempty"`
	DnsServers      []string                 `json:"dns_servers,omitempty"`
	DnsSuffix       string                   `json:"dns_suffix,omitempty"`
	DnsMapping      string                   `json:"dns_mapping,omitempty"`
	Disabled        bool                     `json:"disabled,omitempty"`
	NetworkLinks    []string                 `json:"network_links,omitempty"`
	PortForwarding  []map[string]interface{} `json:"port_forwarding,omitempty"`
	Email           string                   `json:"email,omitempty"`
	Status          bool                     `json:"status,omitempty"`
	OtpSecret       string                   `json:"otp_secret,omitempty"`
	ClientToClient  bool                     `json:"client_to_client,omitempty"`
	MacAddresses    []string                 `json:"mac_addresses,omitempty"`
	YubicoID        string                   `json:"yubico_id,omitempty"`
	SSO             interface{}              `json:"sso,omitempty"`
	BypassSecondary bool                     `json:"bypass_secondary,omitempty"`
	Groups          []string                 `json:"groups,omitempty"`
	Audit           bool                     `json:"audit,omitempty"`
	Gravatar        bool                     `json:"gravatar,omitempty"`
	OtpAuth         bool                     `json:"otp_auth,omitempty"`
	DeviceAuth      bool                     `json:"device_auth,omitempty"`
	Organization    string                   `json:"organization,omitempty"`
	Pin             *Pin                     `json:"pin,omitempty"`
}

Jump to

Keyboard shortcuts

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