Skip to content

Commit

Permalink
Merge pull request #257 from ivpn/bugfix/empty-openvpn-server-list
Browse files Browse the repository at this point in the history
Server list is empty when OpenVPN is selected
  • Loading branch information
jurajhilje authored May 16, 2022
2 parents 34058c1 + 9e6108e commit c85e4b1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
10 changes: 10 additions & 0 deletions IVPNClient/Models/VPNServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ class VPNServer {
}

var supportsIPv6: Bool {
for host in hosts {
if host.ipv6 == nil {
return false
}
}

return true
}

var enabledIPv6: Bool {
for host in hosts {
if !(host.ipv6?.localIP.isEmpty ?? true) {
return true
Expand Down
4 changes: 2 additions & 2 deletions IVPNClient/Models/VPNServerList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ class VPNServerList {
}()

func getServers() -> [VPNServer] {
guard UserDefaults.standard.showIPv4Servers || !UserDefaults.shared.isIPv6 else {
if UserDefaults.shared.isIPv6 && !UserDefaults.standard.showIPv4Servers {
return servers.filter { (server: VPNServer) -> Bool in
return server.supportsIPv6
return server.enabledIPv6 || !server.supportsIPv6
}
}

Expand Down
2 changes: 1 addition & 1 deletion IVPNClient/ViewModels/VPNServerViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ struct VPNServerViewModel {
}

var showIPv6Label: Bool {
return UserDefaults.standard.showIPv4Servers && UserDefaults.shared.isIPv6 && server.supportsIPv6 && !(server.random && Application.shared.connectionManager.status.isDisconnected())
return UserDefaults.standard.showIPv4Servers && UserDefaults.shared.isIPv6 && server.enabledIPv6 && !(server.random && Application.shared.connectionManager.status.isDisconnected())
}

// MARK: - Initialize -
Expand Down

0 comments on commit c85e4b1

Please sign in to comment.