diff --git a/client/index.js b/client/index.js index cf78cb2..41fdc37 100644 --- a/client/index.js +++ b/client/index.js @@ -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(); \ No newline at end of file +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); \ No newline at end of file