Documentation
¶
Index ¶
- Constants
- Variables
- func LoadConfig(configPath string) error
- func LogHTTP2Endpoint(endpoint net.Addr)
- func SelectEndpointFromConfig(useHTTP2 bool, useIPv6 bool, port int) (net.Addr, error)
- func WarnInsecure()
- type Config
- type HTTPProxyConfig
- type LogConfig
- type PortFwConfig
- type SocksConfig
- type TransparentTunConfig
Constants ¶
const ( HTTP2WikiURL = "https://github.com/Diniboy1123/usque/wiki/HTTP-2-support" DefaultEndpointH2V4 = "162.159.198.2" DefaultEndpointH2V6 = "" EndpointHelpSuffixH2 = " For details: https://github.com/Diniboy1123/usque/wiki/HTTP-2-support" )
Variables ¶
var ConfigLoaded bool
ConfigLoaded indicates whether the configuration has been successfully loaded.
Functions ¶
func LoadConfig ¶
LoadConfig loads the application configuration from a JSON file.
Parameters:
- configPath: string - The path to the configuration JSON file.
Returns:
- error: An error if the configuration file cannot be loaded or parsed.
func LogHTTP2Endpoint ¶
LogHTTP2Endpoint prints the wiki reference and active endpoint when HTTP/2 mode is enabled.
func SelectEndpointFromConfig ¶
SelectEndpointFromConfig returns a protocol-appropriate remote endpoint: TCP for HTTP/2 mode and UDP for HTTP/3 mode.
func WarnInsecure ¶
func WarnInsecure()
WarnInsecure prints a warning when certificate pinning is disabled.
Types ¶
type Config ¶
type Config struct {
PrivateKey string `json:"private_key"` // Base64-encoded ECDSA private key
EndpointV4 string `json:"endpoint_v4"` // IPv4 address of the endpoint
EndpointV6 string `json:"endpoint_v6"` // IPv6 address of the endpoint
EndpointH2V4 string `json:"endpoint_h2_v4"` // IPv4 address used in HTTP/2 mode
EndpointH2V6 string `json:"endpoint_h2_v6"` // IPv6 address used in HTTP/2 mode
EndpointPubKey string `json:"endpoint_pub_key"` // PEM-encoded ECDSA public key of the endpoint to verify against
License string `json:"license"` // Application license key
ID string `json:"id"` // Device unique identifier
AccessToken string `json:"access_token"` // Authentication token for API access
IPv4 string `json:"ipv4"` // Assigned IPv4 address
IPv6 string `json:"ipv6"` // Assigned IPv6 address
// Expanded configuration sections
Socks SocksConfig `json:"socks"`
HTTPProxy HTTPProxyConfig `json:"http_proxy"`
PortForward PortFwConfig `json:"port_forward"`
TransparentTun TransparentTunConfig `json:"transparent_tun"`
Log LogConfig `json:"log"`
}
Config represents the application configuration structure, containing essential details such as keys, endpoints, and access tokens.
var AppConfig Config
AppConfig holds the global application configuration.
func (*Config) GetEcEndpointPublicKey ¶
GetEcEndpointPublicKey retrieves the ECDSA public key from the stored PEM-encoded string.
Returns:
- *ecdsa.PublicKey: The parsed ECDSA public key.
- error: An error if decoding or parsing the public key fails.
func (*Config) GetEcPrivateKey ¶
func (*Config) GetEcPrivateKey() (*ecdsa.PrivateKey, error)
GetEcPrivateKey retrieves the ECDSA private key from the stored Base64-encoded string.
Returns:
- *ecdsa.PrivateKey: The parsed ECDSA private key.
- error: An error if decoding or parsing the private key fails.
func (*Config) SaveConfig ¶
SaveConfig writes the current application configuration to a prettified JSON file.
Parameters:
- configPath: string - The path to save the configuration JSON file.
Returns:
- error: An error if the configuration file cannot be written.