Skip to content

Commit

Permalink
Add Multipath TCP (MPTCP) support
Browse files Browse the repository at this point in the history
MPTCP is a TCP extension allowing to improve network reliabilty by using mutiple network interface for the same TCP connection. Check https://www.mptcp.dev and https://developer.apple.com/documentation/foundation/urlsessionconfiguration/improving_network_reliability_using_multipath_tcp for details.
Changes to this repository consists in setting the multipathServiceType of URLSessionConfiguration to Handover, allowing a seamless transition of interface in case of deterioration
of the connection.
  • Loading branch information
Aperence committed Aug 14, 2024
1 parent e728ca3 commit 95642e9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions SignalServiceKit/Network/ContentProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class ContentProxy: NSObject {
"HTTPSProxy": proxyHost,
"HTTPSPort": proxyPort
]
configuration.multipathServiceType = .handover
return configuration
}

Expand Down
5 changes: 4 additions & 1 deletion SignalServiceKit/Network/OWSUrlSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,16 @@ public class OWSURLSession: NSObject, OWSURLSessionProtocol {
}

public static var defaultConfigurationWithCaching: URLSessionConfiguration {
.ephemeral
let configuration = URLSessionConfiguration.ephemeral
configuration.multipathServiceType = .handover
return configuration
}

public static var defaultConfigurationWithoutCaching: URLSessionConfiguration {
let configuration = URLSessionConfiguration.ephemeral
configuration.urlCache = nil
configuration.requestCachePolicy = .reloadIgnoringLocalCacheData
configuration.multipathServiceType = .handover
return configuration
}

Expand Down
8 changes: 7 additions & 1 deletion SignalServiceKit/Subscriptions/Stripe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,17 @@ fileprivate extension Stripe {
: "pk_test_sngOd8FnXNkpce9nPXawKrJD00kIDngZkD"

static let authorizationHeader = "Basic \(Data("\(publishableKey):".utf8).base64EncodedString())"

static let configuration: URLSessionConfiguration{
let configuration = URLSessionConfiguration.ephemeral
configuration.multipathServiceType = .handover
return configuration
}

static let urlSession = OWSURLSession(
baseUrl: URL(string: "https://api.stripe.com/v1/")!,
securityPolicy: OWSURLSession.defaultSecurityPolicy,
configuration: URLSessionConfiguration.ephemeral
configuration: configuration
)

struct API {
Expand Down
1 change: 1 addition & 0 deletions SignalUI/LinkPreview/LinkPreviewFetcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public class LinkPreviewFetcherImpl: LinkPreviewFetcher {
let sessionConfig = URLSessionConfiguration.ephemeral
sessionConfig.urlCache = nil
sessionConfig.requestCachePolicy = .reloadIgnoringLocalCacheData
sessionConfig.multipathServiceType = .handover

// Twitter doesn't return OpenGraph tags to Signal
// `curl -A Signal "https://twitter.com/signalapp/status/1280166087577997312?s=20"`
Expand Down
1 change: 1 addition & 0 deletions SignalUI/Payments/MobileCoinAPI+Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ final class MobileCoinHttpRequester: NSObject, HttpRequester {
let config = URLSessionConfiguration.default
config.timeoutIntervalForRequest = 30
config.timeoutIntervalForResource = 30
config.multipathServiceType = .handover
return config
}()

Expand Down

0 comments on commit 95642e9

Please sign in to comment.