mirror of
https://github.com/qdm12/gluetun.git
synced 2026-05-07 04:20:12 +02:00
hotfix(amneziawg): fix errors (#3240)
This commit is contained in:
@@ -518,7 +518,8 @@ func (ss *ServerSelection) read(r *reader.Reader,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ss.Wireguard.read(r)
|
amneziawg := ss.VPN == vpn.AmneziaWg
|
||||||
|
err = ss.Wireguard.read(r, amneziawg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,18 +152,22 @@ func (w WireguardSelection) toLinesNode() (node *gotree.Node) {
|
|||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WireguardSelection) read(r *reader.Reader) (err error) {
|
func (w *WireguardSelection) read(r *reader.Reader, amneziaWG bool) (err error) {
|
||||||
w.EndpointIP, err = r.NetipAddr("WIREGUARD_ENDPOINT_IP", reader.RetroKeys("VPN_ENDPOINT_IP"))
|
prefix := "WIREGUARD"
|
||||||
|
if amneziaWG {
|
||||||
|
prefix = "AMNEZIAWG"
|
||||||
|
}
|
||||||
|
w.EndpointIP, err = r.NetipAddr(prefix+"_ENDPOINT_IP", reader.RetroKeys("VPN_ENDPOINT_IP"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%w - note this MUST be an IP address, "+
|
return fmt.Errorf("%w - note this MUST be an IP address, "+
|
||||||
"see https://github.com/qdm12/gluetun/issues/788", err)
|
"see https://github.com/qdm12/gluetun/issues/788", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
w.EndpointPort, err = r.Uint16Ptr("WIREGUARD_ENDPOINT_PORT", reader.RetroKeys("VPN_ENDPOINT_PORT"))
|
w.EndpointPort, err = r.Uint16Ptr(prefix+"_ENDPOINT_PORT", reader.RetroKeys("VPN_ENDPOINT_PORT"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
w.PublicKey = r.String("WIREGUARD_PUBLIC_KEY", reader.ForceLowercase(false))
|
w.PublicKey = r.String(prefix+"_PUBLIC_KEY", reader.ForceLowercase(false))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ func MaxTheoreticalVPNMTU(vpnType, network string, vpnGateway netip.Addr) uint32
|
|||||||
panic("unknown network protocol: " + network)
|
panic("unknown network protocol: " + network)
|
||||||
}
|
}
|
||||||
switch vpnType {
|
switch vpnType {
|
||||||
case vpn.Wireguard:
|
case vpn.Wireguard, vpn.AmneziaWg:
|
||||||
vpnLinkMTU -= pconstants.WireguardHeaderLength
|
vpnLinkMTU -= pconstants.WireguardHeaderLength
|
||||||
case vpn.OpenVPN:
|
case vpn.OpenVPN:
|
||||||
vpnLinkMTU -= pconstants.OpenVPNHeaderMaxLength
|
vpnLinkMTU -= pconstants.OpenVPNHeaderMaxLength
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ func (p *Provider) GetConnection(selection settings.ServerSelection, _ bool) (
|
|||||||
switch selection.VPN {
|
switch selection.VPN {
|
||||||
case vpn.OpenVPN:
|
case vpn.OpenVPN:
|
||||||
return getOpenVPNConnection(p.extractor, selection)
|
return getOpenVPNConnection(p.extractor, selection)
|
||||||
case vpn.Wireguard:
|
case vpn.Wireguard, vpn.AmneziaWg:
|
||||||
return getWireguardConnection(selection), nil
|
return getWireguardConnection(selection), nil
|
||||||
default:
|
default:
|
||||||
return connection, fmt.Errorf("%w: %s", ErrVPNTypeNotSupported, selection.VPN)
|
return connection, fmt.Errorf("%w: %s", ErrVPNTypeNotSupported, selection.VPN)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ func pickConnection(connections []models.Connection,
|
|||||||
switch selection.VPN {
|
switch selection.VPN {
|
||||||
case vpn.OpenVPN:
|
case vpn.OpenVPN:
|
||||||
targetIP = selection.OpenVPN.EndpointIP
|
targetIP = selection.OpenVPN.EndpointIP
|
||||||
case vpn.Wireguard:
|
case vpn.Wireguard, vpn.AmneziaWg:
|
||||||
targetIP = selection.Wireguard.EndpointIP
|
targetIP = selection.Wireguard.EndpointIP
|
||||||
default:
|
default:
|
||||||
panic("unknown VPN type: " + selection.VPN)
|
panic("unknown VPN type: " + selection.VPN)
|
||||||
|
|||||||
Reference in New Issue
Block a user