This commit is contained in:
xsean 2025-11-04 10:06:44 +08:00
parent 1acdf1a070
commit cf5c505621
23 changed files with 1954 additions and 1832 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -6,5 +6,5 @@ Author: XYZShell
Section: Utilities Section: Utilities
Tag: role::developer Tag: role::developer
Architecture: iphoneos-arm Architecture: iphoneos-arm
Version: 0.0.7-10-53+debug Version: 0.0.7-10-59+debug
Installed-Size: 1600 Installed-Size: 1600

View File

@ -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.

View File

@ -1 +1 @@
53 59

View File

@ -30,7 +30,6 @@
@property (nonatomic, assign) NSTimeInterval lastTouchTime; @property (nonatomic, assign) NSTimeInterval lastTouchTime;
@property (nonatomic, assign) BOOL isProcessingTouch; @property (nonatomic, assign) BOOL isProcessingTouch;
@property (nonatomic, strong) dispatch_queue_t touchQueue;
@property (nonatomic, assign) NSTimeInterval lastCheckTaskTime; @property (nonatomic, assign) NSTimeInterval lastCheckTaskTime;
@property (nonatomic, strong) dispatch_source_t touchTimer; @property (nonatomic, strong) dispatch_source_t touchTimer;
@ -80,6 +79,7 @@
if (_timer) return; if (_timer) return;
_workQueue = dispatch_queue_create("com.iphone.heartbeat.queue", DISPATCH_QUEUE_SERIAL); _workQueue = dispatch_queue_create("com.iphone.heartbeat.queue", DISPATCH_QUEUE_SERIAL);
_timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, _workQueue); _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); 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]; NSTimeInterval elapsed = [curRunTime timeIntervalSinceDate:self->lastStop];
if (elapsed > 60 * 10 && !myadTaskManualStop) { if (elapsed > 60 * 10 && !myadTaskManualStop) {
self->lastStop = [NSDate date]; self->lastStop = [NSDate date];
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(_workQueue, ^{
[[MyAdTask2Mangger sharedInstance] start]; [[MyAdTask2Mangger sharedInstance] start];
}); });
} }
@ -157,7 +157,7 @@
self.ip = [[XSPhoneInfo sharedInstance] IPAddress]; self.ip = [[XSPhoneInfo sharedInstance] IPAddress];
self.remoteIp = [[XSPhoneInfo sharedInstance] remoteIp]; self.remoteIp = [[XSPhoneInfo sharedInstance] remoteIp];
self.diskSize = [[XSPhoneInfo sharedInstance] IPhoneStatus]; self.diskSize = [[XSPhoneInfo sharedInstance] IPhoneStatus];
self.message = @"251030-nt"; self.message = @"251103-nt";
// //
NSDictionary *heartbeatData = [self constructHeartbeatData]; NSDictionary *heartbeatData = [self constructHeartbeatData];
if (!heartbeatData) { if (!heartbeatData) {
@ -242,7 +242,7 @@
self.lastCheckTaskTime = currentTime; self.lastCheckTaskTime = currentTime;
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
// 使 // 使
dispatch_async(self.touchQueue, ^{ dispatch_async(_workQueue, ^{
@try { @try {
[weakSelf safePerformTouchEvents]; [weakSelf safePerformTouchEvents];
} @catch (NSException *exception) { } @catch (NSException *exception) {

View File

@ -38,6 +38,7 @@ BOOL myadTaskManualStop = NO;
NSString *dataId; NSString *dataId;
NSString *remoteIp; NSString *remoteIp;
NSString *country; NSString *country;
} }
@end @end

View File

@ -15,7 +15,11 @@
#define PORT 6001 #define PORT 6001
@interface XUDPServer() { @interface XUDPServer() {
@private GCDAsyncUdpSocket *serverSocket; @private
GCDAsyncUdpSocket *serverSocket;
dispatch_queue_t serverQueue; //
dispatch_source_t restartTimer; //
NSUInteger restartAttempts;
} }
@end @end
@ -34,12 +38,22 @@
-(instancetype)init { -(instancetype)init {
if (self = [super init]) { if (self = [super init]) {
restartAttempts = 0;
//
serverQueue = dispatch_queue_create("com.xudpserver.queue", DISPATCH_QUEUE_SERIAL);
return self; return self;
} }
return nil; return nil;
} }
- (void) start { - (void)start {
// 使
dispatch_async(serverQueue, ^{
[self _startInternal];
});
}
- (void) _startInternal {
NSLog(@"XS- start udp server"); NSLog(@"XS- start udp server");
// //
if (serverSocket && !serverSocket.isClosed) { if (serverSocket && !serverSocket.isClosed) {
@ -47,35 +61,107 @@
return; return;
} }
[self stop]; // [self _stopInternal];
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); serverSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self
serverSocket=[[GCDAsyncUdpSocket alloc]initWithDelegate:self delegateQueue:queue]; delegateQueue:serverQueue];
NSError *error = nil; NSError *error = nil;
if (![serverSocket bindToPort:PORT error:&error]) if (![serverSocket bindToPort:PORT error:&error]) {
{ NSLog(@"❌ Error binding to port %d: %@", PORT, error);
NSLog(@"Error starting server (bind): %@", error);
[self scheduleRestart]; if (error.code == 48) {
[self _tryFallbackPorts];
return;
}
[self _scheduleRestartWithBackoff];
return; return;
} }
if (![serverSocket beginReceiving:&error])
{ if (![serverSocket beginReceiving:&error]) {
NSLog(@"Error starting server (recv): %@", error); NSLog(@"Error starting server (recv): %@", error);
[self scheduleRestart]; [self _scheduleRestartWithBackoff];
return; return;
} }
restartAttempts = 0; //
NSLog(@"✅ UDP server started successfully on port %d", PORT);
} }
- (void)stop { - (void)stop {
dispatch_async(serverQueue, ^{
[self _stopInternal];
});
}
- (void)_stopInternal {
//
[self _cancelRestartTimer];
if (serverSocket) { if (serverSocket) {
NSLog(@"Stopping UDP server on port %d", PORT);
[serverSocket close]; [serverSocket close];
serverSocket = nil; 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 { - (void)scheduleRestart {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0 * NSEC_PER_SEC)), dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0 * NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{ serverQueue, ^{
[self start]; [self start];
}); });
} }
@ -136,5 +222,9 @@
} }
} }
- (void)dealloc {
[self _cancelRestartTimer];
[self _stopInternal];
}
@end @end

19
ips.txt
View File

@ -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

Binary file not shown.