增加防抓包hook,登录mqtt,退出登录时不传token
This commit is contained in:
17
QXLive/Base/NSURLSession+QX.h
Normal file
17
QXLive/Base/NSURLSession+QX.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// NSURLSession+BJX.h
|
||||
// BJXGame
|
||||
//
|
||||
// Created by apple on 2022/11/7.
|
||||
// Copyright © 2022 鑫创. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NSURLSession (QX)
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
37
QXLive/Base/NSURLSession+QX.m
Normal file
37
QXLive/Base/NSURLSession+QX.m
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// NSURLSession+BJX.m
|
||||
// BJXGame
|
||||
//
|
||||
// Created by apple on 2022/11/7.
|
||||
// Copyright © 2022 鑫创. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSURLSession+QX.h"
|
||||
#import <objc/runtime.h>
|
||||
|
||||
@implementation NSURLSession (QX)
|
||||
+ (void)load{
|
||||
Method method1 = class_getClassMethod([NSURLSession class],@selector(sessionWithConfiguration:));
|
||||
Method method2 = class_getClassMethod([NSURLSession class],@selector(px_sessionWithConfiguration:));
|
||||
method_exchangeImplementations(method1, method2);
|
||||
|
||||
Method method3 =class_getClassMethod([NSURLSession class],@selector(sessionWithConfiguration:delegate:delegateQueue:));
|
||||
Method method4 =class_getClassMethod([NSURLSession class],@selector(px_sessionWithConfiguration:delegate:delegateQueue:));
|
||||
method_exchangeImplementations(method3, method4);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+ (NSURLSession*)px_sessionWithConfiguration:(NSURLSessionConfiguration*)configuration delegate:(nullable id)delegate delegateQueue:(nullable NSOperationQueue*)queue{
|
||||
if(configuration) configuration.connectionProxyDictionary=@{};
|
||||
return [self px_sessionWithConfiguration:configuration delegate:delegate delegateQueue:queue];
|
||||
}
|
||||
|
||||
|
||||
|
||||
+ (NSURLSession*)px_sessionWithConfiguration:(NSURLSessionConfiguration*)configuration{
|
||||
if(configuration) configuration.connectionProxyDictionary=@{};
|
||||
return [self px_sessionWithConfiguration:configuration];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -19,6 +19,7 @@
|
||||
#import "QXRoomMessageManager.h"
|
||||
#import "QXTimer.h"
|
||||
#import <TIMPush/TIMPushManager.h>
|
||||
#import "QXManagerMqtt.h"
|
||||
|
||||
@interface QXGlobal()
|
||||
@property (nonatomic,assign)BOOL isLogin;
|
||||
@@ -52,7 +53,9 @@
|
||||
[self removeLocalData];
|
||||
[self removeMemory];
|
||||
AppDelegate *appdelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
|
||||
/// 移除推送监听
|
||||
[TIMPushManager removePushListener:appdelegate];
|
||||
/// 移除会话监听
|
||||
[[V2TIMManager sharedInstance] removeConversationListener:appdelegate];
|
||||
[TIMPushManager unRegisterPush:^{
|
||||
//success
|
||||
@@ -68,6 +71,8 @@
|
||||
na.modalPresentationStyle = UIModalPresentationFullScreen;
|
||||
[self.getKeyWindow.rootViewController presentViewController:na animated:YES completion:nil];
|
||||
self.isShowLoginVC = YES;
|
||||
/// 断开mqtt连接
|
||||
[[QXManagerMqtt sharedInstance] disconnect];
|
||||
|
||||
}
|
||||
-(void)saveLoginData:(NSString *)userInfoJson{
|
||||
@@ -114,7 +119,7 @@
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
-(void)removeMemory{
|
||||
self.loginModel = nil;
|
||||
QXGlobal.shareGlobal.loginModel = nil;
|
||||
}
|
||||
-(void)showView:(UIView *)view popType:(PopViewType)popType tapDismiss:(BOOL)tapDismiss finishBlock:(showFinishBlock)finishBlock{
|
||||
self.alertViewController = [[QXAlertViewController alloc] init];
|
||||
|
||||
17
QXLive/Base/WKWebView+QX.h
Normal file
17
QXLive/Base/WKWebView+QX.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// WKWebView+QX.h
|
||||
// YBLive
|
||||
//
|
||||
// Created by 启星 on 2025/4/16.
|
||||
// Copyright © 2025 cat. All rights reserved.
|
||||
//
|
||||
|
||||
#import <WebKit/WebKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface WKWebView (QX)
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
50
QXLive/Base/WKWebView+QX.m
Normal file
50
QXLive/Base/WKWebView+QX.m
Normal file
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// WKWebView+QX.m
|
||||
// YBLive
|
||||
//
|
||||
// Created by 启星 on 2025/4/16.
|
||||
// Copyright © 2025 cat. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WKWebView+QX.h"
|
||||
|
||||
@implementation WKWebView (QX)
|
||||
+ (void)load{
|
||||
Method method1 = class_getInstanceMethod([self class],@selector(loadRequest:));
|
||||
Method method2 = class_getInstanceMethod([self class],@selector(qx_loadRequest:));
|
||||
method_exchangeImplementations(method1, method2);
|
||||
|
||||
}
|
||||
-(void)qx_loadRequest:(NSURLRequest*)request{
|
||||
if ([self isProxyEnabled]) {
|
||||
[self qx_loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https:www.baidu.com"]]];
|
||||
}else{
|
||||
[self qx_loadRequest:request];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
-(BOOL)isProxyEnabled{
|
||||
NSArray *criticalDomains = @[
|
||||
H5ServerUrl,
|
||||
ServerUrl,
|
||||
];
|
||||
NSDictionary *proxySettings = (__bridge NSDictionary *)CFNetworkCopySystemProxySettings();
|
||||
for (NSString *domain in criticalDomains) {
|
||||
NSArray *proxies = (__bridge NSArray *)CFNetworkCopyProxiesForURL(
|
||||
(__bridge CFURLRef)[NSURL URLWithString:domain],
|
||||
(__bridge CFDictionaryRef)proxySettings
|
||||
);
|
||||
// 检查每个域名的代理情况...
|
||||
for (NSDictionary *proxy in proxies) {
|
||||
NSString *proxyType = proxy[(NSString *)kCFProxyTypeKey];
|
||||
if (![proxyType isEqualToString:(NSString *)kCFProxyTypeNone]) {
|
||||
return YES; // 存在代理或 VPN
|
||||
}
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user