fix(core): update

This commit is contained in:
2022-07-16 18:15:23 +02:00
parent 4d14526858
commit 830a46ab30
13 changed files with 8468 additions and 10171 deletions

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@uptime.link/detector',
version: '1.0.5',
description: 'a detector for answering network questions locally. It does not rely on any online services.'
}

View File

@ -1,19 +1,23 @@
import * as plugins from './detector.plugins';
import * as plugins from './detector.plugins.js';
export class Detector {
private smartnetworkInstance = new plugins.smartnetwork.SmartNetwork();
private smarturlInstance = new plugins.smarturl.Smarturl();
public async isActive(urlArg: string): Promise<boolean> {
const parsedUrl = this.smarturlInstance.parseUrl(urlArg);
const parsedUrl = plugins.smarturl.Smarturl.createFromUrl(urlArg);
if (parsedUrl.hostname === 'localhost') {
console.log(`detector target is localhost on port ${parsedUrl.port}`);
const portUnused = await this.smartnetworkInstance.isLocalPortUnused(parseInt(parsedUrl.port, 10));
const portUnused = await this.smartnetworkInstance.isLocalPortUnused(
parseInt(parsedUrl.port, 10)
);
const portAvailable = !portUnused;
return portAvailable;
} else {
console.log(`detector target is remote domain ${parsedUrl.host} on port ${parsedUrl.port}`);
const postAvailable = await this.smartnetworkInstance.isRemotePortAvailable(parsedUrl.host, parseInt(parsedUrl.port, 10));
const postAvailable = await this.smartnetworkInstance.isRemotePortAvailable(
parsedUrl.host,
parseInt(parsedUrl.port, 10)
);
return postAvailable;
}
}
@ -21,4 +25,4 @@ export class Detector {
public detectType(urlArg: string) {
console.log('TODO'); // TODO
}
}
}

View File

@ -2,7 +2,4 @@
import * as smartnetwork from '@pushrocks/smartnetwork';
import * as smarturl from '@pushrocks/smarturl';
export {
smartnetwork,
smarturl
};
export { smartnetwork, smarturl };

View File

@ -1 +1 @@
export * from './detectpr.classes.detector';
export * from './detector.classes.detector.js';