mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-12-30 05:28:15 +03:00
Actually fixed Domain.getInfo()
work in some specific cases
This commit is contained in:
parent
8497c9d13b
commit
4f300f48f8
1 changed files with 21 additions and 40 deletions
|
@ -3,6 +3,8 @@ import type { DomainInfo } from '../types/Domain';
|
|||
import Process from '../neutralino/Process';
|
||||
import { DebugThread } from './Debug';
|
||||
|
||||
declare const Neutralino;
|
||||
|
||||
export default class Domain
|
||||
{
|
||||
public static getInfo(uri: string): Promise<DomainInfo>
|
||||
|
@ -10,27 +12,15 @@ export default class Domain
|
|||
const debugThread = new DebugThread('Domain.getInfo', `Getting info about uri: ${uri}`);
|
||||
|
||||
return new Promise(async (resolve) => {
|
||||
const process = await Process.run(`ping -n -4 -w 1 -B "${Process.addSlashes(uri)}"`);
|
||||
|
||||
// If something will be wrong - at least we'll have
|
||||
// to wait 1.5 seconds instread of 2
|
||||
process.runningInterval = 500;
|
||||
process.outputInterval = 500;
|
||||
const process = await Neutralino.os.execCommand(`ping -n -4 -w 1 -B "${Process.addSlashes(uri)}"`);
|
||||
const output = process.stdOut || process.stdErr;
|
||||
|
||||
const resolveInfo = (info: DomainInfo) => {
|
||||
process.outputInterval = null;
|
||||
process.runningInterval = null;
|
||||
|
||||
process.kill();
|
||||
|
||||
debugThread.log({ message: info });
|
||||
|
||||
resolve(info);
|
||||
};
|
||||
|
||||
let output = '';
|
||||
|
||||
const processOutput = () => {
|
||||
if (output.includes('Name or service not known'))
|
||||
{
|
||||
resolveInfo({
|
||||
|
@ -53,15 +43,6 @@ export default class Domain
|
|||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
process.output((outputPart) => {
|
||||
output += outputPart;
|
||||
|
||||
processOutput();
|
||||
});
|
||||
|
||||
process.finish(() => processOutput());
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue