Skip to content

Commit 5423be3

Browse files
committed
converted port-scanner to cjs
1 parent 92ec0e9 commit 5423be3

File tree

7 files changed

+1098
-7711
lines changed

7 files changed

+1098
-7711
lines changed

packages/port-scanner/cjs/package.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/port-scanner/cjs/port-scanner.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/port-scanner/lib/port-scanner.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
*******************************************************************************************************/
66
'use strict';
77

8-
import { createConnection } from 'net';
9-
import { EventEmitter } from 'events';
10-
import LightMap from '@mi-sec/lightmap';
11-
import NetworkCidr from '@mi-sec/network-cidr';
12-
13-
export const commonPorts = new LightMap( [
8+
const
9+
{ createConnection } = require( 'net' ),
10+
{ EventEmitter } = require( 'events' ),
11+
LightMap = require( '@mi-sec/lightmap' ),
12+
NetworkCidr = require( '@mi-sec/network-cidr' );
13+
14+
console.log( NetworkCidr );
15+
const commonPorts = new LightMap( [
1416
[ 7, 'echo' ],
1517
[ 9, 'discard' ],
1618
[ 13, 'daytime' ],
@@ -113,7 +115,7 @@ export const commonPorts = new LightMap( [
113115
[ 49157, 'unknown' ]
114116
] );
115117

116-
export function convertHighResolutionTime( t ) {
118+
function convertHighResolutionTime( t ) {
117119
return ( ( t[ 0 ] * 1e9 ) + t[ 1 ] ) / 1e6;
118120
}
119121

@@ -142,7 +144,7 @@ export function convertHighResolutionTime( t ) {
142144
* service: 'ssh'
143145
* }
144146
*/
145-
export function connect( host, port, opts = {} ) {
147+
function connect( host, port, opts = {} ) {
146148
!opts.debug || console.log( `scanning ${ host }:${ port }` );
147149

148150
return new Promise(
@@ -244,7 +246,7 @@ export function connect( host, port, opts = {} ) {
244246
);
245247
}
246248

247-
export default class PortScanner extends EventEmitter
249+
class PortScanner extends EventEmitter
248250
{
249251
constructor( opts = {} )
250252
{
@@ -313,3 +315,8 @@ export default class PortScanner extends EventEmitter
313315
this.emit( 'done', this.result );
314316
}
315317
}
318+
319+
module.exports = PortScanner;
320+
module.exports.commonPorts = commonPorts;
321+
module.exports.convertHighResolutionTime = convertHighResolutionTime;
322+
module.exports.connect = connect;

0 commit comments

Comments
 (0)