-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Categorize files based on functionalities
- Loading branch information
1 parent
fa4bc70
commit 9057933
Showing
63 changed files
with
229 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// Jittered.swift | ||
// MullvadREST | ||
// | ||
// Created by Mojgan on 2023-12-08. | ||
// Copyright © 2023 Mullvad VPN AB. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import MullvadTypes | ||
|
||
struct Jittered<InnerIterator: IteratorProtocol>: IteratorProtocol | ||
where InnerIterator.Element == Duration { | ||
private var inner: InnerIterator | ||
|
||
init(_ inner: InnerIterator) { | ||
self.inner = inner | ||
} | ||
|
||
mutating func next() -> Duration? { | ||
guard let interval = inner.next() else { return nil } | ||
|
||
let jitter = Double.random(in: 0.0 ... 1.0) | ||
let millis = interval.milliseconds | ||
let millisWithJitter = millis.saturatingAddition(Int(Double(millis) * jitter)) | ||
|
||
return .milliseconds(millisWithJitter) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
ios/MullvadREST/RESTRetryStrategy.swift → ...vadREST/RetryStrategy/RetryStrategy.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// | ||
// RESTRetryStrategy.swift | ||
// RetryStrategy.swift | ||
// MullvadREST | ||
// | ||
// Created by pronebird on 09/12/2021. | ||
|
33 changes: 33 additions & 0 deletions
33
ios/MullvadREST/Transport/Direct/URLSessionTransport.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// URLSessionTransport.swift | ||
// MullvadREST | ||
// | ||
// Created by Mojgan on 2023-12-08. | ||
// Copyright © 2023 Mullvad VPN AB. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import MullvadTypes | ||
|
||
extension URLSessionTask: Cancellable {} | ||
|
||
public final class URLSessionTransport: RESTTransport { | ||
public var name: String { | ||
"url-session" | ||
} | ||
|
||
public let urlSession: URLSession | ||
|
||
public init(urlSession: URLSession) { | ||
self.urlSession = urlSession | ||
} | ||
|
||
public func sendRequest( | ||
_ request: URLRequest, | ||
completion: @escaping (Data?, URLResponse?, Swift.Error?) -> Void | ||
) -> Cancellable { | ||
let dataTask = urlSession.dataTask(with: request, completionHandler: completion) | ||
dataTask.resume() | ||
return dataTask | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
typedef struct ProxyHandle { | ||
void *context; | ||
uint16_t port; | ||
} ProxyHandle; | ||
|
||
/** | ||
* # Safety | ||
* `addr`, `password`, `cipher` must be valid for the lifetime of this function call and they must | ||
* be backed by the amount of bytes as stored in the respective `*_len` parameters. | ||
* | ||
* `proxy_config` must be pointing to a valid memory region for the size of a `ProxyHandle` | ||
* instance. | ||
*/ | ||
int32_t start_shadowsocks_proxy(const uint8_t *forward_address, | ||
uintptr_t forward_address_len, | ||
uint16_t forward_port, | ||
const uint8_t *addr, | ||
uintptr_t addr_len, | ||
uint16_t port, | ||
const uint8_t *password, | ||
uintptr_t password_len, | ||
const uint8_t *cipher, | ||
uintptr_t cipher_len, | ||
struct ProxyHandle *proxy_config); | ||
|
||
/** | ||
* # Safety | ||
* `proxy_config` must be pointing to a valid instance of a `ProxyInstance`, as instantiated by | ||
* `start_shadowsocks_proxy`. | ||
*/ | ||
int32_t stop_shadowsocks_proxy(struct ProxyHandle *proxy_config); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
ios/MullvadREST/RESTTransportStrategy.swift → ...vadREST/Transport/TransportStrategy.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.