mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Debug clearnet changes
This commit is contained in:
parent
936287683f
commit
2111e73675
5 changed files with 15 additions and 9 deletions
|
@ -44,6 +44,7 @@ public extension LokiAPI {
|
|||
if randomSnodePool.isEmpty {
|
||||
let url = URL(string: "http://3.104.19.14:22023/json_rpc")!
|
||||
let request = TSRequest(url: url, method: "POST", parameters: [ "method" : "get_service_nodes" ])
|
||||
print("[Loki] Invoking get_service_nodes on http://3.104.19.14:22023.")
|
||||
return TSNetworkManager.shared().makePromise(request: request).map { intermediate in
|
||||
let rawResponse = intermediate.responseObject
|
||||
guard let json = rawResponse as? JSON, let intermediate = json["result"] as? JSON, let rawTargets = intermediate["service_node_states"] as? [JSON] else { throw "Failed to update random snode pool from: \(rawResponse)." }
|
||||
|
@ -82,8 +83,11 @@ public extension LokiAPI {
|
|||
return []
|
||||
}
|
||||
return rawSnodes.flatMap { rawSnode in
|
||||
guard let address = rawSnode["ip"] as? String, let port = rawSnode["port"] as? Int else { return nil }
|
||||
return LokiAPITarget(address: address, port: UInt16(port))
|
||||
guard let address = rawSnode["ip"] as? String, let portAsString = rawSnode["port"] as? String, let port = UInt16(portAsString) else {
|
||||
print("[Loki] Failed to parse target from: \(rawSnode).")
|
||||
return nil
|
||||
}
|
||||
return LokiAPITarget(address: "https://\(address)", port: port)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,13 @@ public final class LokiAPI : NSObject {
|
|||
if let timeout = timeout { request.timeoutInterval = timeout ?? defaultTimeout }
|
||||
let headers = request.allHTTPHeaderFields ?? [:]
|
||||
let headersDescription = headers.isEmpty ? "no custom headers specified" : headers.description
|
||||
print("[Loki] Invoking \(method.rawValue) on \(url) with \(parameters) (\(headersDescription)).")
|
||||
let parametersDescription = "[ " + parameters.map { key, value in
|
||||
let valueDescription = String(describing: value)
|
||||
let maxLength = 20
|
||||
let truncatedValueDescription = valueDescription.count > maxLength ? valueDescription.prefix(maxLength) + "..." : valueDescription
|
||||
return key + " : " + truncatedValueDescription
|
||||
}.joined(separator: ", ") + " ]"
|
||||
print("[Loki] Invoking \(method.rawValue) on \(target) with \(parametersDescription) (\(headersDescription)).")
|
||||
return TSNetworkManager.shared().makePromise(request: request).map { $0.responseObject }
|
||||
.handlingSwarmSpecificErrorsIfNeeded(for: target, associatedWith: hexEncodedPublicKey).recoveringNetworkErrorsIfNeeded()
|
||||
}
|
||||
|
|
|
@ -31,5 +31,5 @@ internal final class LokiAPITarget : NSObject, NSCoding {
|
|||
}
|
||||
|
||||
// MARK: Description
|
||||
override var description: String { return "\(address):\(port)" }
|
||||
override var description: String { return "https://\(address):\(port)" }
|
||||
}
|
||||
|
|
|
@ -185,11 +185,8 @@ NSString *const kNSNotificationName_IsCensorshipCircumventionActiveDidChange =
|
|||
|
||||
- (AFHTTPSessionManager *)defaultSignalServiceSessionManager
|
||||
{
|
||||
NSURL *baseURL = [[NSURL alloc] initWithString:textSecureServerURL];
|
||||
OWSAssertDebug(baseURL);
|
||||
NSURLSessionConfiguration *sessionConf = NSURLSessionConfiguration.ephemeralSessionConfiguration;
|
||||
AFHTTPSessionManager *sessionManager =
|
||||
[[AFHTTPSessionManager alloc] initWithBaseURL:baseURL sessionConfiguration:sessionConf];
|
||||
AFHTTPSessionManager *sessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:sessionConf];
|
||||
|
||||
AFSecurityPolicy *securityPolicy = AFSecurityPolicy.defaultPolicy;
|
||||
securityPolicy.allowInvalidCertificates = YES;
|
||||
|
|
|
@ -27,7 +27,6 @@ typedef NS_ENUM(NSInteger, TSWhisperMessageType) {
|
|||
|
||||
// Production
|
||||
#define textSecureWebSocketAPI @"wss://textsecure-service.whispersystems.org/v1/websocket/"
|
||||
#define textSecureServerURL @"https://textsecure-service.whispersystems.org/"
|
||||
#define textSecureCDNServerURL @"https://cdn.signal.org"
|
||||
// Use same reflector for service and CDN
|
||||
#define textSecureServiceReflectorHost @"europe-west1-signal-cdn-reflector.cloudfunctions.net"
|
||||
|
|
Loading…
Reference in a new issue