fix(core): update
This commit is contained in:
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal 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.'
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,4 @@
|
||||
import * as smartnetwork from '@pushrocks/smartnetwork';
|
||||
import * as smarturl from '@pushrocks/smarturl';
|
||||
|
||||
export {
|
||||
smartnetwork,
|
||||
smarturl
|
||||
};
|
||||
export { smartnetwork, smarturl };
|
||||
|
@ -1 +1 @@
|
||||
export * from './detectpr.classes.detector';
|
||||
export * from './detector.classes.detector.js';
|
||||
|
Reference in New Issue
Block a user