mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 22:23:31 +00:00
Fix support for IPv6 literals
This commit is contained in:
@@ -18,7 +18,6 @@
|
|||||||
NSURLSession* _urlSession;
|
NSURLSession* _urlSession;
|
||||||
NSString* _baseHTTPURL;
|
NSString* _baseHTTPURL;
|
||||||
NSString* _baseHTTPSURL;
|
NSString* _baseHTTPSURL;
|
||||||
NSString* _host;
|
|
||||||
NSString* _uniqueId;
|
NSString* _uniqueId;
|
||||||
NSString* _deviceName;
|
NSString* _deviceName;
|
||||||
NSData* _cert;
|
NSData* _cert;
|
||||||
@@ -41,16 +40,25 @@ static const NSString* HTTPS_PORT = @"47984";
|
|||||||
|
|
||||||
- (id) initWithHost:(NSString*) host uniqueId:(NSString*) uniqueId deviceName:(NSString*) deviceName cert:(NSData*) cert {
|
- (id) initWithHost:(NSString*) host uniqueId:(NSString*) uniqueId deviceName:(NSString*) deviceName cert:(NSData*) cert {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
_host = host;
|
|
||||||
_uniqueId = uniqueId;
|
_uniqueId = uniqueId;
|
||||||
_deviceName = deviceName;
|
_deviceName = deviceName;
|
||||||
_cert = cert;
|
_cert = cert;
|
||||||
_baseHTTPURL = [NSString stringWithFormat:@"http://%@:%@", host, HTTP_PORT];
|
|
||||||
_baseHTTPSURL = [NSString stringWithFormat:@"https://%@:%@", host, HTTPS_PORT];
|
|
||||||
_requestLock = dispatch_semaphore_create(0);
|
_requestLock = dispatch_semaphore_create(0);
|
||||||
_respData = [[NSMutableData alloc] init];
|
_respData = [[NSMutableData alloc] init];
|
||||||
NSURLSessionConfiguration* config = [NSURLSessionConfiguration ephemeralSessionConfiguration];
|
NSURLSessionConfiguration* config = [NSURLSessionConfiguration ephemeralSessionConfiguration];
|
||||||
_urlSession = [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:nil];
|
_urlSession = [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:nil];
|
||||||
|
|
||||||
|
// If this is an IPv6 literal, we must properly enclose it in brackets
|
||||||
|
NSString* urlSafeHost;
|
||||||
|
if ([host containsString:@":"]) {
|
||||||
|
urlSafeHost = [NSString stringWithFormat:@"[%@]", host];
|
||||||
|
} else {
|
||||||
|
urlSafeHost = host;
|
||||||
|
}
|
||||||
|
|
||||||
|
_baseHTTPURL = [NSString stringWithFormat:@"http://%@:%@", urlSafeHost, HTTP_PORT];
|
||||||
|
_baseHTTPSURL = [NSString stringWithFormat:@"https://%@:%@", urlSafeHost, HTTPS_PORT];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user