간단한 핑 도구. TCP/UDP/ICMP 프로토콜을 지원합니다.
핑거스는...
ICMP 에코 요청 및 ttl 추적 경로를 보냅니다.
핑 보내기, TCP/UDP 포트 스캔 및 배너 잡기.
UDP ping을 사용하여 매직 패킷(Wake on LAN)을 보냅니다.
pingus.Ping'ready''result''error'ping.send()pingus.PingTCP 확장: pingus.Pingnew PingTCP(options)pingtcp.send()pingtcp.scan()pingus.PingUDP 확장: pingus.Pingnew PingUDP(options)pingudp.send()pingudp.scan()pingus.PingICMP 확장: pingus.Pingnew PingICMP(options)pingicmp.send()pingicmp.traceroute()Callback 또는 Promise 사용( async/await )pingus.tcp(options[, callback])pingus.tcpscan(options[, callback])pingus.udp(options[, callback])pingus.udpscan(options[, callback])pingus.wol(mac, options[, callback])pingus.icmp(options[, callback])pingus.traceroute(options[, callback]) npm i pingus
설치 중 오류가 발생하는 경우, 다음 패키지의 설치 실패로 인한 것일 수 있습니다.
GCC 컴파일러를 설치하면 문제를 해결할 수 있습니다.
우분투에서는:
sudo apt-get install -y build-essentialWindows의 경우:
Desktop development with C++ 포함하는 Visual Studio 설치합니다.
// TCP Ping to localhost:22
import pingus from 'pingus' ; // ESM, Typescript
const pingus = require ( 'pingus' ) ; // CJS
pingus . tcp ( { host : 'localhost' , port : 22 } ) . then ( console . log ) ; // Result
{
type : 'ping/tcp' ,
status : 'open' ,
host : 'localhost' ,
ip : IP { label : '127.0.0.1' } ,
ips : [ IP { label : '127.0.0.1' } ] ,
time : 2 ,
port : 22 ,
name : 'ssh' ,
banner : 'SSH-2.0-OpenSSH_8.9p1 Ubuntu-3'
toPrimitiveJSON : [ Function ( anonymous ) ]
}pingus.Ping pingus.Ping 다음 이벤트를 포함하는 EventEmitter 입니다.
'ready'result <Object> ping.send() 호출 후 ping을 보낼 준비가 되면(DNS 확인, Bogon IP 필터링) 방출됩니다.
import pingus from 'pingus' ;
const ping = new pingus . PingTCP ( {
host : 'example.com' ,
} ) ;
ping . on ( 'ready' , ( result ) => {
const data = result . toPrimitiveJSON ( ) ;
console . log ( 'pingttarget:t' , data . host ) ;
console . log ( 'tips:t' , data . ips ) ;
} ) ;
ping . send ( ) ; ping target: example.com
ips: [ '93.184.215.14', '2606:2800:021f:cb07:6820:80da:af6b:8b2c' ]
'result'result <Object>핑 데이터 결과.
import pingus from 'pingus' ;
const ping = new pingus . PingTCP ( {
host : 'example.com' ,
} ) ;
ping . on ( 'result' , ( result ) => {
const data = result . toPrimitiveJSON ( ) ;
console . log ( result ) ;
} ) ;
ping . send ( ) ; {
type : 'ping/tcp' ,
status : 'open' ,
host : 'example.com' ,
ip : '93.184.215.14' ,
ips : [ '93.184.215.14' , '2606:2800:021f:cb07:6820:80da:af6b:8b2c' ] ,
time : 134 ,
port : 80 ,
name : 'http' ,
banner : ''
}'error'<Error>result <Object> 오류가 발생하면 발생합니다. result 오류가 발생하기 전 마지막 명령문과 오류 코드가 있습니다.
ping.send()핑을 보냅니다. 사용법의 몇 가지 예를 참조하세요.
pingus.PingTCP 확장: pingus.Ping TCP ping 클래스입니다.
pingus.PingTCP 는 pingus.Ping 의 유형입니다.
new PingTCP(options)options <Object>host <string> 대상 호스트 이름(도메인) 또는 IP 주소를 설정합니다.port <number> pingtcp.send() 사용 시 대상 포트를 설정합니다. 기본값: 80ports <Array> | <string> pingtcp.scan() 사용 시 대상 포트를 설정합니다. 포트 번호 배열이나 쿼리 문자열을 사용하세요. 예를 참조하세요.timeout <number> 시간 초과를 설정합니다. 기본값: 2000resolveDNS <boolean> host 도메인 주소인 경우 DNS A 및 AAAA 레코드를 확인합니다. 기본값: truednsServer <string> DNS 레코드를 확인하도록 DNS 서버를 설정합니다.filterBogon <boolean> host 의 Bogon IP 주소를 필터링합니다. 기본값: true options.ports 의 예 ports: [ 21 , 22 , 80 , 443 ] ; // Scan port 21, 22, 80, 443 ports: '21,22,80,443' ; // Scan port 21, 22, 80, 443 ports: '21-80' ; // Scan ports in range 21 to 80 (21, 22, 23 ... 78, 79, 80) ports: '21-25,80,443' ; // Scan ports in range 21 to 25 and 80, 443 ports: '@' ; // Scan most used 1024 ports in protocol ports: '*' ; // Scan all ports (1 to 65535)pingtcp.send() ping.send() 참조하세요. 사용법의 일부 예.
pingtcp.scan() TCP ping을 사용하여 포트를 스캔합니다. 이벤트에 대한 결과 반환: 'result' . 사용법의 몇 가지 예를 참조하세요.
pingus.PingUDP 확장: pingus.Ping UDP ping을 위한 클래스입니다.
pingus.PingUDP 는 pingus.Ping 의 유형입니다.
new PingUDP(options)options <Object>host <string> 대상 호스트 이름(도메인) 또는 IP 주소를 설정합니다.port <number> pingudp.send() 사용 시 대상 포트를 설정합니다. 기본값: 68ports <Array> | <string> pingudp.scan() 사용 시 대상 포트를 설정합니다. 포트 번호 배열이나 쿼리 문자열을 사용하세요. PingTCP와 동일합니다. 예를 참조하세요.buffer <Buffer> 연결된 UDP ping 소켓으로 보낼 때 버퍼를 설정합니다.body <string> 연결된 UDP ping 소켓으로 보낼 때 본문을 설정합니다. buffer 옵션이 설정되면 무시됩니다.bytes <number> 연결된 UDP 핑 소켓으로 보낼 때 임의의 바이트 길이를 설정합니다. body 옵션이 설정되면 무시됩니다. 기본값: 32timeout <number> 시간 초과를 설정합니다. 기본값: 2000resolveDNS <boolean> host 도메인 주소인 경우 DNS A 및 AAAA 레코드를 확인합니다. 기본값: truednsServer <string> DNS 레코드를 확인하도록 DNS 서버를 설정합니다.filterBogon <boolean> host 의 Bogon IP 주소를 필터링합니다. 기본값: truepingudp.send() ping.send() 참조하세요. 사용법의 일부 예.
pingudp.scan() pingtcp.scan() 과 유사합니다.
UDP ping을 사용하여 포트를 스캔합니다. 이벤트에 대한 결과 반환: 'result' . 사용법의 몇 가지 예를 참조하세요.
pingus.PingICMP 확장: pingus.Ping ICMP ping 클래스입니다.
pingus.PingICMP 는 pingus.Ping 의 유형입니다.
new PingICMP(options)options <Object>host <string> 대상 호스트 이름(도메인) 또는 IP 주소를 설정합니다.ttl <number> ttl을 설정합니다. 기본값: 128ttln <number> pingicmp.traceroute() 사용 시 시작 ttl을 설정합니다. 기본값: 1ttlx <number> pingicmp.traceroute() 사용 시 최대 ttl을 설정합니다. 기본값: 64timeout <number> 시간 초과를 설정합니다. 기본값: 2000timeoutx <number> pingicmp.traceroute() 사용 시 최대 시간 초과 스택을 설정합니다. 기본값: 8resolveDNS <boolean> host 도메인 주소인 경우 DNS A 및 AAAA 레코드를 확인합니다. 기본값: truednsServer <string> DNS 레코드를 확인하도록 DNS 서버를 설정합니다.filterBogon <boolean> host 의 Bogon IP 주소를 필터링합니다. 기본값: truepingicmp.send() ping.send() 참조하세요. 사용법의 일부 예.
pingicmp.traceroute()추적 경로를 실행합니다. 사용법의 일부 예.
Callback 또는 Promise 사용( async/await )핑 스타일 보내기의 예를 참조하세요.
pingus.tcp(options[, callback])TCP 핑을 보냅니다.
pingus.tcpscan(options[, callback])TCP ping을 사용하여 포트를 스캔합니다.
pingus.udp(options[, callback])UDP 핑을 보냅니다.
pingus.udpscan(options[, callback])UDP ping을 사용하여 포트를 스캔합니다.
pingus.wol(mac, options[, callback])mac <string> 대상 MAC 주소를 설정합니다.options <Object> new PingUDP(options) 의 옵션과 동일WOL 기능을 사용하려면 매직 패킷 UDP ping을 보냅니다.
pingus.icmp(options[, callback])ICMP 핑을 보냅니다.
pingus.traceroute(options[, callback])추적 경로를 실행합니다.
ESM(타입스크립트)
import pingus from 'pingus' ;CJS
const pingus = require ( 'pingus' ) ; Class 사용하면 EventEmitter 확장됩니다. // TCP ping to localhost:80
new pingus . PingTCP ( { host : 'localhost' } )
. on ( 'result' , ( result ) => {
console . log ( result . toPrimitiveJSON ( ) ) ;
} )
. on ( 'error' , ( err , result ) => {
throw err ;
} )
. send ( ) ;Callback 사용 // TCP ping to localhost:80
pingus . tcp ( { host : 'localhost' } , ( err , result ) => {
if ( err ) {
throw err ;
}
console . log ( result ) ;
} ) ;Promise 사용 // TCP ping to localhost:80
pingus
. tcp ( { host : 'localhost' } )
. then ( ( result ) => {
console . log ( result . toPrimitiveJSON ( ) ) ;
} )
. catch ( ( err ) => {
throw err ;
} ) ;async/await 사용 // TCP ping to localhost:80
const result = await pingus . tcp ( { host : 'localhost' } ) ;
console . log ( result . toPrimitiveJSON ( ) ) ; {
type : 'ping/tcp' ,
status : 'open' ,
host : 'localhost' ,
ip : '127.0.0.1' ,
ips : [ '127.0.0.1' ] ,
time : 2 ,
port : 80 ,
name : 'http' ,
banner : ''
} // TCP ping to localhost:22
new pingus . PingTCP ( { host : 'localhost' , port : 22 } )
. on ( 'result' , ( result ) => {
console . log ( result . toPrimitiveJSON ( ) ) ;
} )
. on ( 'error' , ( err , result ) => {
throw err ;
} )
. send ( ) ; {
type : 'ping/tcp' ,
status : 'open' ,
host : 'localhost' ,
ip : '127.0.0.1' ,
ips : [ '127.0.0.1' ] ,
time : 2 ,
port : 22 ,
name : 'ssh' ,
banner : 'SSH-2.0-OpenSSH_8.9p1 Ubuntu-3'
} // TCP ping scan to localhost
new pingus . PingTCP ( {
host : 'localhost' ,
ports : [ 21 , 22 , 80 , 443 , 3306 , 8080 ] ,
} )
. on ( 'result' , ( result ) => {
console . log ( result . toPrimitiveJSON ( ) ) ;
} )
. on ( 'error' , ( err , result ) => {
throw err ;
} )
. scan ( ) ; {
type : 'ping/tcp/scan' ,
status : 'finish' ,
host : 'localhost' ,
ip : '127.0.0.1' ,
ips : [ '127.0.0.1' ] ,
time : 2009 ,
port : 80 ,
name : 'http' ,
banner : '' ,
ports : [ 21 , 22 , 80 , 443 , 3306 , 8080 ] ,
statuses : {
open : [ 22 , 80 , 8080 ] ,
reset : [ ] ,
close : [ 21 , 443 , 3306 ] ,
filtered : [ ] ,
error : [ ]
} ,
names : {
'21' : 'ftp' ,
'22' : 'ssh' ,
'80' : 'http' ,
'443' : 'https' ,
'3306' : 'mysql' ,
'8080' : 'http-alt'
} ,
banners : { '22' : 'SSH-2.0-OpenSSH_8.9p1 Ubuntu-3' } ,
errors : { }
} // UDP ping to localhost:19132
new pingus . PingUDP ( { host : 'localhost' , port : 19132 } )
. on ( 'result' , ( result ) => {
console . log ( result . toPrimitiveJSON ( ) ) ;
} )
. on ( 'error' , ( err , result ) => {
throw err ;
} )
. send ( ) ; {
type : 'ping/udp' ,
status : 'close' ,
host : 'localhost' ,
ip : '127.0.0.1' ,
ips : [ '127.0.0.1' ] ,
time : 2 ,
port : 19132 ,
name : 'minecraft-be'
} // UDP ping scan to localhost
new pingus . PingUDP ( {
host : 'localhost' ,
ports : [ 67 , 68 , 161 , 162 , 445 ] ,
} )
. on ( 'result' , ( result ) => {
console . log ( result . toPrimitiveJSON ( ) ) ;
} )
. on ( 'error' , ( err , result ) => {
throw err ;
} )
. scan ( ) ; {
error : undefined ,
type : 'ping/udp/scan' ,
status : 'finish' ,
host : 'localhost' ,
ip : '127.0.0.1' ,
ips : [ '127.0.0.1' ] ,
time : 2003 ,
ports : [ 67 , 68 , 161 , 162 , 445 ] ,
statuses : {
open : [ 68 ] ,
reset : [ ] ,
close : [ 67 , 161 , 162 , 445 ] ,
filtered : [ ] ,
error : [ ]
} ,
names : {
'67' : 'bootps' ,
'68' : 'bootpc' ,
'161' : 'snmp' ,
'162' : 'snmptrap' ,
'445' : 'microsoft-ds'
} ,
banners : { } ,
errors : { }
} // Send magic packet using UDP ping to 00-00-00-00-00-00
pingus
. wol ( '00-00-00-00-00-00' )
. then ( ( result ) => {
console . log ( result . toPrimitiveJSON ( ) ) ;
} )
. catch ( ( error ) => {
throw error ;
} ) ; {
type : 'ping/udp' ,
status : 'open' ,
host : '255.255.255.255' ,
ip : '255.255.255.255' ,
ips : [ '255.255.255.255' ] ,
time : 2 ,
port : 9 ,
name : 'discard'
} // ICMP ping to example.com
new pingus . PingICMP ( { host : 'example.com' } )
. on ( 'result' , ( result ) => {
console . log ( result . toPrimitiveJSON ( ) ) ;
} )
. on ( 'error' , ( err , result ) => {
throw err ;
} )
. send ( ) ; {
type : 'ping/icmp' ,
status : 'reply' ,
host : 'example.com' ,
ip : '93.184.215.14' ,
ips : [ '93.184.215.14' , '2606:2800:021f:cb07:6820:80da:af6b:8b2c' ] ,
time : 130 ,
ttl : 128 ,
bytes : 32 ,
reply : {
source : '93.184.216.34' ,
type : 0 ,
code : 0 ,
typestr : 'ECHO_REPLY' ,
codestr : 'NO_CODE' ,
body : '767284c4'
}
} // ICMP ping to example.com using ttl = 10
new pingus . PingICMP ( { host : 'example.com' , ttl : 10 } )
. on ( 'result' , ( result ) => {
console . log ( result . toPrimitiveJSON ( ) ) ;
} )
. on ( 'error' , ( err , result ) => {
throw err ;
} )
. send ( ) ; {
type : 'ping/icmp' ,
status : 'exception' ,
host : 'example.com' ,
ip : '93.184.215.14' ,
ips : [ '93.184.215.14' , '2606:2800:021f:cb07:6820:80da:af6b:8b2c' ] ,
time : 133 ,
ttl : 10 ,
bytes : 32 ,
reply : {
source : '152.195.76.133' ,
type : 11 ,
code : 0 ,
typestr : 'TIME_EXCEEDED' ,
codestr : 'NO_CODE' ,
body : ']8X"bx00CQx00x00x00x00'
}
} // Traceroute to example.com
new pingus . PingICMP ( { host : 'example.com' , timeout : 500 } )
. on ( 'result' , ( result ) => {
console . log ( result . toPrimitiveJSON ( ) ) ;
} )
. on ( 'error' , ( err , result ) => {
throw err ;
} )
. traceroute ( ) ; {
type : 'ping/icmp/traceroute' ,
status : 'finish' ,
host : 'example.com' ,
ip : '93.184.215.14' ,
ips : [ '93.184.215.14' , '2606:2800:021f:cb07:6820:80da:af6b:8b2c' ] ,
time : 7614 ,
ttl : 128 ,
bytes : 32 ,
hops : [
{
status : 'time_exceeded' ,
ip : '172.19.80.1' ,
ttl : 1 ,
rtt : { min : 0 , max : 1 , avg : 1 }
} ,
{
status : 'time_exceeded' ,
ip : '172.30.1.254' ,
ttl : 2 ,
rtt : { min : 0 , max : 1 , avg : 1 }
} ,
{
status : 'timeout' ,
ip : null ,
ttl : 3 ,
rtt : { min : 2001 , max : 2002 , avg : 2002 }
} ,
{
status : 'time_exceeded' ,
ip : '112.188.59.77' ,
ttl : 4 ,
rtt : { min : 2 , max : 3 , avg : 3 }
} ,
{
status : 'time_exceeded' ,
ip : '112.188.53.13' ,
ttl : 5 ,
rtt : { min : 1 , max : 2 , avg : 2 }
} ,
{
status : 'time_exceeded' ,
ip : '112.174.47.177' ,
ttl : 6 ,
rtt : { min : 7 , max : 8 , avg : 8 }
} ,
{
status : 'time_exceeded' ,
ip : '112.174.91.130' ,
ttl : 7 ,
rtt : { min : 7 , max : 8 , avg : 8 }
} ,
{
status : 'time_exceeded' ,
ip : '112.174.87.102' ,
ttl : 8 ,
rtt : { min : 129 , max : 130 , avg : 130 }
} ,
{
status : 'time_exceeded' ,
ip : '206.72.210.112' ,
ttl : 9 ,
rtt : { min : 127 , max : 128 , avg : 128 }
} ,
{
status : 'time_exceeded' ,
ip : '152.195.76.151' ,
ttl : 10 ,
rtt : { min : 132 , max : 134 , avg : 133 }
} ,
{
status : 'reply' ,
ip : '93.184.215.14' ,
ttl : 11 ,
rtt : { min : 126 , max : 126 , avg : 126 }
}
]
}