"use strict"; import net from 'net'; import l from 'log'; import settings from '../../settings.mjs'; import sleep from '../../lib/async/sleep.mjs'; import Connection from '../../lib/transport/Connection.mjs'; import { encrypt, decrypt } from '../../lib/crypto/secretbox.mjs'; export default async function() { const test_key = "H7xKSxvJFoZoNjCKAfxn4E3qUzY3Y/4bjY+qIzxg+78="; const test_data = "hello, world"; l.notice(`TEST_DATA`, test_data); const encrypted = encrypt(test_key, test_data); l.notice(`ENCRYPTED`, encrypted); const decrypted = decrypt(test_key, encrypted); l.notice(`DECRYPTED`, decrypted); const socket = await Connection.Create(test_key, "::1", settings.cli.port); socket.on("message", (event, msg) => { l.notice(`<<< ${event}: ${JSON.stringify(msg)}`); }); for(let i = 0; i < 100; i++) { await sleep(1000); l.notice(`>>> hello world ${i}`); socket.send(`test-client`, `hello world ${i}\n`); } }