Compare commits

...

10 Commits

Author SHA1 Message Date
d8f409c191 3.0.1 2022-10-21 17:13:06 +02:00
bcfa3be58b fix(core): update 2022-10-21 17:13:06 +02:00
15744d3c4e 3.0.0 2022-03-24 23:11:53 +01:00
8b2f541150 BREAKING CHANGE(core): switch to esm 2022-03-24 23:11:53 +01:00
b52bb4b474 2.0.14 2022-02-17 00:33:12 +01:00
42f5d66fc4 fix(core): update 2022-02-17 00:33:11 +01:00
54bb9549a1 2.0.13 2022-02-17 00:18:23 +01:00
95c3314400 fix(core): update 2022-02-17 00:18:23 +01:00
695d047200 2.0.12 2022-02-17 00:03:13 +01:00
c308589d28 fix(core): update 2022-02-17 00:03:13 +01:00
15 changed files with 4590 additions and 27668 deletions

View File

@ -12,6 +12,9 @@ stages:
- release
- metadata
before_script:
- npm install -g @shipzone/npmci
# ====================
# security stage
# ====================
@ -36,6 +39,7 @@ auditProductionDependencies:
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci

24
.vscode/launch.json vendored
View File

@ -2,28 +2,10 @@
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
"type": "node-terminal"
}
]
}

View File

@ -9,7 +9,7 @@
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartnetwork",
"shortDescription": "network diagnostics",
"description": "network diagnostics",
"npmPackagename": "@pushrocks/smartnetwork",
"license": "MIT"
}

27606
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +1,33 @@
{
"name": "@pushrocks/smartnetwork",
"version": "2.0.11",
"version": "3.0.1",
"private": false,
"description": "network diagnostics",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild --web)"
"build": "(tsbuild --web --allowimplicitany)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.29",
"@gitzone/tstest": "^1.0.64",
"@pushrocks/tapbundle": "^4.0.7",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
"@gitzone/tsbuild": "^2.1.61",
"@gitzone/tsrun": "^1.2.39",
"@gitzone/tstest": "^1.0.69",
"@pushrocks/smartenv": "^5.0.0",
"@pushrocks/tapbundle": "^5.0.3",
"@types/node": "^18.11.3"
},
"dependencies": {
"@pushrocks/smartpromise": "^3.1.6",
"@pushrocks/smartstring": "^3.0.24",
"@pushrocks/smartping": "^1.0.7",
"@pushrocks/smartpromise": "^3.1.7",
"@pushrocks/smartstring": "^4.0.2",
"@types/default-gateway": "^3.0.1",
"isopen": "^1.3.0",
"public-ip": "^4.0.4",
"systeminformation": "^5.11.3"
"public-ip": "^6.0.1",
"systeminformation": "^5.11.9"
},
"files": [
"ts/**/*",

4501
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

25
test/test.ping.ts Normal file
View File

@ -0,0 +1,25 @@
import { tap, expect, expectAsync } from '@pushrocks/tapbundle';
import * as smartnetwork from '../ts/index.js';
let testSmartnetwork: smartnetwork.SmartNetwork;
tap.test('should create a vlid instance of SmartNetwork', async () => {
testSmartnetwork = new smartnetwork.SmartNetwork();
expect(testSmartnetwork).toBeInstanceOf(smartnetwork.SmartNetwork);
});
tap.test('should send a ping to Google', async () => {
console.log(await testSmartnetwork.ping('google.com'));
await expectAsync(testSmartnetwork.ping('google.com')).property('alive').toBeTrue();
});
tap.test('should state when a ping is not alive ', async () => {
await expectAsync(testSmartnetwork.ping('notthere.lossless.com')).property('alive').toBeFalse();
});
tap.test('should send a ping to an IP', async () => {
await expectAsync(testSmartnetwork.ping('192.168.186.999')).property('alive').toBeFalse();
})
tap.start();

View File

@ -1,5 +1,5 @@
import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
import * as smartnetwork from '../ts/index';
import * as smartnetwork from '../ts/index.js';
let testSmartNetwork: smartnetwork.SmartNetwork;

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/smartnetwork',
version: '3.0.1',
description: 'network diagnostics'
}

View File

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

View File

@ -1,5 +1,5 @@
import * as plugins from './smartnetwork.plugins';
import * as stats from './helpers/stats';
import * as plugins from './smartnetwork.plugins.js';
import * as stats from './helpers/stats.js';
export class CloudflareSpeed {
constructor() {}
@ -106,7 +106,7 @@ export class CloudflareSpeed {
public async fetchServerLocations(): Promise<{ [key: string]: string }> {
const res = JSON.parse(await this.get('speed.cloudflare.com', '/locations'));
return res.reduce((data: any, optionsArg: { iata: string, city: string}) => {
return res.reduce((data: any, optionsArg: { iata: string; city: string }) => {
// Bypass prettier "no-assign-param" rules
const data1 = data;
@ -172,7 +172,7 @@ export class CloudflareSpeed {
public async request(options: plugins.https.RequestOptions, data = ''): Promise<number[]> {
let started: number;
let dnsLookup: number;
let tcpHandshake : number;
let tcpHandshake: number;
let sslHandshake: number;
let ttfb: number;
let ended: number;

View File

@ -1,6 +1,6 @@
import * as plugins from './smartnetwork.plugins';
import * as plugins from './smartnetwork.plugins.js';
import { CloudflareSpeed } from './smartnetwork.classes.cloudflarespeed';
import { CloudflareSpeed } from './smartnetwork.classes.cloudflarespeed.js';
/**
* SmartNetwork simplifies actions within the network
@ -16,6 +16,12 @@ export class SmartNetwork {
return test;
}
public async ping(hostArg: string, timeoutArg: number = 500): Promise<ReturnType<typeof plugins.smartping.Smartping.prototype.ping>> {
const smartpingInstance = new plugins.smartping.Smartping();
const pingResult = await smartpingInstance.ping(hostArg, timeoutArg);
return pingResult;
}
/**
* returns a promise with a boolean answer
* note: false also resolves with false as argument
@ -114,10 +120,14 @@ export class SmartNetwork {
public async getPublicIps() {
return {
v4: await plugins.publicIp.v4({
v4: await plugins.publicIp.publicIpv4({
timeout: 1000,
onlyHttps: true,
}),
v6: await plugins.publicIp.publicIpv6({
timeout: 1000,
onlyHttps: true,
})
};
}
}

View File

@ -6,14 +6,17 @@ import * as perfHooks from 'perf_hooks';
export { os, https, perfHooks };
// @pushrocks scope
import * as smartping from '@pushrocks/smartping';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartstring from '@pushrocks/smartstring';
export { smartpromise, smartstring };
export { smartpromise, smartping, smartstring };
// @third party scope
const isopen = require('isopen');
import publicIp from 'public-ip';
// @ts-ignore
import isopen from 'isopen';
// @ts-ignore
import * as publicIp from 'public-ip';
import * as systeminformation from 'systeminformation';
export { isopen, publicIp, systeminformation };

9
tsconfig.json Normal file
View File

@ -0,0 +1,9 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext"
}
}

View File

@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}