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

Add connection detail toggle to connection view #7388

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
36 changes: 36 additions & 0 deletions ios/MullvadMockData/MullvadREST/SelectedRelaysStub+Stubs.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// SelectedRelaysStub+Stubs.swift
// MullvadVPN
//
// Created by Jon Petersson on 2024-12-18.
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
//

import MullvadREST
import MullvadTypes
import Network

public struct SelectedRelaysStub {
public static let selectedRelays = SelectedRelays(
entry: nil,
exit: SelectedRelay(
endpoint: MullvadEndpoint(
ipv4Relay: IPv4Endpoint(ip: .loopback, port: 42),
ipv6Relay: IPv6Endpoint(ip: .loopback, port: 42),
ipv4Gateway: IPv4Address.loopback,
ipv6Gateway: IPv6Address.loopback,
publicKey: Data()
),
hostname: "se-got-wg-001",
location: Location(
country: "Sweden",
countryCode: "se",
city: "Gothenburg",
cityCode: "got",
latitude: 42,
longitude: 42
)
),
retryAttempt: 0
)
}
3 changes: 0 additions & 3 deletions ios/MullvadRustRuntime/EphemeralPeerNegotiator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import MullvadTypes
import NetworkExtension
import WireGuardKitTypes

// swiftlint:disable function_parameter_count
public protocol EphemeralPeerNegotiating {
func startNegotiation(
devicePublicKey: PublicKey,
Expand Down Expand Up @@ -70,5 +69,3 @@ public class EphemeralPeerNegotiator: EphemeralPeerNegotiating {
drop_ephemeral_peer_exchange_token(cancelToken)
}
}

// swiftlint:enable function_parameter_count
3 changes: 0 additions & 3 deletions ios/MullvadRustRuntimeTests/MullvadPostQuantum+Stubs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import NetworkExtension
@testable import PacketTunnelCore
@testable import WireGuardKitTypes

// swiftlint:disable function_parameter_count
class NWTCPConnectionStub: NWTCPConnection {
var _isViable = false
override var isViable: Bool {
Expand Down Expand Up @@ -104,5 +103,3 @@ class SuccessfulNegotiatorStub: EphemeralPeerNegotiating {
onCancelKeyNegotiation?()
}
}

// swiftlint:enable function_parameter_count
10 changes: 9 additions & 1 deletion ios/MullvadSettings/IPOverrideRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
//

import Foundation
import Combine
import MullvadLogging

public protocol IPOverrideRepositoryProtocol {
var overridesPublisher: AnyPublisher<[IPOverride], Never> { get }
func add(_ overrides: [IPOverride])
func fetchAll() -> [IPOverride]
func deleteAll()
func parse(data: Data) throws -> [IPOverride]
}

public class IPOverrideRepository: IPOverrideRepositoryProtocol {
private let overridesSubject: CurrentValueSubject<[IPOverride], Never> = .init([])
public var overridesPublisher: AnyPublisher<[IPOverride], Never> {
overridesSubject.eraseToAnyPublisher()
}

private let logger = Logger(label: "IPOverrideRepository")
private let readWriteLock = NSLock()

Expand Down Expand Up @@ -58,6 +64,7 @@ public class IPOverrideRepository: IPOverrideRepositoryProtocol {
do {
try readWriteLock.withLock {
try SettingsManager.store.delete(key: .ipOverrides)
overridesSubject.send([])
}
} catch {
logger.error("Could not delete all overrides. \nError: \(error)")
Expand Down Expand Up @@ -85,6 +92,7 @@ public class IPOverrideRepository: IPOverrideRepositoryProtocol {

try readWriteLock.withLock {
try SettingsManager.store.write(data, for: .ipOverrides)
overridesSubject.send(overrides)
}
}

Expand Down
4 changes: 4 additions & 0 deletions ios/MullvadSettings/WireGuardObfuscationSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public enum WireGuardObfuscationState: Codable {
self = .off
}
}

public var isEnabled: Bool {
[.udpOverTcp, .shadowsocks].contains(self)
}
}

public enum WireGuardObfuscationUdpOverTcpPort: Codable, Equatable, CustomStringConvertible {
Expand Down
84 changes: 74 additions & 10 deletions ios/MullvadVPN.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions ios/MullvadVPN/Classes/AccessbilityIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public enum AccessibilityIdentifier: Equatable {
case purchaseButton
case redeemVoucherButton
case restorePurchasesButton
case secureConnectionButton
case connectButton
case selectLocationButton
case closeSelectLocationButton
case settingsButton
Expand Down Expand Up @@ -132,7 +132,7 @@ public enum AccessibilityIdentifier: Equatable {
case selectLocationTableView
case settingsTableView
case vpnSettingsTableView
case tunnelControlView
case connectionView
case problemReportView
case problemReportSubmittedView
case revokedDeviceView
Expand All @@ -156,6 +156,7 @@ public enum AccessibilityIdentifier: Equatable {
case logOutSpinnerAlertView
case connectionPanelInAddressRow
case connectionPanelOutAddressRow
case connectionPanelOutIpv6AddressRow
case customSwitch
case customWireGuardPortTextField
case dnsContentBlockersHeaderView
Expand Down
3 changes: 2 additions & 1 deletion ios/MullvadVPN/Coordinators/ApplicationCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,8 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo
private func makeTunnelCoordinator() -> TunnelCoordinator {
let tunnelCoordinator = TunnelCoordinator(
tunnelManager: tunnelManager,
outgoingConnectionService: outgoingConnectionService
outgoingConnectionService: outgoingConnectionService,
ipOverrideRepository: ipOverrideRepository
)

tunnelCoordinator.showSelectLocationPicker = { [weak self] in
Expand Down
16 changes: 14 additions & 2 deletions ios/MullvadVPN/Coordinators/TunnelCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@
// Copyright © 2023 Mullvad VPN AB. All rights reserved.
//

import MullvadSettings
import Routing
import UIKit

class TunnelCoordinator: Coordinator, Presenting {
private let tunnelManager: TunnelManager

#if DEBUG
private let controller: FI_TunnelViewController
#else
private let controller: TunnelViewController
#endif

private var tunnelObserver: TunnelObserver?

Expand All @@ -27,16 +33,22 @@ class TunnelCoordinator: Coordinator, Presenting {

init(
tunnelManager: TunnelManager,
outgoingConnectionService: OutgoingConnectionServiceHandling
outgoingConnectionService: OutgoingConnectionServiceHandling,
ipOverrideRepository: IPOverrideRepositoryProtocol
) {
self.tunnelManager = tunnelManager

let interactor = TunnelViewControllerInteractor(
tunnelManager: tunnelManager,
outgoingConnectionService: outgoingConnectionService
outgoingConnectionService: outgoingConnectionService,
ipOverrideRepository: ipOverrideRepository
)

#if DEBUG
controller = FI_TunnelViewController(interactor: interactor)
#else
controller = TunnelViewController(interactor: interactor)
#endif

super.init()

Expand Down
6 changes: 5 additions & 1 deletion ios/MullvadVPN/Extensions/String+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright © 2020 Mullvad VPN AB. All rights reserved.
//

import Foundation
import UIKit

extension String {
Expand All @@ -19,4 +18,9 @@ extension String {
return (0 ..< resultCount)
.map { dropFirst($0 * length).prefix(length) }
}

func width(using font: UIFont) -> CGFloat {
let fontAttributes = [NSAttributedString.Key.font: font]
return self.size(withAttributes: fontAttributes).width
}
}
41 changes: 41 additions & 0 deletions ios/MullvadVPN/Extensions/View+Conditionals.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// View+Conditionals.swift
// MullvadVPN
//
// Created by Jon Petersson on 2025-01-07.
// Copyright © 2025 Mullvad VPN AB. All rights reserved.
//

import SwiftUI

extension View {
@ViewBuilder func `if`<Content: View>(
_ conditional: Bool,
@ViewBuilder _ content: (Self) -> Content
) -> some View {
if conditional {
content(self)
} else {
self
}
}

@ViewBuilder func ifLet<Content: View, T>(
_ conditional: T?,
@ViewBuilder _ content: (Self, _ value: T) -> Content
) -> some View {
if let value = conditional {
content(self, value)
} else {
self
}
}

@ViewBuilder func showIf(_ conditional: Bool) -> some View {
if conditional {
self
} else {
EmptyView()
}
}
}
5 changes: 2 additions & 3 deletions ios/MullvadVPN/Extensions/View+TapAreaSize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ extension View {
}

private struct TappablePadding: ViewModifier {
@State var actualViewSize: CGSize = .zero
let tappableViewSize = UIMetrics.Button.minimumTappableAreaSize
@State private var actualViewSize: CGSize = .zero
private let tappableViewSize = UIMetrics.Button.minimumTappableAreaSize

func body(content: Content) -> some View {
content
Expand All @@ -28,6 +28,5 @@ private struct TappablePadding: ViewModifier {
height: max(actualViewSize.height, tappableViewSize.height)
)
.contentShape(Rectangle())
.frame(width: actualViewSize.width, height: actualViewSize.height)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "IconReload.pdf",
"filename" : "icon-reload.svg",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions ios/MullvadVPN/UI appearance/UIMetrics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ enum UIMetrics {
enum MainButton {
static let cornerRadius: CGFloat = 4
}

enum FeatureIndicators {
static let chipViewHorisontalPadding: CGFloat = 8
static let chipViewTrailingMargin: CGFloat = 6
}
}

extension UIMetrics {
Expand Down
Loading
Loading