Skip to content

Commit

Permalink
feat(airvpn): support for AirVPN entry-IP 3 for Wireguard protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
le0m committed Oct 2, 2023
1 parent d4df872 commit c27275d
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions internal/provider/airvpn/updater/servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ func (u *Updater) FetchServers(ctx context.Context, minServers int) (
}

// every API server model has:
// - Wireguard server using IPv4In1
// - Wiregard server using IPv6In1
// - Wireguard server using IPv4In1 and IPv4In3
// - Wiregard server using IPv6In1 and IPv4In3
// - OpenVPN TCP+UDP+SSH+SSL server with tls-auth using IPv4In1 and IPv6In1
// - OpenVPN TCP+UDP+SSH+SSL server with tls-auth using IPv4In2 and IPv6In2
// - OpenVPN TCP+UDP+SSH+SSL server with tls-crypt using IPv4In3 and IPv6In3
// - OpenVPN TCP+UDP+SSH+SSL server with tls-crypt using IPv6In4 and IPv6In4
const numberOfServersPerAPIServer = 1 + // Wireguard server using IPv4In1
1 + // Wiregard server using IPv6In1
const numberOfServersPerAPIServer = 2 + // Wireguard server using IPv4In1, IPv4In3
2 + // Wiregard server using IPv6In1, IPv4In3
4 + // OpenVPN TCP server with tls-auth using IPv4In3, IPv6In3, IPv4In4, IPv6In4
4 // OpenVPN UDP server with tls-auth using IPv4In3, IPv6In3, IPv4In4, IPv6In4
projectedNumberOfServers := numberOfServersPerAPIServer * len(data.Servers)
Expand Down Expand Up @@ -56,15 +56,25 @@ func (u *Updater) FetchServers(ctx context.Context, minServers int) (
baseWireguardServer.VPN = vpn.Wireguard
baseWireguardServer.WgPubKey = "PyLCXAQT8KkM4T+dUsOQfn+Ub3pGxfGlxkIApuig+hk="

ipv4WireguadServer := baseWireguardServer
ipv4WireguadServer.IPs = []netip.Addr{apiServer.IPv4In1}
ipv4WireguadServer.Hostname = apiServer.CountryCode + ".vpn.airdns.org"
servers = append(servers, ipv4WireguadServer)

ipv6WireguadServer := baseWireguardServer
ipv6WireguadServer.IPs = []netip.Addr{apiServer.IPv6In1}
ipv6WireguadServer.Hostname = apiServer.CountryCode + ".ipv6.vpn.airdns.org"
servers = append(servers, ipv6WireguadServer)
ipv4In1WireguadServer := baseWireguardServer
ipv4In1WireguadServer.IPs = []netip.Addr{apiServer.IPv4In1}
ipv4In1WireguadServer.Hostname = apiServer.CountryCode + ".vpn.airdns.org"
servers = append(servers, ipv4In1WireguadServer)

ipv6In1WireguadServer := baseWireguardServer
ipv6In1WireguadServer.IPs = []netip.Addr{apiServer.IPv6In1}
ipv6In1WireguadServer.Hostname = apiServer.CountryCode + ".ipv6.vpn.airdns.org"
servers = append(servers, ipv6In1WireguadServer)

ipv4In3WireguadServer := baseWireguardServer
ipv4In3WireguadServer.IPs = []netip.Addr{apiServer.IPv4In3}
ipv4In3WireguadServer.Hostname = apiServer.CountryCode + "3.vpn.airdns.org"
servers = append(servers, ipv4In3WireguadServer)

ipv6In3WireguadServer := baseWireguardServer
ipv6In3WireguadServer.IPs = []netip.Addr{apiServer.IPv6In3}
ipv6In3WireguadServer.Hostname = apiServer.CountryCode + "3.ipv6.vpn.airdns.org"
servers = append(servers, ipv6In3WireguadServer)

baseOpenVPNServer := baseServer
baseOpenVPNServer.VPN = vpn.OpenVPN
Expand Down

0 comments on commit c27275d

Please sign in to comment.