diff --git a/ios/MullvadREST/HTTP.swift b/ios/MullvadREST/HTTP.swift index 900ab2a49aee..93074fdbd35a 100644 --- a/ios/MullvadREST/HTTP.swift +++ b/ios/MullvadREST/HTTP.swift @@ -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" } diff --git a/ios/MullvadREST/RESTRequestFactory.swift b/ios/MullvadREST/RESTRequestFactory.swift index 00ed23e9aea2..f0a3f3334eb4 100644 --- a/ios/MullvadREST/RESTRequestFactory.swift +++ b/ios/MullvadREST/RESTRequestFactory.swift @@ -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 diff --git a/ios/PacketTunnel/PacketTunnelProvider.swift b/ios/PacketTunnel/PacketTunnelProvider.swift index 910c8b2befa2..e115c5a34049 100644 --- a/ios/PacketTunnel/PacketTunnelProvider.swift +++ b/ios/PacketTunnel/PacketTunnelProvider.swift @@ -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 @@ -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 } @@ -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 {