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

Prep iOS for same ip #5269

Merged
merged 2 commits into from
Oct 11, 2023
Merged
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
1 change: 1 addition & 0 deletions ios/MullvadREST/HTTP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ enum HTTPHeader {
static let contentType = "Content-Type"
static let etag = "ETag"
static let ifNoneMatch = "If-None-Match"
static let userAgent = "User-Agent"
}
1 change: 1 addition & 0 deletions ios/MullvadREST/RESTRequestFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ extension REST {
request.httpShouldHandleCookies = false
request.addValue(hostname, forHTTPHeaderField: HTTPHeader.host)
request.addValue("application/json", forHTTPHeaderField: HTTPHeader.contentType)
request.addValue("mullvad-app", forHTTPHeaderField: HTTPHeader.userAgent)
request.httpMethod = method.rawValue

let prefixedPathTemplate = URLPathTemplate(stringLiteral: pathPrefix) + pathTemplate
Expand Down
5 changes: 3 additions & 2 deletions ios/PacketTunnel/PacketTunnelProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
let selectorResult = tunnelConfiguration.selectorResult
self.selectorResult = selectorResult
self.providerLogger.debug("Set tunnel relay to \(selectorResult.relay.hostname).")
self.logIfDeviceHasSameIP(than: tunnelConfiguration.wgTunnelConfig.interface.addresses)
self.logIfDeviceHasSameIP(as: tunnelConfiguration.wgTunnelConfig.interface.addresses)

// Start tunnel.
self.adapter.start(tunnelConfiguration: tunnelConfiguration.wgTunnelConfig) { error in
Expand Down Expand Up @@ -239,7 +239,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
}
}

private func logIfDeviceHasSameIP(than addresses: [IPAddressRange]) {
private func logIfDeviceHasSameIP(as addresses: [IPAddressRange]) {
let hasIPv4SameAddress = addresses.compactMap { $0.address as? IPv4Address }
.contains { $0 == ApplicationConfiguration.sameIPv4 }
let hasIPv6SameAddress = addresses.compactMap { $0.address as? IPv6Address }
Expand Down Expand Up @@ -664,6 +664,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
providerLogger.debug("Set tunnel relay to \(newTunnelRelay.hostname).")
setReconnecting(true)

logIfDeviceHasSameIP(as: tunnelConfiguration.wgTunnelConfig.interface.addresses)
adapter.update(tunnelConfiguration: tunnelConfiguration.wgTunnelConfig) { error in
self.dispatchQueue.async {
if let error {
Expand Down
Loading