detector/ts/detectpr.classes.detector.ts

23 lines
918 B
TypeScript
Raw Normal View History

2021-04-13 08:30:33 +00:00
import * as plugins from './detector.plugins';
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);
if (parsedUrl.host === 'localhost') {
console.log(`detector target is localhost on port ${parsedUrl.port}`);
const result = await this.smartnetworkInstance.isLocalPortAvailable(parseInt(parsedUrl.port, 10));
return result;
} else {
console.log(`detector target is remote domain ${parsedUrl.host} on port ${parsedUrl.port}`);
const result = await this.smartnetworkInstance.isRemotePortAvailable(parsedUrl.host, parseInt(parsedUrl.port, 10));
return result;
}
}
public detectType(urlArg: string) {
console.log('TODO'); // TODO
}
}