feat(vpn): VPN_ENDPOINT_PORT
- Deprecate `OPENVPN_PORT` - Deprecate `WIREGUARD_ENDPOINT_PORT`
This commit is contained in:
@@ -61,16 +61,23 @@ func (r *Reader) readOpenVPNProtocol() (tcp *bool, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Reader) readOpenVPNCustomPort() (customPort *uint16, err error) {
|
func (r *Reader) readOpenVPNCustomPort() (customPort *uint16, err error) {
|
||||||
key := "OPENVPN_PORT"
|
const currentKey = "VPN_ENDPOINT_PORT"
|
||||||
s := os.Getenv(key)
|
key := "PORT"
|
||||||
|
s := os.Getenv(key) // Retro-compatibility
|
||||||
if s == "" {
|
if s == "" {
|
||||||
// Retro-compatibility
|
key = "OPENVPN_PORT" // Retro-compatibility
|
||||||
key = "PORT"
|
|
||||||
s = os.Getenv(key)
|
s = os.Getenv(key)
|
||||||
if s == "" {
|
if s == "" {
|
||||||
return nil, nil //nolint:nilnil
|
key = currentKey
|
||||||
|
s = os.Getenv(key)
|
||||||
|
if s == "" {
|
||||||
|
return nil, nil //nolint:nilnil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
r.onRetroActive("PORT", "OPENVPN_PORT")
|
}
|
||||||
|
|
||||||
|
if key != currentKey {
|
||||||
|
r.onRetroActive(key, currentKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
customPort = new(uint16)
|
customPort = new(uint16)
|
||||||
|
|||||||
@@ -55,16 +55,23 @@ func (r *Reader) readWireguardEndpointIP() (endpointIP net.IP, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Reader) readWireguardCustomPort() (customPort *uint16, err error) {
|
func (r *Reader) readWireguardCustomPort() (customPort *uint16, err error) {
|
||||||
key := "WIREGUARD_ENDPOINT_PORT"
|
const currentKey = "VPN_ENDPOINT_PORT"
|
||||||
|
key := "WIREGUARD_PORT" // Retro-compatibility
|
||||||
s := os.Getenv(key)
|
s := os.Getenv(key)
|
||||||
if s == "" {
|
if s == "" {
|
||||||
// Retro-compatibility
|
key = "WIREGUARD_ENDPOINT_PORT" // Retro-compatibility
|
||||||
key = "WIREGUARD_PORT"
|
|
||||||
s = os.Getenv(key)
|
s = os.Getenv(key)
|
||||||
if s == "" {
|
if s == "" {
|
||||||
return nil, nil //nolint:nilnil
|
key = currentKey
|
||||||
|
s = os.Getenv(key)
|
||||||
|
if s == "" {
|
||||||
|
return nil, nil //nolint:nilnil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
r.onRetroActive("WIREGUARD_PORT", "WIREGUARD_ENDPOINT_PORT")
|
}
|
||||||
|
|
||||||
|
if key != currentKey {
|
||||||
|
r.onRetroActive(key, currentKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
customPort = new(uint16)
|
customPort = new(uint16)
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ func getWireguardConnection(selection settings.ServerSelection) (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Port found is overridden by custom port set with `PORT` or `WIREGUARD_ENDPOINT_PORT`.
|
// Port found is overridden by custom port set with `VPN_ENDPOINT_PORT`.
|
||||||
func getPort(foundPort uint16, selection settings.ServerSelection) (port uint16) {
|
func getPort(foundPort uint16, selection settings.ServerSelection) (port uint16) {
|
||||||
return utils.GetPort(selection, foundPort, foundPort, foundPort)
|
return utils.GetPort(selection, foundPort, foundPort, foundPort)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user