ios12-nt
This commit is contained in:
parent
1acdf1a070
commit
cf5c505621
@ -6,5 +6,5 @@ Author: XYZShell
|
||||
Section: Utilities
|
||||
Tag: role::developer
|
||||
Architecture: iphoneos-arm
|
||||
Version: 0.0.7-10-53+debug
|
||||
Version: 0.0.7-10-59+debug
|
||||
Installed-Size: 1600
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
./packages/com.xyzshell.ioscontrol_0.0.7-10-53+debug_iphoneos-arm.deb
|
||||
./packages/com.xyzshell.ioscontrol_0.0.7-10-59+debug_iphoneos-arm.deb
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
53
|
||||
59
|
||||
@ -30,7 +30,6 @@
|
||||
|
||||
@property (nonatomic, assign) NSTimeInterval lastTouchTime;
|
||||
@property (nonatomic, assign) BOOL isProcessingTouch;
|
||||
@property (nonatomic, strong) dispatch_queue_t touchQueue;
|
||||
@property (nonatomic, assign) NSTimeInterval lastCheckTaskTime;
|
||||
@property (nonatomic, strong) dispatch_source_t touchTimer;
|
||||
|
||||
@ -80,6 +79,7 @@
|
||||
if (_timer) return;
|
||||
|
||||
_workQueue = dispatch_queue_create("com.iphone.heartbeat.queue", DISPATCH_QUEUE_SERIAL);
|
||||
|
||||
_timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, _workQueue);
|
||||
dispatch_source_set_timer(_timer, dispatch_time(DISPATCH_TIME_NOW, 0), 5 * NSEC_PER_SEC, 0.1 * NSEC_PER_SEC);
|
||||
|
||||
@ -146,7 +146,7 @@
|
||||
NSTimeInterval elapsed = [curRunTime timeIntervalSinceDate:self->lastStop];
|
||||
if (elapsed > 60 * 10 && !myadTaskManualStop) {
|
||||
self->lastStop = [NSDate date];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
dispatch_async(_workQueue, ^{
|
||||
[[MyAdTask2Mangger sharedInstance] start];
|
||||
});
|
||||
}
|
||||
@ -157,7 +157,7 @@
|
||||
self.ip = [[XSPhoneInfo sharedInstance] IPAddress];
|
||||
self.remoteIp = [[XSPhoneInfo sharedInstance] remoteIp];
|
||||
self.diskSize = [[XSPhoneInfo sharedInstance] IPhoneStatus];
|
||||
self.message = @"251030-nt";
|
||||
self.message = @"251103-nt";
|
||||
// 构建请求数据
|
||||
NSDictionary *heartbeatData = [self constructHeartbeatData];
|
||||
if (!heartbeatData) {
|
||||
@ -242,7 +242,7 @@
|
||||
self.lastCheckTaskTime = currentTime;
|
||||
__weak typeof(self) weakSelf = self;
|
||||
// 使用专门的触摸队列
|
||||
dispatch_async(self.touchQueue, ^{
|
||||
dispatch_async(_workQueue, ^{
|
||||
@try {
|
||||
[weakSelf safePerformTouchEvents];
|
||||
} @catch (NSException *exception) {
|
||||
|
||||
@ -38,6 +38,7 @@ BOOL myadTaskManualStop = NO;
|
||||
NSString *dataId;
|
||||
NSString *remoteIp;
|
||||
NSString *country;
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -15,7 +15,11 @@
|
||||
#define PORT 6001
|
||||
|
||||
@interface XUDPServer() {
|
||||
@private GCDAsyncUdpSocket *serverSocket;
|
||||
@private
|
||||
GCDAsyncUdpSocket *serverSocket;
|
||||
dispatch_queue_t serverQueue; // 专用队列
|
||||
dispatch_source_t restartTimer; // 重用的定时器
|
||||
NSUInteger restartAttempts;
|
||||
}
|
||||
|
||||
@end
|
||||
@ -34,12 +38,22 @@
|
||||
|
||||
-(instancetype)init {
|
||||
if (self = [super init]) {
|
||||
restartAttempts = 0;
|
||||
// 创建串行队列,避免并发问题
|
||||
serverQueue = dispatch_queue_create("com.xudpserver.queue", DISPATCH_QUEUE_SERIAL);
|
||||
return self;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void) start {
|
||||
- (void)start {
|
||||
// 使用专用队列,确保操作串行化
|
||||
dispatch_async(serverQueue, ^{
|
||||
[self _startInternal];
|
||||
});
|
||||
}
|
||||
|
||||
- (void) _startInternal {
|
||||
NSLog(@"XS- start udp server");
|
||||
// 避免重复创建
|
||||
if (serverSocket && !serverSocket.isClosed) {
|
||||
@ -47,35 +61,107 @@
|
||||
return;
|
||||
}
|
||||
|
||||
[self stop]; // 清理旧资源
|
||||
|
||||
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
||||
serverSocket=[[GCDAsyncUdpSocket alloc]initWithDelegate:self delegateQueue:queue];
|
||||
[self _stopInternal];
|
||||
|
||||
serverSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self
|
||||
delegateQueue:serverQueue];
|
||||
|
||||
NSError *error = nil;
|
||||
if (![serverSocket bindToPort:PORT error:&error])
|
||||
{
|
||||
NSLog(@"Error starting server (bind): %@", error);
|
||||
[self scheduleRestart];
|
||||
if (![serverSocket bindToPort:PORT error:&error]) {
|
||||
NSLog(@"❌ Error binding to port %d: %@", PORT, error);
|
||||
|
||||
if (error.code == 48) {
|
||||
[self _tryFallbackPorts];
|
||||
return;
|
||||
}
|
||||
|
||||
[self _scheduleRestartWithBackoff];
|
||||
return;
|
||||
}
|
||||
if (![serverSocket beginReceiving:&error])
|
||||
{
|
||||
NSLog(@"Error starting server (recv): %@", error);
|
||||
[self scheduleRestart];
|
||||
|
||||
if (![serverSocket beginReceiving:&error]) {
|
||||
NSLog(@"❌ Error starting server (recv): %@", error);
|
||||
[self _scheduleRestartWithBackoff];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
restartAttempts = 0; // 重置重试计数
|
||||
NSLog(@"✅ UDP server started successfully on port %d", PORT);
|
||||
|
||||
}
|
||||
|
||||
- (void)stop {
|
||||
dispatch_async(serverQueue, ^{
|
||||
[self _stopInternal];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)_stopInternal {
|
||||
// 取消待处理的重启定时器
|
||||
[self _cancelRestartTimer];
|
||||
|
||||
if (serverSocket) {
|
||||
NSLog(@"Stopping UDP server on port %d", PORT);
|
||||
[serverSocket close];
|
||||
serverSocket = nil;
|
||||
}
|
||||
}
|
||||
#pragma mark - Restart Logic with Backoff
|
||||
|
||||
- (void)_cancelRestartTimer {
|
||||
if (restartTimer) {
|
||||
dispatch_source_cancel(restartTimer);
|
||||
restartTimer = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_scheduleRestartWithBackoff {
|
||||
// 取消之前的定时器
|
||||
[self _cancelRestartTimer];
|
||||
|
||||
// 限制重试次数
|
||||
const NSUInteger maxAttempts = 10;
|
||||
if (restartAttempts >= maxAttempts) {
|
||||
NSLog(@"❌ Maximum restart attempts (%lu) reached, giving up",
|
||||
(unsigned long)maxAttempts);
|
||||
return;
|
||||
}
|
||||
|
||||
restartAttempts++;
|
||||
|
||||
// 指数退避:1s, 2s, 4s, 8s, 16s, 最大60s
|
||||
NSTimeInterval delay = MIN(pow(2, restartAttempts - 1), 60.0);
|
||||
|
||||
NSLog(@"⏰ Scheduling restart attempt %lu in %.1f seconds",
|
||||
(unsigned long)restartAttempts, delay);
|
||||
|
||||
// 使用 dispatch_source 创建可取消的定时器
|
||||
restartTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, serverQueue);
|
||||
|
||||
dispatch_source_set_timer(restartTimer,
|
||||
dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC),
|
||||
DISPATCH_TIME_FOREVER,
|
||||
0.1 * NSEC_PER_SEC);
|
||||
|
||||
dispatch_source_set_event_handler(restartTimer, ^{
|
||||
[self _startInternal];
|
||||
});
|
||||
|
||||
dispatch_resume(restartTimer);
|
||||
}
|
||||
|
||||
- (void)_tryFallbackPorts {
|
||||
|
||||
|
||||
NSLog(@"❌ No available ports found");
|
||||
[self _scheduleRestartWithBackoff];
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (void)scheduleRestart {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0 * NSEC_PER_SEC)),
|
||||
dispatch_get_main_queue(), ^{
|
||||
serverQueue, ^{
|
||||
[self start];
|
||||
});
|
||||
}
|
||||
@ -136,5 +222,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[self _cancelRestartTimer];
|
||||
[self _stopInternal];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
19
ips.txt
19
ips.txt
@ -1 +1,18 @@
|
||||
192.168.31.254
|
||||
172.29.103.16
|
||||
172.29.103.19
|
||||
172.29.103.18
|
||||
172.29.103.15
|
||||
172.30.8.102
|
||||
172.29.103.14
|
||||
172.29.103.13
|
||||
172.29.103.28
|
||||
172.29.103.24
|
||||
172.29.103.31
|
||||
172.29.103.17
|
||||
172.29.103.20
|
||||
172.29.103.12
|
||||
172.29.103.21
|
||||
172.29.103.30
|
||||
172.29.103.26
|
||||
172.29.103.25
|
||||
172.29.103.23
|
||||
|
||||
BIN
packages/251103-nt.deb
Normal file
BIN
packages/251103-nt.deb
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user