Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajhilje committed Nov 23, 2022
2 parents 98e107c + 5df3d97 commit 15b1841
Show file tree
Hide file tree
Showing 62 changed files with 1,712 additions and 325 deletions.
17 changes: 16 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ As a contributor, here are the guidelines we would like you to follow:
* [Git Workflow](#git)
* [Commit Message Guidelines](#commit)
* [Coding Conventions](#conventions)
* [Beta Program](#beta-program)

<a name="contributing"></a>
## Contributing Code
Expand Down Expand Up @@ -108,4 +109,18 @@ This projects is using [SwiftLint](https://github.com/realm/SwiftLint) to enforc

```sh
$ fastlane lint
```
```

<a name="beta-program"></a>
## IVPN iOS App Beta Program

Users with an active IVPN account can join our iOS app beta program:

1. Install the iOS [TestFlight app](https://testflight.apple.com)
2. Open [https://testflight.apple.com/join/FnmEzHHb](https://testflight.apple.com/join/FnmEzHHb) on your iOS device
3. You will be presented with detailed instructions on how to install the IVPN iOS beta app

Any feedback will be very useful to us. You can submit feedback either by opening an issue on [GitHub](https://github.com/ivpn/ios-app/issues), or send a direct message to [email protected].

**IMPORTANT NOTE:**
Do not use IVPN prerelease (beta) apps in situations where you need to protect your privacy or security, but only for testing new unreleased features and improvements.
4 changes: 2 additions & 2 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Reporting a security vulnerability to IVPN

If you believe you have found a security vulnerability, **DO NOT CREATE AN ISSUE**. Instead, please send an email to [email protected]. We treat all reports with the highest priority and confidentiality.
If you believe you have found a security vulnerability, **DO NOT CREATE AN ISSUE**. Instead, please send an email to [email protected] or file a report directly on GitHub with [Private vulnerability reporting](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability). We treat all reports with the highest priority and confidentiality.

## Incident resolution process

Expand Down Expand Up @@ -58,4 +58,4 @@ fw0vw5vWVvCDLCQx+sLeNNwWl8291JZNPaSjhuUkK7npNRHV8M3AC5UhhJjwS5K98YeZUeE/4SLN
T7Vor9NUBZb2g6gu2CwiPAhOS5TY/Oqgh3rvBcDS8X9pgOYXpnTrRLJNhZEjNawRvsqbjJV7vpzL
x6/Qj0RvfminJWZZz54gHHuh/98PpmByzXLdpQ8GH+PiUd8n5AyA9FxW81kSLTE==o/fv
-----END PGP PUBLIC KEY BLOCK-----
```
```
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to this project will be documented in this file.

## 2.7.0 - 2022-11-23

[NEW] Ability to connect to a specific host in a location
[NEW] Support for custom ports
[IMPROVED] Warning about existing VPN connection(s) when downgrading subscription plan
[FIXED] IPv6 connection information not displayed on iOS 16+ devices
[FIXED] Port number displayed in the settings when MultiHop is enabled

## 2.6.3 - 2022-05-17

[IMPROVED] Option to select UDP or TCP when using OpenVPN MultiHop
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ GEM
tty-screen (0.7.0)
tty-spinner (0.9.2)
tty-cursor (~> 0.7)
tzinfo (1.2.6)
tzinfo (1.2.10)
thread_safe (~> 0.1)
uber (0.1.0)
unf (0.1.4)
Expand Down
72 changes: 48 additions & 24 deletions IVPNClient.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions IVPNClient/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,7 @@ class AppDelegate: UIResponder {
})
case Config.urlTypeLogin:
if let topViewController = UIApplication.topViewController() {
if #available(iOS 13.0, *) {
topViewController.present(NavigationManager.getLoginViewController(), animated: true, completion: nil)
} else {
topViewController.present(NavigationManager.getLoginViewController(), animated: true, completion: nil)
}
topViewController.present(NavigationManager.getLoginViewController(), animated: true, completion: nil)
}
default:
break
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "icon-arrow-down-gray.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "icon-arrow-up-gray.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Binary file not shown.
23 changes: 0 additions & 23 deletions IVPNClient/Config/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,6 @@ struct Config {
static let stableVPNStatusInterval: TimeInterval = 0.5

static let defaultProtocol = ConnectionSettings.wireguard(.udp, 2049)
static let supportedProtocols = [
ConnectionSettings.ipsec,
ConnectionSettings.openvpn(.udp, 2049),
ConnectionSettings.openvpn(.udp, 2050),
ConnectionSettings.openvpn(.udp, 53),
// ConnectionSettings.openvpn(.udp, 80),
// ConnectionSettings.openvpn(.udp, 443),
ConnectionSettings.openvpn(.udp, 1194),
ConnectionSettings.openvpn(.tcp, 443),
ConnectionSettings.openvpn(.tcp, 1443),
ConnectionSettings.openvpn(.tcp, 80),
ConnectionSettings.wireguard(.udp, 2049),
ConnectionSettings.wireguard(.udp, 2050),
ConnectionSettings.wireguard(.udp, 53),
// ConnectionSettings.wireguard(.udp, 80),
// ConnectionSettings.wireguard(.udp, 443),
ConnectionSettings.wireguard(.udp, 1194),
ConnectionSettings.wireguard(.udp, 30587),
ConnectionSettings.wireguard(.udp, 41893),
ConnectionSettings.wireguard(.udp, 48574),
ConnectionSettings.wireguard(.udp, 58237)
]

static let supportedProtocolTypes = [
ConnectionSettings.wireguard(.udp, 2049),
ConnectionSettings.ipsec,
Expand Down
2 changes: 1 addition & 1 deletion IVPNClient/Config/servers.json

Large diffs are not rendered by default.

46 changes: 40 additions & 6 deletions IVPNClient/Enums/ConnectionSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ enum ConnectionSettings {
case wireguard(WireGuardProtocol, Int)

func format() -> String {
if UserDefaults.shared.isMultiHop {
return formatMultiHop()
}

switch self {
case .ipsec:
return "IKEv2"
Expand All @@ -56,7 +60,7 @@ enum ConnectionSettings {
case .udp:
return "OpenVPN, UDP"
}
case .wireguard(_, _):
case .wireguard:
return "WireGuard, UDP"
}
}
Expand Down Expand Up @@ -137,7 +141,7 @@ enum ConnectionSettings {
}

func supportedProtocolsFormat(protocols: [ConnectionSettings]) -> [String] {
let protocols = supportedProtocols(protocols: Config.supportedProtocols)
let protocols = supportedProtocols(protocols: protocols)
return protocols.map({ $0.formatProtocol() })
}

Expand All @@ -146,11 +150,41 @@ enum ConnectionSettings {
}

static func getSavedProtocol() -> ConnectionSettings {
let protocolIndex = UserDefaults.standard.integer(forKey: UserDefaults.Key.selectedProtocolIndex)
let portString = UserDefaults.standard.string(forKey: UserDefaults.Key.selectedProtocol) ?? ""
return getFrom(portString: portString)
}

static func getFrom(portString: String) -> ConnectionSettings {
var name = ""
var proto = ""
var port = 0
let components = portString.components(separatedBy: "-")

if let protocolName = components[safeIndex: 0] {
name = protocolName
}
if let protocolType = components[safeIndex: 1] {
proto = protocolType
}
if let protocolPort = components[safeIndex: 2] {
port = Int(protocolPort) ?? 0
}

if Config.supportedProtocols.indices.contains(protocolIndex) && UserDefaults.standard.object(forKey: UserDefaults.Key.selectedProtocolIndex) != nil || !(KeyChain.sessionToken ?? "").isEmpty {
return Config.supportedProtocols[protocolIndex]
} else {
switch name {
case "ikev2":
return .ipsec
case "openvpn":
switch proto {
case "tcp":
return .openvpn(.tcp, port)
case "udp":
return .openvpn(.udp, port)
default:
return Config.defaultProtocol
}
case "wireguard":
return .wireguard(.udp, port)
default:
return Config.defaultProtocol
}
}
Expand Down
6 changes: 6 additions & 0 deletions IVPNClient/Managers/APIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ class APIClient: NSObject {
urlComponents.path = baseURL.path
urlComponents.queryItems = request.queryItems

// TODO: Remove when fixed in future iOS versions
// https://github.com/ivpn/ios-app/issues/276
if #available(iOS 16.0, *), let addressType = request.addressType, addressType == .IPv6 {
urlComponents.host = "[\(hostName)]"
}

if request.method == .post {
urlComponents.queryItems = []
}
Expand Down
2 changes: 1 addition & 1 deletion IVPNClient/Managers/ConnectionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ class ConnectionManager {
}

getWireGuardLog { _ in
var wireGuardLog: String? = nil
var wireGuardLog: String?
let filePath = FileSystemManager.sharedFilePath(name: "WireGuard.log").path
if let file = NSData(contentsOfFile: filePath) {
wireGuardLog = String(data: file as Data, encoding: .utf8) ?? ""
Expand Down
12 changes: 12 additions & 0 deletions IVPNClient/Managers/NavigationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,16 @@ class NavigationManager {
return navController!
}

static func getAddCustomPortViewController(delegate: AddCustomPortViewControllerDelegate? = nil) -> UIViewController {
let storyBoard = UIStoryboard(name: "Main", bundle: nil)
let navController = storyBoard.instantiateViewController(withIdentifier: "addCustomPort") as? UINavigationController
navController?.modalPresentationStyle = .formSheet

if let viewController = navController?.topViewController as? AddCustomPortViewController {
viewController.delegate = delegate
}

return navController!
}

}
1 change: 1 addition & 0 deletions IVPNClient/Managers/SessionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class SessionManager {
switch result {
case .success(let model):
Application.shared.serviceStatus = model.serviceStatus
NotificationCenter.default.post(name: Notification.Name.EvaluatePlanUpdate, object: nil)

if model.serviceActive {
self.delegate?.sessionStatusSuccess()
Expand Down
24 changes: 24 additions & 0 deletions IVPNClient/Managers/StorageManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class StorageManager {
static func clearSession() {
remove(entityName: "Network")
remove(entityName: "Server")
remove(entityName: "CustomPort")
}

static func remove(entityName: String) {
Expand Down Expand Up @@ -154,6 +155,29 @@ extension StorageManager {
}
}

static func saveCustomPort(vpnProtocol: String = "", type: String = "", port: Int = 0) {
let customPort = CustomPort(context: context)
customPort.vpnProtocol = vpnProtocol
customPort.type = type
customPort.port = Int32(port)
saveContext()
}

static func fetchCustomPorts(vpnProtocol: String = "") -> [CustomPort]? {
let request: NSFetchRequest<CustomPort> = CustomPort.fetchRequest(vpnProtocol: vpnProtocol)

do {
let result = try context.fetch(request)
if !result.isEmpty {
return result
}
} catch {
log(error: "Coult not load collection from StorageManager")
}

return nil
}

}

// MARK: - NEOnDemandRule -
Expand Down
2 changes: 1 addition & 1 deletion IVPNClient/Managers/VPNManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ class VPNManager {
}

do {
try session.sendProviderMessage(Message.requestLog.data) { data in
try session.sendProviderMessage(Message.requestLog.data) { _ in
completion(nil)
return
}
Expand Down
11 changes: 6 additions & 5 deletions IVPNClient/Model.xcdatamodeld/Model.xcdatamodel/contents
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="17192" systemVersion="19H2" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21511" systemVersion="22A5352e" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="CustomPort" representedClassName="CustomPort" syncable="YES">
<attribute name="port" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="type" optional="YES" attributeType="String"/>
<attribute name="vpnProtocol" optional="YES" attributeType="String"/>
</entity>
<entity name="Network" representedClassName="Network" syncable="YES">
<attribute name="isDefault" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="name" optional="YES" attributeType="String"/>
Expand All @@ -10,8 +15,4 @@
<attribute name="gateway" optional="YES" attributeType="String"/>
<attribute name="isFastestEnabled" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
</entity>
<elements>
<element name="Network" positionX="-54" positionY="-9" width="128" height="105"/>
<element name="Server" positionX="-54" positionY="18" width="128" height="73"/>
</elements>
</model>
30 changes: 30 additions & 0 deletions IVPNClient/Models/CoreData/CustomPort+CoreDataClass.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// CustomPort+CoreDataClass.swift
// IVPN iOS app
// https://github.com/ivpn/ios-app
//
// Created by Juraj Hilje on 2022-10-05.
// Copyright (c) 2022 Privatus Limited.
//
// This file is part of the IVPN iOS app.
//
// The IVPN iOS app is free software: you can redistribute it and/or
// modify it under the terms of the GNU General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any later version.
//
// The IVPN iOS app is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details.
//
// You should have received a copy of the GNU General Public License
// along with the IVPN iOS app. If not, see <https://www.gnu.org/licenses/>.
//

import Foundation
import CoreData

@objc(CustomPort)
public class CustomPort: NSManagedObject {

}
Loading

0 comments on commit 15b1841

Please sign in to comment.