-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbind.js
More file actions
43 lines (39 loc) · 1.44 KB
/
Copy pathbind.js
File metadata and controls
43 lines (39 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import Logger from '../../logger'
export default (sonar, active)=>{
sonar.bind({
host: active.ip,
init: (server, option)=>{
let serverIp = server.address()
Logger(`UDP SERVER INITIALIZED... [${serverIp.address}:${serverIp.port}]`)
},
bind: (server, option)=>{
let serverIp = server.address()
Logger(`UDP SERVER BINDED... [${serverIp.address}:${serverIp.port}]`)
let process = ()=>{
console.log('')
Logger(`SENDING PCAP PACKET...`)
let sendAlert = sonar.send(`hello! world`, {
from: {
address: '1.2.3.4',
port: '5'
},
to: {
address: active.external,
port: serverIp.port
},
noRaw: false // IT MUST BE /FALSE/ WORK ON RAW.
})
if(sendAlert !== null)
Logger(`SENDING ALERT: ${sendAlert}`)
}
process()
setInterval(process, 3000)
},
receive: (message, client, error, server, option)=>{
let serverIp = server.address()
Logger(`UDP MESSAGE RECEIVED... [${client.address}:${client.port}->${serverIp.address}:${serverIp.port}]`)
Logger(String(message))
console.log(message)
}
})
}