initial commit
This commit is contained in:
37
protonvpn-wg-confgen/internal/constants/api.go
Normal file
37
protonvpn-wg-confgen/internal/constants/api.go
Normal file
@@ -0,0 +1,37 @@
|
||||
// Package constants defines constants used throughout the application.
|
||||
package constants
|
||||
|
||||
// API endpoints
|
||||
const (
|
||||
DefaultAPIURL = "https://vpn-api.proton.me"
|
||||
AuthInfoPath = "/core/v4/auth/info"
|
||||
AuthPath = "/core/v4/auth"
|
||||
RefreshPath = "/auth/refresh"
|
||||
CertificatePath = "/vpn/v1/certificate"
|
||||
LogicalsPath = "/vpn/v1/logicals"
|
||||
)
|
||||
|
||||
// API version headers - can be overridden at build time via ldflags:
|
||||
// go build -ldflags "-X .../internal/constants.AppVersion=linux-vpn@X.Y.Z"
|
||||
var (
|
||||
AppVersion = "linux-vpn@4.13.1"
|
||||
UserAgent = "ProtonVPN/4.13.1 (Linux; Ubuntu)"
|
||||
)
|
||||
|
||||
// API response codes
|
||||
// Reference: proton-python-client/proton/api.py checks for codes 1000 and 1001
|
||||
const (
|
||||
APICodeSuccess = 1000
|
||||
APICodeMultiStatus = 1001 // Also indicates success in some contexts
|
||||
)
|
||||
|
||||
// IsSuccessCode checks if an API response code indicates success
|
||||
func IsSuccessCode(code int) bool {
|
||||
return code == APICodeSuccess || code == APICodeMultiStatus
|
||||
}
|
||||
|
||||
// Server/feature status values
|
||||
const (
|
||||
StatusOnline = 1
|
||||
EnabledTrue = 1
|
||||
)
|
||||
14
protonvpn-wg-confgen/internal/constants/defaults.go
Normal file
14
protonvpn-wg-confgen/internal/constants/defaults.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package constants
|
||||
|
||||
// Certificate defaults
|
||||
const (
|
||||
DefaultCertDuration = "365d"
|
||||
MaxCertDuration = 365 // days
|
||||
CertMode = "persistent"
|
||||
PublicKeyMode = "EC"
|
||||
)
|
||||
|
||||
// Server selection defaults
|
||||
const (
|
||||
DefaultP2POnly = true
|
||||
)
|
||||
9
protonvpn-wg-confgen/internal/constants/session.go
Normal file
9
protonvpn-wg-confgen/internal/constants/session.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package constants
|
||||
|
||||
// Session defaults
|
||||
const (
|
||||
SessionFileName = ".protonvpn-session.json"
|
||||
SessionFileMode = 0o600 // Read/write for owner only
|
||||
SessionRefreshDays = 7 // Refresh when less than 7 days remain
|
||||
SessionExpirySeconds = 2592000 // 30 days in seconds (from API)
|
||||
)
|
||||
17
protonvpn-wg-confgen/internal/constants/wireguard.go
Normal file
17
protonvpn-wg-confgen/internal/constants/wireguard.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package constants
|
||||
|
||||
// WireGuard defaults
|
||||
const (
|
||||
WireGuardPort = 51820
|
||||
DefaultMTU = 1420
|
||||
|
||||
// IPv4 configuration
|
||||
WireGuardIPv4 = "10.2.0.2/32"
|
||||
DefaultDNSIPv4 = "10.2.0.1"
|
||||
DefaultAllowedIPsIPv4 = "0.0.0.0/0"
|
||||
|
||||
// IPv6 configuration
|
||||
WireGuardIPv6 = "2a07:b944::2:2/128"
|
||||
DefaultDNSIPv6 = "2a07:b944::2:1"
|
||||
DefaultAllowedIPsIPv6 = "::/0"
|
||||
)
|
||||
Reference in New Issue
Block a user