softetherApi

package module
v0.0.0-...-fc371b1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: MIT Imports: 20 Imported by: 0

README

SoftEtherGo

SoftEther VPN Server Golang Management API.

Golang implementation of SoftEther VPN management protocol. Can be used for controlling remote server, automation or statistics.

Usage example



api := NewAPI('vpn.whitehouse.gov', 443, '123456password')

api.HandShake()

api.Test()

api.Disconnect()

Documentation

Index

Constants

View Source
const (
	AUTHTYPE_ANONYMOUS = iota // Anonymous authentication
	AUTHTYPE_PASSWORD         // Password authentication
	AUTHTYPE_USERCERT         // User certificate authentication
	AUTHTYPE_ROOTCERT         // Root certificate which is issued by trusted Certificate Authority
	AUTHTYPE_RADIUS           // Radius authentication
	AUTHTYPE_NT               // Windows NT authentication
	AUTHTYPE_TICKET           // Ticket authentication
)
View Source
const (
	HUB_TYPE_STANDALONE   = 0 // Stand-alone HUB
	HUB_TYPE_FARM_STATIC  = 1 // Static HUB
	HUB_TYPE_FARM_DYNAMIC = 2 // Dynamic HUB
)

Type of HUB

View Source
const (
	ERR_NO_ERROR = iota
	ERR_CONNECT_FAILED
	ERR_SERVER_IS_NOT_VPN
	ERR_DISCONNECTED
	ERR_PROTOCOL_ERROR
	ERR_CLIENT_IS_NOT_VPN
	ERR_USER_CANCEL
	ERR_AUTHTYPE_NOT_SUPPORTED
	ERR_HUB_NOT_FOUND
	ERR_AUTH_FAILED
	ERR_HUB_STOPPING
	ERR_SESSION_REMOVED
	ERR_ACCESS_DENIED
	ERR_SESSION_TIMEOUT
	ERR_INVALID_PROTOCOL
	ERR_TOO_MANY_CONNECTION
	ERR_HUB_IS_BUSY
	ERR_PROXY_CONNECT_FAILED
	ERR_PROXY_ERROR
	ERR_PROXY_AUTH_FAILED
	ERR_TOO_MANY_USER_SESSION
	ERR_LICENSE_ERROR
	ERR_DEVICE_DRIVER_ERROR
	ERR_INTERNAL_ERROR
	ERR_SECURE_DEVICE_OPEN_FAILED
	ERR_SECURE_PIN_LOGIN_FAILED
	ERR_SECURE_NO_CERT
	ERR_SECURE_NO_PRIVATE_KEY
	ERR_SECURE_CANT_WRITE
	ERR_OBJECT_NOT_FOUND
	ERR_VLAN_ALREADY_EXISTS
	ERR_VLAN_INSTALL_ERROR
	ERR_VLAN_INVALID_NAME
	ERR_NOT_SUPPORTED
	ERR_ACCOUNT_ALREADY_EXISTS
	ERR_ACCOUNT_ACTIVE
	ERR_ACCOUNT_NOT_FOUND
	ERR_ACCOUNT_INACTIVE
	ERR_INVALID_PARAMETER
	ERR_SECURE_DEVICE_ERROR
	ERR_NO_SECURE_DEVICE_SPECIFIED
	ERR_VLAN_IS_USED
	ERR_VLAN_FOR_ACCOUNT_NOT_FOUND
	ERR_VLAN_FOR_ACCOUNT_USED
	ERR_VLAN_FOR_ACCOUNT_DISABLED
	ERR_INVALID_VALUE
	ERR_NOT_FARM_CONTROLLER
	ERR_TRYING_TO_CONNECT
	ERR_CONNECT_TO_FARM_CONTROLLER
	ERR_COULD_NOT_HOST_HUB_ON_FARM
	ERR_FARM_MEMBER_HUB_ADMIN
	ERR_NULL_PASSWORD_LOCAL_ONLY
	ERR_NOT_ENOUGH_RIGHT
	ERR_LISTENER_NOT_FOUND
	ERR_LISTENER_ALREADY_EXISTS
	ERR_NOT_FARM_MEMBER
	ERR_CIPHER_NOT_SUPPORTED
	ERR_HUB_ALREADY_EXISTS
	ERR_TOO_MANY_HUBS
	ERR_LINK_ALREADY_EXISTS
	ERR_LINK_CANT_CREATE_ON_FARM
	ERR_LINK_IS_OFFLINE
	ERR_TOO_MANY_ACCESS_LIST
	ERR_TOO_MANY_USER
	ERR_TOO_MANY_GROUP
	ERR_GROUP_NOT_FOUND
	ERR_USER_ALREADY_EXISTS
	ERR_GROUP_ALREADY_EXISTS
	ERR_USER_AUTHTYPE_NOT_PASSWORD
	ERR_OLD_PASSWORD_WRONG
	ERR_LINK_CANT_DISCONNECT
	ERR_ACCOUNT_NOT_PRESENT
	ERR_ALREADY_ONLINE
	ERR_OFFLINE
	ERR_NOT_RSA_1024
	ERR_SNAT_CANT_DISCONNECT
	ERR_SNAT_NEED_STANDALONE
	ERR_SNAT_NOT_RUNNING
	ERR_SE_VPN_BLOCK
	ERR_BRIDGE_CANT_DISCONNECT
	ERR_LOCAL_BRIDGE_STOPPING
	ERR_LOCAL_BRIDGE_UNSUPPORTED
	ERR_CERT_NOT_TRUSTED
	ERR_PRODUCT_CODE_INVALID
	ERR_VERSION_INVALID
	ERR_CAPTURE_DEVICE_ADD_ERROR
	ERR_VPN_CODE_INVALID
	ERR_CAPTURE_NOT_FOUND
	ERR_LAYER3_CANT_DISCONNECT
	ERR_LAYER3_SW_EXISTS
	ERR_LAYER3_SW_NOT_FOUND
	ERR_INVALID_NAME
	ERR_LAYER3_IF_ADD_FAILED
	ERR_LAYER3_IF_DEL_FAILED
	ERR_LAYER3_IF_EXISTS
	ERR_LAYER3_TABLE_ADD_FAILED
	ERR_LAYER3_TABLE_DEL_FAILED
	ERR_LAYER3_TABLE_EXISTS
	ERR_BAD_CLOCK
	ERR_LAYER3_CANT_START_SWITCH
	ERR_CLIENT_LICENSE_NOT_ENOUGH
	ERR_BRIDGE_LICENSE_NOT_ENOUGH
	ERR_SERVER_CANT_ACCEPT
	ERR_SERVER_CERT_EXPIRES
	ERR_MONITOR_MODE_DENIED
	ERR_BRIDGE_MODE_DENIED
	ERR_IP_ADDRESS_DENIED
	ERR_TOO_MANT_ITEMS
	ERR_MEMORY_NOT_ENOUGH
	ERR_OBJECT_EXISTS
	ERR_FATAL
	ERR_SERVER_LICENSE_FAILED
	ERR_SERVER_INTERNET_FAILED
	ERR_CLIENT_LICENSE_FAILED
	ERR_BAD_COMMAND_OR_PARAM
	ERR_INVALID_LICENSE_KEY
	ERR_NO_VPN_SERVER_LICENSE
	ERR_NO_VPN_CLUSTER_LICENSE
	ERR_NOT_ADMINPACK_SERVER
	ERR_NOT_ADMINPACK_SERVER_NET
	ERR_BETA_EXPIRES
	ERR_BRANDED_C_TO_S
	ERR_BRANDED_C_FROM_S
	ERR_AUTO_DISCONNECTED
	ERR_CLIENT_ID_REQUIRED
	ERR_TOO_MANY_USERS_CREATED
	ERR_SUBSCRIPTION_IS_OLDER
	ERR_ILLEGAL_TRIAL_VERSION
	ERR_NAT_T_TWO_OR_MORE
	ERR_DUPLICATE_DDNS_KEY
	ERR_DDNS_HOSTNAME_EXISTS
	ERR_DDNS_HOSTNAME_INVALID_CHAR
	ERR_DDNS_HOSTNAME_TOO_LONG
	ERR_DDNS_HOSTNAME_IS_EMPTY
	ERR_DDNS_HOSTNAME_TOO_SHORT
	ERR_MSCHAP2_PASSWORD_NEED_RESET
	ERR_DDNS_DISCONNECTED
	ERR_SPECIAL_LISTENER_ICMP_ERROR
	ERR_SPECIAL_LISTENER_DNS_ERROR
	ERR_OPENVPN_IS_NOT_ENABLED
	ERR_NOT_SUPPORTED_AUTH_ON_OPENSOURCE
	ERR_VPNGATE
	ERR_VPNGATE_CLIENT
	ERR_VPNGATE_INCLIENT_CANT_STOP
	ERR_NOT_SUPPORTED_FUNCTION_ON_OPENSOURCE
	ERR_SUSPENDING
)

Error Code

Variables

View Source
var DefaultCallMethodTimeout = time.Second * 20
View Source
var ErrorNo = _ErrorNo{}/* 146 elements not displayed */

Functions

func InetAtoN

func InetAtoN(ip string) int64

func InetNtoA

func InetNtoA(ip int64) string

func InetNtoI

func InetNtoI(ip int64) (b [4]int)

func NewPasswordAuthData

func NewPasswordAuthData(username, password string) []byte

func Protocol

func Protocol(payload []byte) (p *protocol)

func RpcError

func RpcError(code int) error

func Sha0Sum

func Sha0Sum(p []byte) []byte

Types

type API

type API struct {
	Host            string
	Port            int
	Password        string
	Conn            Connector
	ConnectResponse map[string]interface{}
	// contains filtered or unexported fields
}

func NewAPI

func NewAPI(host string, port int, password string) *API

API基础方法

func (*API) Authenticate

func (a *API) Authenticate(hub string) (err error)

func (*API) CallMethod

func (a *API) CallMethod(method string, request Request) (res Response, err error)

func (*API) Connect

func (a *API) Connect() (err error)

func (*API) CreateGroup

func (a *API) CreateGroup(hub, name, realname, note string) (Response, error)

Group Operation

func (*API) CreateHub

func (a *API) CreateHub(name string, online bool, hub_type int) (Response, error)

Hub Operation

func (*API) CreateListener

func (a *API) CreateListener(port int, enable bool) (Response, error)

Listener Operation

func (*API) CreateUser

func (a *API) CreateUser(hub, useranme, realname, note, password string) (Response, error)

User Operation

func (*API) DeleteGroup

func (a *API) DeleteGroup(hub, name string) (Response, error)

func (*API) DeleteHub

func (a *API) DeleteHub(name string) (Response, error)

func (*API) DeleteListener

func (a *API) DeleteListener(port int) (Response, error)

func (*API) DeleteSession

func (a *API) DeleteSession(hub, name string) (Response, error)

func (*API) DeleteUser

func (a *API) DeleteUser(hub, name string) (Response, error)

func (*API) DisableSecureNat

func (a *API) DisableSecureNat(name string) (Response, error)

func (*API) Disconnect

func (a *API) Disconnect()

func (*API) DisconnectConnection

func (a *API) DisconnectConnection(cid string) (Response, error)

func (*API) EnableListener

func (a *API) EnableListener(port int, enable bool) (Response, error)

func (*API) EnableSecureNat

func (a *API) EnableSecureNat(name string) (Response, error)

SecureNat Operation

func (*API) GetConfig

func (a *API) GetConfig() (Response, error)

func (*API) GetConnection

func (a *API) GetConnection(cid string) (Response, error)

func (*API) GetCrl

func (a *API) GetCrl(name string, key int) (Response, error)

func (*API) GetDDnsClientStatus

func (a *API) GetDDnsClientStatus() (Response, error)

func (*API) GetDDnsHostName

func (a *API) GetDDnsHostName() (string, string, error)

func (*API) GetDDnsInternetSetting

func (a *API) GetDDnsInternetSetting() (Response, error)

DynamicDnsOperation

func (*API) GetGroup

func (a *API) GetGroup(hub, name string) (Response, error)

func (*API) GetHub

func (a *API) GetHub(name string) (Response, error)

func (*API) GetHubAdminOptions

func (a *API) GetHubAdminOptions(name string) (Response, error)

func (*API) GetHubStatus

func (a *API) GetHubStatus(name string) (Response, error)

func (*API) GetOpenVpnRemoteAccess

func (a *API) GetOpenVpnRemoteAccess() (string, error)

func (*API) GetOpenVpnSSTPConfig

func (a *API) GetOpenVpnSSTPConfig() (Response, error)

func (*API) GetSecureNatOption

func (a *API) GetSecureNatOption(hubname string) (Response, error)

func (*API) GetSecureNatStatus

func (a *API) GetSecureNatStatus(name string) (Response, error)

func (*API) GetServerCert

func (a *API) GetServerCert() (string, error)

func (*API) GetServerCipher

func (a *API) GetServerCipher() (Response, error)

Cert Operation

func (*API) GetServerInfo

func (a *API) GetServerInfo() (Response, error)

func (*API) GetSession

func (a *API) GetSession(hub, name string) (Response, error)

func (*API) GetUser

func (a *API) GetUser(hub, name string) (Response, error)

func (*API) HandShake

func (a *API) HandShake() error

func (*API) IPsecEnable

func (a *API) IPsecEnable() (Response, error)

IPSec Operation

func (*API) IPsecGet

func (a *API) IPsecGet() (Response, error)

func (*API) IPsecSet

func (a *API) IPsecSet(l2tp, l2tpraw, ehterip bool, psk string, hub string) (Response, error)

func (*API) ListConnection

func (a *API) ListConnection(hubname string) (Response, error)

Connection Operation

func (*API) ListDhcp

func (a *API) ListDhcp(hubname string) (Response, error)

DHCP Operation

func (*API) ListGroup

func (a *API) ListGroup(hub string) (Response, error)

func (*API) ListHub

func (a *API) ListHub() (Response, error)

func (*API) ListListener

func (a *API) ListListener() (map[int]bool, error)

func (*API) ListSessions

func (a *API) ListSessions(hub string) (Response, error)

Session Operation

func (*API) ListUser

func (a *API) ListUser(hub string) (Response, error)

func (*API) MakeOpenVpnConfigFile

func (a *API) MakeOpenVpnConfigFile() (Response, error)

func (*API) Request

func (a *API) Request(method, target string, body []byte, headers http.Header) (res Response, err error)

func (*API) SetGroup

func (a *API) SetGroup(hub, name string) (Response, error)

func (*API) SetHub

func (a *API) SetHub(name string, online bool, hub_type int) (Response, error)

func (*API) SetHubOnline

func (a *API) SetHubOnline(name string) (Response, error)

func (*API) SetOpenVpnSSTPConfig

func (a *API) SetOpenVpnSSTPConfig(enable_open_vpn, enable_sstp bool, open_vpn_port_list []int) (Response, error)

OpenVPN Operation

func (*API) SetSecureNatOption

func (a *API) SetSecureNatOption(hubname string, natoptions map[string]interface{}) (Response, error)

func (*API) SetServerPassword

func (a *API) SetServerPassword(password string) (Response, error)

Server Operation

func (*API) SetUserExpireTime

func (a *API) SetUserExpireTime(hub, name string, timestamp time.Time) (Response, error)

func (*API) SetUserPassword

func (a *API) SetUserPassword(hub, useranme, password string) (Response, error)

func (*API) SetUserPolicy

func (a *API) SetUserPolicy(hub, name string, MaxUpload, MaxDownload int) (Response, error)

func (*API) SetUserUpdateTime

func (a *API) SetUserUpdateTime(hub, name string, timestamp time.Time) (Response, error)

func (*API) Test

func (a *API) Test() (Response, error)

type APIConnect

type APIConnect struct {
	Sock net.Conn
	// contains filtered or unexported fields
}

func (*APIConnect) Close

func (c *APIConnect) Close() error

func (*APIConnect) Connect

func (c *APIConnect) Connect() error

func (*APIConnect) GetSock

func (c *APIConnect) GetSock() net.Conn

func (*APIConnect) Recv

func (c *APIConnect) Recv(shoud int) (buf []byte, err error)

func (*APIConnect) Send

func (c *APIConnect) Send(buf []byte) error

type ApiError

type ApiError struct {
	// contains filtered or unexported fields
}

func (ApiError) Code

func (e ApiError) Code() int

func (ApiError) Error

func (e ApiError) Error() string

type Connector

type Connector interface {
	Connect() error
	Close() error
	GetSock() net.Conn
	Send([]byte) error
	Recv(should int) ([]byte, error)
}

type Request

type Request map[string][]interface{}

type Response

type Response map[string]interface{}

type SHA0

type SHA0 struct {
	// contains filtered or unexported fields
}

func NewSha0Hash

func NewSha0Hash() SHA0

func (*SHA0) Reset

func (s *SHA0) Reset()

func (*SHA0) Sum

func (s *SHA0) Sum() []byte

func (*SHA0) Write

func (s *SHA0) Write(p []byte) (n int)

Jump to

Keyboard shortcuts

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