client keepalive
This commit is contained in:
parent
c43e1b0fb2
commit
7c0906401a
|
|
@ -9,6 +9,7 @@ const net = require('net');
|
|||
const { Tun } = require('tuntap2');
|
||||
const { encrypt, decrypt } = require('../encryption');
|
||||
const IP = require('ip-packet');
|
||||
const { randomFill, randomFillSync } = require('crypto');
|
||||
const sock = dgram.createSocket('udp4');
|
||||
|
||||
const tun = new Tun();
|
||||
|
|
@ -79,4 +80,24 @@ function authenticateAndCheck() {
|
|||
}, 2000);
|
||||
}
|
||||
|
||||
authenticateAndCheck();
|
||||
function keepAlive() {
|
||||
var buff = Buffer.alloc(64);
|
||||
randomFillSync(buff);
|
||||
buff[0] = 0x60; // actually you can send anything just make sure that buff[0] >> 4 !== 4
|
||||
sock.send(
|
||||
encrypt(
|
||||
buff,
|
||||
config.privateKey,
|
||||
config.iv,
|
||||
config.algorithm
|
||||
),
|
||||
config.port,
|
||||
config.endpoint
|
||||
);
|
||||
}
|
||||
|
||||
authenticateAndCheck();
|
||||
|
||||
setInterval(() => {
|
||||
keepAlive();
|
||||
}, 15000);
|
||||
Loading…
Reference in New Issue