wip noisy echo

This commit is contained in:
Peter Harpending
2026-09-02 02:23:59 -07:00
parent 7aa6f4b863
commit e5436c2e3e
13 changed files with 1831 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
% @doc echo server client
-module(nechoc).
-export([main/0]).
main() ->
{ok, TcpSocket} = gen_tcp:connect("localhost", 6969, [binary, {packet, 0}]),
ok = inet:setopts(Socket, [{active, once}]),
{ok, NoiseSock, _HandshakeState} = enoise:connect(TcpSocket, noise_options()),
loop(Socket).
noise_options() ->
% totally safe crypto
KP = enoise_keypair:new(dh25519),
[{noise, "Noise_NN_25519_ChaChaPoly_BLAKE2b"},
{e, KP}].
j_loop(NSock) ->
ok = inet:setopts(NSock, [{active, once}]),
receive
{tcp, Socket, Bytes} ->
ok = io:format("< ~tp~n", [Bytes]),
loop(Socket);
{tcp_closed, Socket} ->
ok = io:format("connection terminated~n", []),
exit(normal)
end.