Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obfuscation with V2Ray #371

Merged
merged 81 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
de5e549
feat(v2ray): add v2ray-core submodule
jurajhilje Jul 31, 2023
06d798c
feat(v2ray): create build.sh
jurajhilje Jul 31, 2023
d5fa1c4
feat(v2ray): link V2Ray.xcframework
jurajhilje Aug 4, 2023
d164004
feat(v2ray): create Decodable+Ext.swift
jurajhilje Aug 4, 2023
052c9d9
feat(v2ray): create V2RayConfig.swift
jurajhilje Aug 4, 2023
162b7b7
feat(v2ray): create VmessEndpoint.swift
jurajhilje Aug 5, 2023
dbd362d
Merge branch 'develop' into feature/v2ray
jurajhilje Aug 7, 2023
6f70d83
Merge branch 'develop' into feature/v2ray
jurajhilje Aug 8, 2023
96348d3
Merge branch 'develop' into feature/v2ray
jurajhilje Aug 22, 2023
a02f5cd
docs: update licence header
jurajhilje Aug 22, 2023
2247dc2
feat: create V2RayCore.swift
jurajhilje Aug 23, 2023
cbb22a2
feat: create V2Ray/config.json
jurajhilje Aug 23, 2023
e70df08
feat: update V2RayCore.swift
jurajhilje Aug 23, 2023
455e0f8
feat: update V2Ray/config.json
jurajhilje Aug 23, 2023
94eca7a
feat: update V2RayConfig.swift
jurajhilje Aug 24, 2023
34d6bc1
feat: update V2RayConfig.swift
jurajhilje Aug 24, 2023
59e19c5
refactor: update AddressType.swift
jurajhilje Aug 26, 2023
da8c985
refactor: update Interface.swift
jurajhilje Aug 26, 2023
031225d
refactor: remove openvpn-tunnel-provider/Curve25519
jurajhilje Aug 26, 2023
05c09f8
build: update build.sh
jurajhilje Aug 26, 2023
b32d24a
build: update build.sh
jurajhilje Aug 26, 2023
7607282
Merge branch 'develop' into feature/v2ray
jurajhilje Sep 2, 2023
e206ff2
feat: update V2RayCore.swift
jurajhilje Sep 2, 2023
52b77dd
feat: update V2RayCore.swift
jurajhilje Sep 8, 2023
e920e57
feat: update V2RayCore.swift
jurajhilje Sep 9, 2023
f3fb29f
feat: create configv5.json
jurajhilje Sep 11, 2023
449c6aa
feat: update V2RayConfig.swift
jurajhilje Sep 12, 2023
e3d3010
feat: update V2RayCore.swift
jurajhilje Sep 12, 2023
e2d9321
feat: update .entitlements
jurajhilje Sep 12, 2023
e4d4448
feat: update V2RayConfig.swift
jurajhilje Sep 13, 2023
fa2d455
feat: add jsonString method in V2RayConfig.swift
jurajhilje Sep 13, 2023
4e40a4c
feat: import V2RayControl.xcframework
jurajhilje Sep 14, 2023
28821b9
feat: update V2RayCore.swift
jurajhilje Sep 15, 2023
f470492
feat: add TcpSettings in V2RayConfig.swift
jurajhilje Sep 18, 2023
b2ffbda
feat: add v2ray property in Host.swift
jurajhilje Sep 18, 2023
69fa660
feat: create V2RayPorts.swift
jurajhilje Sep 18, 2023
14eae4b
feat: add makeConfig method in V2RayCore.swift
jurajhilje Sep 18, 2023
84abb80
feat: update V2RayConfig.swift and config.json
jurajhilje Sep 18, 2023
0699692
feat: update NETunnelProviderProtocol+Ext.swift
jurajhilje Sep 18, 2023
8bb182f
feat: update NETunnelProviderProtocol+Ext.swift
jurajhilje Sep 18, 2023
f142cf0
feat: refactor V2RayPorts.swift
jurajhilje Sep 18, 2023
051e9a0
feat: update V2RaySettings.swift
jurajhilje Sep 18, 2023
2296d04
feat: update NETunnelProviderProtocol+Ext.swift
jurajhilje Sep 18, 2023
a5ff2d1
feat: update NETunnelProviderProtocol+Ext.swift
jurajhilje Sep 19, 2023
f253638
feat: update build.sh
jurajhilje Sep 20, 2023
e72e10c
Merge branch 'develop' into feature/v2ray
jurajhilje Sep 20, 2023
80b1fe4
feat: update config.json
jurajhilje Sep 20, 2023
a61b72f
feat: update V2RayCore.swift
jurajhilje Sep 20, 2023
0891041
feat: update ConnectionManager.swift
jurajhilje Sep 22, 2023
5ffc441
feat: update UserDefaults+Ext.swift
jurajhilje Sep 22, 2023
9f21c0b
feat: update UserDefaults+Ext.swift
jurajhilje Sep 26, 2023
0e3a7a5
feat: update AdvancedViewController.swift
jurajhilje Sep 26, 2023
31e8336
feat: update ProtocolViewController.swift
jurajhilje Sep 26, 2023
bb37941
feat: update AdvancedViewController.swift
jurajhilje Sep 26, 2023
9672f40
feat: update V2RayCore.swift
jurajhilje Sep 26, 2023
b5b2fa8
refactor: update ConnectionManager.swift
jurajhilje Sep 27, 2023
aa65287
feat: update V2RayControl/ctrl.go
jurajhilje Sep 29, 2023
1b8ca7c
feat: update UITableViewDelegate in AdvancedViewController
jurajhilje Oct 10, 2023
c6989a1
feat: update selectV2rayProtocol method in AdvancedViewController
jurajhilje Oct 10, 2023
685f11d
fix: update UITableViewDelegate in AdvancedViewController
jurajhilje Oct 10, 2023
25094f9
feat: update UITableViewDataSource in ProtocolViewController
jurajhilje Oct 11, 2023
199a825
feat: update PortViewController
jurajhilje Oct 11, 2023
9e1293b
feat: update ConnectionSettings.swift
jurajhilje Oct 11, 2023
2ca3f27
feat: update ConnectionSettings.swift
jurajhilje Oct 11, 2023
19cb0fc
ci: update .swiftlint.yml
jurajhilje Oct 12, 2023
862555e
chore: revert changes in PortViewController
jurajhilje Oct 16, 2023
84627e2
feat: update ConnectionInfoViewModel
jurajhilje Oct 23, 2023
e84513a
feat: update Main.storyboard
jurajhilje Oct 23, 2023
8751104
feat: update ConnectionInfoViewModel
jurajhilje Oct 23, 2023
ab7dc5e
feat: update AdvancedViewController
jurajhilje Oct 23, 2023
1a5d2bb
feat: update Main.storyboard
jurajhilje Oct 23, 2023
9d3e262
feat: update IVPNWidget.swift for iOS 17
jurajhilje Oct 23, 2023
76136c9
docs: update README.md
jurajhilje Oct 27, 2023
fe1aaad
feat: update supportedProtocols method in ConnectionSettings.swift
jurajhilje Nov 2, 2023
9d9d58c
feat: update PortViewController.swift
jurajhilje Nov 2, 2023
ca8a1af
feat: update AdvancedViewController.swift
jurajhilje Nov 2, 2023
5e2a71e
Merge branch 'develop' into feature/v2ray
jurajhilje Nov 6, 2023
2967aae
feat: update AddCustomPortViewController.swift
jurajhilje Nov 7, 2023
a506ba2
Merge branch 'develop' into feature/v2ray
jurajhilje Nov 8, 2023
44ae5c2
feat: update AdvancedViewController.swift
jurajhilje Nov 8, 2023
d0450f0
feat: update SettingsViewController.swift
jurajhilje Nov 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,7 @@ OpenVPNConf.swift
# Fastlane
fastlane/test_output
fastlane/report.xml
fastlane/Appfile
fastlane/Appfile

# Frameworks
Frameworks
2 changes: 1 addition & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ file_length:
ignore_comment_only_lines: true
cyclomatic_complexity:
warning: 15
error: 35
error: 45
reporter: "xcode"
69 changes: 47 additions & 22 deletions IVPNClient.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions IVPNClient/Config/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ struct Config {
static let wgKeyExpirationDays = 30
static let wgKeyRegenerationRate = 1

// MARK: V2Ray

static let v2rayHost = "127.0.0.1"
static let v2rayPort = 16661

// MARK: ENV variables

static var Environment: String {
Expand Down
16 changes: 7 additions & 9 deletions IVPNClient/Enums/AddressType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,22 @@
// along with the IVPN iOS app. If not, see <https://www.gnu.org/licenses/>.
//

import Network

enum AddressType {

case IPv6
case IPv4
case other

static func validateIpAddress(ipToValidate: String) -> AddressType {
var sin = sockaddr_in()
if ipToValidate.withCString({ cstring in inet_pton(AF_INET, cstring, &sin.sin_addr) }) == 1 {
static func validateIpAddress(_ address: String) -> AddressType {
if let _ = IPv4Address(address) {
return .IPv4
}

var sin6 = sockaddr_in6()
if ipToValidate.withCString({ cstring in inet_pton(AF_INET6, cstring, &sin6.sin6_addr) }) == 1 {
} else if let _ = IPv6Address(address) {
return .IPv6
} else {
return .other
}

return .other
}

}
42 changes: 37 additions & 5 deletions IVPNClient/Enums/ConnectionSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ enum ConnectionSettings {
return "OpenVPN, UDP \(port)"
}
case .wireguard(_, let port):
return "WireGuard, UDP \(port)"
return "WireGuard, \(wireguardProtocol()) \(port)"
}
}

Expand All @@ -60,8 +60,12 @@ enum ConnectionSettings {
case .udp:
return "OpenVPN, UDP"
}
case .wireguard:
return "WireGuard, UDP"
case .wireguard(_, let port):
if UserDefaults.shared.isV2ray {
return "WireGuard, \(wireguardProtocol()) \(port)"
}

return "WireGuard, \(wireguardProtocol())"
}
}

Expand Down Expand Up @@ -104,7 +108,27 @@ enum ConnectionSettings {
return "UDP \(port)"
}
case .wireguard(_, let port):
return "UDP \(port)"
return "\(wireguardProtocol()) \(port)"
}
}

func formatProtocolMultiHop() -> String {
switch self {
case .ipsec:
return "IKEv2"
case .openvpn(let proto, _):
switch proto {
case .tcp:
return "TCP"
case .udp:
return "UDP"
}
case .wireguard(_, let port):
if UserDefaults.shared.isV2ray {
return "\(wireguardProtocol()) \(port)"
}

return "\(wireguardProtocol())"
}
}

Expand Down Expand Up @@ -227,8 +251,16 @@ enum ConnectionSettings {
return "UDP"
}
case .wireguard:
return "UDP"
return wireguardProtocol()
}
}

func wireguardProtocol() -> String {
if UserDefaults.shared.isV2ray && UserDefaults.shared.v2rayProtocol == "tcp" {
return "TCP"
}

return "UDP"
}

static func == (lhs: ConnectionSettings, rhs: ConnectionSettings) -> Bool {
Expand Down
1 change: 0 additions & 1 deletion IVPNClient/IVPNClient-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#include "../WireGuardKitC/WireGuardKitC.h"
#include "Utilities/Logging/ringlogger.h"
#include "liboqs/include/oqs/oqs.h"
2 changes: 2 additions & 0 deletions IVPNClient/IVPNClient.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<string>NSFileProtectionCompleteUntilFirstUserAuthentication</string>
<key>com.apple.developer.networking.networkextension</key>
<array>
<string>app-proxy-provider</string>
<string>content-filter-provider</string>
<string>packet-tunnel-provider</string>
</array>
<key>com.apple.developer.networking.vpn.api</key>
Expand Down
30 changes: 30 additions & 0 deletions IVPNClient/Managers/ConnectionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ class ConnectionManager {
self.evaluateCloseApp()
}
}
DispatchQueue.delay(2.5) {
if UserDefaults.shared.isV2ray && !V2RayCore.shared.reconnectWithV2ray {
V2RayCore.shared.reconnectWithV2ray = true
self.reconnect()
} else {
V2RayCore.shared.reconnectWithV2ray = false
}
}
} else {
self.connected = false
}
Expand Down Expand Up @@ -247,6 +255,17 @@ class ConnectionManager {
return
}

if UserDefaults.shared.isV2ray && V2RayCore.shared.reconnectWithV2ray {
DispatchQueue.global(qos: .userInitiated).async {
let error = V2RayCore.shared.start()
if error != nil {
log(.error, message: error?.localizedDescription ?? "")
} else {
log(.info, message: "V2Ray start OK")
}
}
}

self.vpnManager.connect(tunnelType: self.settings.connectionProtocol.tunnelType())
}
}
Expand All @@ -263,6 +282,17 @@ class ConnectionManager {
}
}
}

if UserDefaults.shared.isV2ray {
DispatchQueue.global(qos: .userInitiated).async {
let error = V2RayCore.shared.close()
if error != nil {
log(.error, message: error?.localizedDescription ?? "")
} else {
log(.info, message: "V2Ray stop OK")
}
}
}
}

func installOnDemandRules() {
Expand Down
1 change: 1 addition & 0 deletions IVPNClient/Models/Host.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct Host: Codable {
var ipv6: IPv6?
var multihopPort: Int
var load: Double
var v2ray: String

func localIPAddress() -> String {
if let range = localIP.range(of: "/", options: .backwards, range: nil, locale: nil) {
Expand Down
Loading