From 838f097d6552036410b0c44d38304efcdb85d754 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sat, 23 Mar 2019 16:15:22 +0100 Subject: [PATCH 1/2] Parse TLSWrap from infra preset "wrap" --- Passepartout/Sources/Services/InfrastructurePreset.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Passepartout/Sources/Services/InfrastructurePreset.swift b/Passepartout/Sources/Services/InfrastructurePreset.swift index 4c8b44d3..b354e6a6 100644 --- a/Passepartout/Sources/Services/InfrastructurePreset.swift +++ b/Passepartout/Sources/Services/InfrastructurePreset.swift @@ -59,6 +59,8 @@ public struct InfrastructurePreset: Codable { case renegotiatesAfterSeconds = "reneg" + case tlsWrap = "wrap" + case usesPIAPatches = "pia" case randomizeEndpoint = "random" @@ -95,6 +97,7 @@ public struct InfrastructurePreset: Codable { sessionBuilder.clientCertificate = try cfgContainer.decodeIfPresent(CryptoContainer.self, forKey: .clientCertificate) sessionBuilder.clientKey = try cfgContainer.decodeIfPresent(CryptoContainer.self, forKey: .clientKey) sessionBuilder.compressionFraming = try cfgContainer.decode(SessionProxy.CompressionFraming.self, forKey: .compressionFraming) + sessionBuilder.tlsWrap = try cfgContainer.decodeIfPresent(SessionProxy.TLSWrap.self, forKey: .tlsWrap) sessionBuilder.keepAliveInterval = try cfgContainer.decodeIfPresent(TimeInterval.self, forKey: .keepAliveSeconds) sessionBuilder.renegotiatesAfter = try cfgContainer.decodeIfPresent(TimeInterval.self, forKey: .renegotiatesAfterSeconds) sessionBuilder.usesPIAPatches = try cfgContainer.decodeIfPresent(Bool.self, forKey: .usesPIAPatches) ?? false @@ -120,6 +123,7 @@ public struct InfrastructurePreset: Codable { try cfgContainer.encodeIfPresent(configuration.sessionConfiguration.clientCertificate, forKey: .clientCertificate) try cfgContainer.encodeIfPresent(configuration.sessionConfiguration.clientKey, forKey: .clientKey) try cfgContainer.encode(configuration.sessionConfiguration.compressionFraming, forKey: .compressionFraming) + try cfgContainer.encodeIfPresent(configuration.sessionConfiguration.tlsWrap, forKey: .tlsWrap) try cfgContainer.encodeIfPresent(configuration.sessionConfiguration.keepAliveInterval, forKey: .keepAliveSeconds) try cfgContainer.encodeIfPresent(configuration.sessionConfiguration.renegotiatesAfter, forKey: .renegotiatesAfterSeconds) try cfgContainer.encodeIfPresent(configuration.sessionConfiguration.usesPIAPatches, forKey: .usesPIAPatches) From 65b6cdccbf8e76d0e6f1d64f27c0e7499f339aa1 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 24 Mar 2019 23:36:21 +0100 Subject: [PATCH 2/2] Parse server num and free bit --- Passepartout/Sources/Services/Pool.swift | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Passepartout/Sources/Services/Pool.swift b/Passepartout/Sources/Services/Pool.swift index bb86faee..8e881bab 100644 --- a/Passepartout/Sources/Services/Pool.swift +++ b/Passepartout/Sources/Services/Pool.swift @@ -36,6 +36,10 @@ public struct Pool: Codable, Comparable, CustomStringConvertible { case area + case num + + case isFree = "free" + // case location case hostname @@ -51,6 +55,10 @@ public struct Pool: Codable, Comparable, CustomStringConvertible { public let area: String? + public let num: String? + + public let isFree: Bool? + // public let location: (Double, Double) public let hostname: String @@ -93,10 +101,17 @@ extension Pool { public var localizedCountryArea: String { let countryString = localizedCountry - guard let area = area else { + let zone: String + if let area = area, let num = num { + zone = "\(area) #\(num)" + } else if let area = area { + zone = area + } else if let num = num { + zone = "#\(num)" + } else { return countryString } - return String.init(format: Pool.localizedFormat, countryString, area.uppercased()) + return String.init(format: Pool.localizedFormat, countryString, zone.uppercased()) } public var localizedName: String {