wip noisy echo
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user