otherSection

This commit is contained in:
TrueZhuanjia committed 2025-06-10 00:14:08 +08:00
1 parent 1e6a380f99
commit 5a77571d6f
447 files changed
+130926 -118

No files matched your search

-2
View File
@@ -96,7 +96,6 @@ static NSData* p12 = nil;
bio = BIO_new(BIO_s_mem());
i2d_X509_bio(bio, x509);
X509_free(x509);
BUF_MEM* mem;
BIO_get_mem_ptr(bio, &mem);
@@ -223,7 +222,6 @@ static NSData* p12 = nil;
+ (NSData *)getSignatureFromCert:(NSData *)cert {
BIO* bio = BIO_new_mem_buf([cert bytes], (int)[cert length]);
X509* x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL);
BIO_free(bio);
if (!x509) {
Log(LOG_E, @"Unable to parse certificate in memory!");
+9 -19
View File
@@ -4,12 +4,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <openssl/evp.h>
#include <openssl/pem.h>
#include <OpenSSL/provider.h>
#include <OpenSSL/rsa.h>
#include <openssl/rsa.h>
#include <openssl/x509.h>
#include <OpenSSL/rand.h>
#include <openssl/rand.h>
static const int NUM_BITS = 2048;
static const int SERIAL = 0;
@@ -63,30 +61,22 @@ void mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int years) {
}
struct CertKeyPair generateCertKeyPair(void) {
BIO *bio_err;
X509 *x509 = NULL;
EVP_PKEY *pkey = NULL;
PKCS12 *p12 = NULL;
bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
mkcert(&x509, &pkey, NUM_BITS, SERIAL, NUM_YEARS);
char* pass = "limelight";
p12 = PKCS12_create(pass,
"GameStream",
pkey,
x509,
NULL,
NID_pbe_WithSHA1And3_Key_TripleDES_CBC,
-1, // disable certificate encryption
2048,
-1, // disable the automatic MAC
0);
// MAC it ourselves with SHA1 since iOS refuses to load anything else.
PKCS12_set_mac(p12, pass, -1, NULL, 0, 1, EVP_sha1());
p12 = PKCS12_create("limelight", "GameStream", pkey, x509, NULL, 0, 0, 0, 0, 0);
if (p12 == NULL) {
printf("Error generating a valid PKCS12 certificate.\n");
}
BIO_free(bio_err);
return (CertKeyPair){x509, pkey, p12};
}
+30 -25
View File
@@ -23,14 +23,20 @@
#define EXTRA_LONG_TIMEOUT_SEC 180
@implementation HttpManager {
NSURLSession* _urlSession;
NSString* _urlSafeHostName;
NSString* _baseHTTPURL;
NSString* _uniqueId;
NSString* _deviceName;
NSData* _serverCert;
NSMutableData* _respData;
NSData* _requestResp;
dispatch_semaphore_t _requestLock;
TemporaryHost *_host; // May be nil
NSString* _baseHTTPSURL;
NSError* _error;
}
+ (NSData*) fixXmlVersion:(NSData*) xmlData {
@@ -57,6 +63,10 @@
_uniqueId = @"0123456789ABCDEF";
_deviceName = deviceName;
_serverCert = serverCert;
_requestLock = dispatch_semaphore_create(0);
_respData = [[NSMutableData alloc] init];
NSURLSessionConfiguration* config = [NSURLSessionConfiguration ephemeralSessionConfiguration];
_urlSession = [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:nil];
NSString* address = [Utils addressPortStringToAddress:hostAddressPortString];
unsigned short port = [Utils addressPortStringToPort:hostAddressPortString];
@@ -115,40 +125,37 @@
return;
}
__block NSData* requestResp = nil;
__block NSError* respError = nil;
__block dispatch_semaphore_t requestLock = dispatch_semaphore_create(0);
[_respData setLength:0];
_error = nil;
Log(LOG_D, @"Making Request: %@", request);
NSURLSession* urlSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration ephemeralSessionConfiguration] delegate:self delegateQueue:nil];
[[urlSession dataTaskWithRequest:request.request completionHandler:^(NSData * __nullable data, NSURLResponse * __nullable response, NSError * __nullable error) {
[[_urlSession dataTaskWithRequest:request.request completionHandler:^(NSData * __nullable data, NSURLResponse * __nullable response, NSError * __nullable error) {
if (error != NULL) {
Log(LOG_D, @"Connection error: %@", error);
respError = error;
self->_error = error;
}
else {
Log(LOG_D, @"Received response: %@", response);
if (data != NULL) {
Log(LOG_D, @"\n\nReceived data: %@\n\n", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
if ([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] != nil) {
requestResp = [HttpManager fixXmlVersion:data];
[self->_respData appendData:data];
if ([[NSString alloc] initWithData:self->_respData encoding:NSUTF8StringEncoding] != nil) {
self->_requestResp = [HttpManager fixXmlVersion:self->_respData];
} else {
requestResp = data;
self->_requestResp = self->_respData;
}
}
}
dispatch_semaphore_signal(requestLock);
dispatch_semaphore_signal(self->_requestLock);
}] resume];
dispatch_semaphore_wait(_requestLock, DISPATCH_TIME_FOREVER);
dispatch_semaphore_wait(requestLock, DISPATCH_TIME_FOREVER);
[urlSession invalidateAndCancel];
if (!respError && request.response) {
[request.response populateWithData:requestResp];
if (!_error && request.response) {
[request.response populateWithData:_requestResp];
// If the fallback error code was detected, issue the fallback request
if (request.response.statusCode == request.fallbackError && request.fallbackRequest != NULL) {
@@ -159,7 +166,7 @@
[self executeRequestSynchronously:request];
}
}
else if (respError && [respError code] == NSURLErrorServerCertificateUntrusted) {
else if (_error && [_error code] == NSURLErrorServerCertificateUntrusted) {
// We must have a pinned cert for HTTPS. If we fail, it must be due to
// a non-matching cert, not because we had no cert at all.
assert(_serverCert != nil);
@@ -174,9 +181,9 @@
[self executeRequestSynchronously:request];
}
}
else if (respError && request.response) {
request.response.statusCode = [respError code];
request.response.statusMessage = [respError localizedDescription];
else if (_error && request.response) {
request.response.statusCode = [_error code];
request.response.statusMessage = [_error localizedDescription];
}
}
@@ -319,7 +326,7 @@
SecIdentityCopyCertificate(identity, &certificate);
return [[NSArray alloc] initWithObjects:(__bridge_transfer id)certificate, nil];
return [[NSArray alloc] initWithObjects:(__bridge id)certificate, nil];
}
// Returns the identity
@@ -331,14 +338,13 @@
const void *keys[] = { kSecImportExportPassphrase };
const void *values[] = { password };
CFDictionaryRef options = CFDictionaryCreate(NULL, keys, values, 1, NULL, NULL);
CFArrayRef items = nil;
CFArrayRef items = CFArrayCreate(NULL, 0, 0, NULL);
OSStatus securityError = SecPKCS12Import(p12Data, options, &items);
if (securityError == errSecSuccess) {
//Log(LOG_D, @"Success opening p12 certificate. Items: %ld", CFArrayGetCount(items));
CFDictionaryRef identityDict = CFArrayGetValueAtIndex(items, 0);
identityApp = (SecIdentityRef)CFRetain(CFDictionaryGetValue(identityDict, kSecImportItemIdentity));
CFRelease(items);
identityApp = (SecIdentityRef)CFDictionaryGetValue(identityDict, kSecImportItemIdentity);
} else {
Log(LOG_E, @"Error opening Certificate.");
}
@@ -392,7 +398,6 @@
SecIdentityRef identity = [self getClientCertificate];
NSArray* certArray = [self getCertificate:identity];
NSURLCredential* newCredential = [NSURLCredential credentialWithIdentity:identity certificates:certArray persistence:NSURLCredentialPersistencePermanent];
CFRelease(identity);
completionHandler(NSURLSessionAuthChallengeUseCredential, newCredential);
}
else
-3
View File
@@ -254,9 +254,6 @@ int ArInit(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, v
// Start playback
SDL_PauseAudioDevice(audioDevice, 0);
// Disable lowering volume of other audio streams (SDL sets AVAudioSessionCategoryOptionDuckOthers by default)
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];
return 0;
}
@@ -403,6 +403,7 @@ BOOL isCustomResolution(CGSize res) {
- (void)layoutSections{
MenuSectionView *videoSection = [[MenuSectionView alloc] init];
videoSection.sectionTitle = [LocalizationHelper localizedStringForKey:@"Video"];
if (@available(iOS 13.0, *)) {
@@ -413,6 +414,7 @@ BOOL isCustomResolution(CGSize res) {
[self addSetting:self.bitrateStack ofId:@"bitrateStack" withInfoTag:NO to:videoSection];
[self addSetting:self.codecStack ofId:@"codecStack" withInfoTag:NO to:videoSection];
[self addSetting:self.HdrStack ofId:@"HdrStack" withInfoTag:NO to:videoSection];
[self addSetting:self.yuv444Stack ofId:@"yuv444Stack" withInfoTag:NO to:videoSection];
[self addSetting:self.framepacingStack ofId:@"framepacingStack" withInfoTag:NO to:videoSection];
[videoSection addToParentStack:parentStack];
[videoSection setExpanded:NO];
@@ -462,6 +464,19 @@ BOOL isCustomResolution(CGSize res) {
[peripheralSection setExpanded:NO];
MenuSectionView *otherSection = [[MenuSectionView alloc] init];
otherSection.sectionTitle = [LocalizationHelper localizedStringForKey:@"Others"];
if (@available(iOS 13.0, *)) {
[otherSection setSectionWithIcon:[UIImage systemImageNamed:@"cube"] andSize:20.5];
}
[self addSetting:self.statsOverlayStack ofId:@"statsOverlayStack" withInfoTag:NO to:otherSection];
[self addSetting:self.optimizeSettingsStack ofId:@"optimizeSettingsStack" withInfoTag:YES to:otherSection];
[self addSetting:self.audioOnPcStack ofId:@"audioOnPcStack" withInfoTag:NO to:otherSection];
[self addSetting:self.multiControllerStack ofId:@"multiControllerStack" withInfoTag:YES to:otherSection];
[self addSetting:self.showKeyboardToolbarStack ofId:@"showKeyboardToolbarStack" withInfoTag:YES to:otherSection];
[self addSetting:self.unlockDisplayOrientationStack ofId:@"unlockDisplayOrientationStack" withInfoTag:YES to:otherSection];
[otherSection addToParentStack:parentStack];
[otherSection setExpanded:NO];
MenuSectionView *experimentalSection = [[MenuSectionView alloc] init];