Skip to content

Commit

Permalink
Merge branch 'prep-ios-for-same-ip' into ios-release-2023.6
Browse files Browse the repository at this point in the history
  • Loading branch information
pinkisemils committed Oct 11, 2023
2 parents 319b2eb + a9f8b56 commit 6f9d8d1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
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

0 comments on commit 6f9d8d1

Please sign in to comment.