Skip to content

Commit

Permalink
converted port-scanner to cjs
Browse files Browse the repository at this point in the history
  • Loading branch information
iSkore committed May 15, 2020
1 parent 92ec0e9 commit 5423be3
Show file tree
Hide file tree
Showing 7 changed files with 1,098 additions and 7,711 deletions.
3 changes: 0 additions & 3 deletions packages/port-scanner/cjs/package.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/port-scanner/cjs/port-scanner.js

This file was deleted.

25 changes: 16 additions & 9 deletions packages/port-scanner/lib/port-scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
*******************************************************************************************************/
'use strict';

import { createConnection } from 'net';
import { EventEmitter } from 'events';
import LightMap from '@mi-sec/lightmap';
import NetworkCidr from '@mi-sec/network-cidr';

export const commonPorts = new LightMap( [
const
{ createConnection } = require( 'net' ),
{ EventEmitter } = require( 'events' ),
LightMap = require( '@mi-sec/lightmap' ),
NetworkCidr = require( '@mi-sec/network-cidr' );

console.log( NetworkCidr );
const commonPorts = new LightMap( [
[ 7, 'echo' ],
[ 9, 'discard' ],
[ 13, 'daytime' ],
Expand Down Expand Up @@ -113,7 +115,7 @@ export const commonPorts = new LightMap( [
[ 49157, 'unknown' ]
] );

export function convertHighResolutionTime( t ) {
function convertHighResolutionTime( t ) {
return ( ( t[ 0 ] * 1e9 ) + t[ 1 ] ) / 1e6;
}

Expand Down Expand Up @@ -142,7 +144,7 @@ export function convertHighResolutionTime( t ) {
* service: 'ssh'
* }
*/
export function connect( host, port, opts = {} ) {
function connect( host, port, opts = {} ) {
!opts.debug || console.log( `scanning ${ host }:${ port }` );

return new Promise(
Expand Down Expand Up @@ -244,7 +246,7 @@ export function connect( host, port, opts = {} ) {
);
}

export default class PortScanner extends EventEmitter
class PortScanner extends EventEmitter
{
constructor( opts = {} )
{
Expand Down Expand Up @@ -313,3 +315,8 @@ export default class PortScanner extends EventEmitter
this.emit( 'done', this.result );
}
}

module.exports = PortScanner;
module.exports.commonPorts = commonPorts;
module.exports.convertHighResolutionTime = convertHighResolutionTime;
module.exports.connect = connect;
Loading

0 comments on commit 5423be3

Please sign in to comment.