network chunk v20
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import {JsonManager} from "./json_manager";
|
||||
import {UdpClient} from "../network/udp/udp_client";
|
||||
import {parentPort} from "worker_threads";
|
||||
import {TcpCommunicator} from "./tcp_communicator";
|
||||
import {operationCodes} from "../network/operation_codes";
|
||||
import {ParsedMessage} from "../network/message_handler";
|
||||
@@ -55,7 +54,7 @@ export class NetworkScanner {
|
||||
try {
|
||||
this.log('UC Check running...', 'log', 'startUCCheck');
|
||||
const udpClient = new UdpClient(this.udpPort);
|
||||
const aliveClients = await udpClient.getAliveClients();
|
||||
const aliveClients = await udpClient.getTargetClients(operationCodes.ARE_YOU_UC);
|
||||
const storedIp = await this.applicationInfo.readValue('serverIp');
|
||||
const foundClient = aliveClients.length > 0;
|
||||
|
||||
@@ -65,19 +64,19 @@ export class NetworkScanner {
|
||||
if (!storedIp || storedIp !== ipAddress) {
|
||||
await this.applicationInfo.writeValue('serverIp', ipAddress);
|
||||
if (!this.appStarted) {
|
||||
parentPort?.postMessage({ type: 'changeContent', page: this.okPage });
|
||||
process.send?.({ type: 'changeContent', page: this.okPage });
|
||||
}
|
||||
this.appStarted = true;
|
||||
} else if (!this.appStarted) {
|
||||
parentPort?.postMessage({ type: 'changeContent', page: this.okPage });
|
||||
process.send?.({ type: 'changeContent', page: this.okPage });
|
||||
this.appStarted = true;
|
||||
}
|
||||
} else {
|
||||
parentPort?.postMessage({ type: 'changeContent', page: this.errorPage });
|
||||
process.send?.({ type: 'changeContent', page: this.errorPage });
|
||||
}
|
||||
} catch (err) {
|
||||
this.log(`Error checking UC: ${err}`, 'error', 'startUCCheck');
|
||||
parentPort?.postMessage({ type: 'changeContent', page: this.errorPage });
|
||||
process.send?.({ type: 'changeContent', page: this.errorPage });
|
||||
} finally {
|
||||
this.ucCheckBusy = false;
|
||||
}
|
||||
@@ -96,7 +95,7 @@ export class NetworkScanner {
|
||||
this.log('IP Lookup running...', 'log', 'startUserIPLookup');
|
||||
const serverIp = await this.applicationInfo.readValue('serverIp');
|
||||
const udpClient = new UdpClient(this.udpPort);
|
||||
const activeIPs = await udpClient.getAliveClients();
|
||||
const activeIPs = await udpClient.getTargetClients(operationCodes.ARE_YOU_HUMAN);
|
||||
const filteredIPs = activeIPs.filter(ip => ip !== serverIp);
|
||||
|
||||
// Save the filtered IPs to 'users_ip'
|
||||
@@ -152,7 +151,7 @@ export class NetworkScanner {
|
||||
if (response?.operationCode !== operationCodes.OK) {
|
||||
await this.userConfig.resetFile();
|
||||
await this.userConfig.writeValue('app_type', app_type);
|
||||
parentPort?.postMessage({ type: 'changeContent', page: this.databaseResetPage });
|
||||
process.send?.({ type: 'changeContent', page: this.databaseResetPage });
|
||||
}
|
||||
} catch (err) {
|
||||
this.log(`Error during login request: ${err}`, 'error', 'sendLoginRequest');
|
||||
|
||||
Reference in New Issue
Block a user