scratch
This commit is contained in:
+11
-24
@@ -4,41 +4,28 @@
|
|||||||
* Author: Peter Harpending <peterharpending@qpq.swiss>
|
* Author: Peter Harpending <peterharpending@qpq.swiss>
|
||||||
* Date: 2026-08-12
|
* Date: 2026-08-12
|
||||||
*/
|
*/
|
||||||
|
|
||||||
contract Rubicon =
|
contract Rubicon =
|
||||||
// this could/should be a record, but records aren't really
|
// this could/should be a record, but records aren't really
|
||||||
// portable across contracts/languages/APIs
|
// portable across contracts/languages/APIs
|
||||||
//
|
//
|
||||||
// I think records are returned to caller as a FATE tuple with
|
|
||||||
// fields in this order. I don't really know though and that's
|
|
||||||
// kind of a hack and not something that we should build around i
|
|
||||||
// feel like
|
|
||||||
//
|
|
||||||
// record rbx =
|
// record rbx =
|
||||||
// {ip : string,
|
// {ip : string,
|
||||||
// port : int,
|
// port : int,
|
||||||
// protocol : string, // "tcp", "udp", "sctp", etc
|
// protocol : string, // "tcp", "udp", "sctp", etc
|
||||||
// noise : string, // Noise_Foo_Bar_Baz_Quux
|
// noise : string, // Noise_Foo_Bar_Baz_Quux
|
||||||
// pubkey : bytes, // service's pubkey
|
// pubkey : bytes, // responder static pubkey (noise rs field)
|
||||||
// salt : bytes} // ???
|
// prologue : bytes} // noise prologue (empty = no prologue)
|
||||||
|
|
||||||
// (ip, port, protocol, noise, pubkey)
|
// (ip, port, protocol, noise, pubkey, prologue)
|
||||||
type rbx_tuple = string * int * string * string * bytes
|
type rbx_tuple = string * int * string * string * bytes * bytes
|
||||||
type state = list(rbx_tuple)
|
type state = list(rbx_tuple)
|
||||||
|
|
||||||
entrypoint
|
entrypoint init(tuples: list(rbx_tuple)): state =
|
||||||
init : list(rbx_tuple) => state
|
tuples
|
||||||
init(services) =
|
|
||||||
services
|
|
||||||
|
|
||||||
stateful entrypoint
|
stateful entrypoint set(tuples: list(rbx_tuple)): unit =
|
||||||
set_services : list(rbx_tuple) => ()
|
require(Call.caller == Contract.creator, "Not allowed")
|
||||||
set_services(_) | Call.caller != Contract.creator =
|
put(tuples)
|
||||||
abort("Not allowed")
|
|
||||||
set_services(svs) =
|
|
||||||
put(svs)
|
|
||||||
|
|
||||||
entrypoint
|
entrypoint lookup(): list(rbx_tuple) =
|
||||||
get_services : () => list(rbx_tuple)
|
state
|
||||||
get_services() =
|
|
||||||
state
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
.eunit
|
||||||
|
deps
|
||||||
|
*.o
|
||||||
|
*.beam
|
||||||
|
*.plt
|
||||||
|
*.swp
|
||||||
|
erl_crash.dump
|
||||||
|
ebin/*.beam
|
||||||
|
doc/*.html
|
||||||
|
doc/*.css
|
||||||
|
doc/edoc-info
|
||||||
|
doc/erlang.png
|
||||||
|
rel/example_project
|
||||||
|
.concrete/DEV_MODE
|
||||||
|
.rebar
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"src/*", [debug_info, {i, "include/"}, {outdir, "ebin/"}]}.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{application,rq,
|
||||||
|
[{description,[]},
|
||||||
|
{registered,[]},
|
||||||
|
{included_applications,[]},
|
||||||
|
{applications,[stdlib,kernel]},
|
||||||
|
{vsn,"0.1.0"},
|
||||||
|
{modules,[rq]}]}.
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
%% @doc rubicon querier
|
||||||
|
-module(rq).
|
||||||
|
-vsn("0.1.0").
|
||||||
|
-author("Peter Harpending").
|
||||||
|
-copyright("Peter Harpending").
|
||||||
|
|
||||||
|
|
||||||
|
-export([start/1]).
|
||||||
|
|
||||||
|
|
||||||
|
-spec start(ArgV) -> ok
|
||||||
|
when ArgV :: [string()].
|
||||||
|
|
||||||
|
start(ArgV) ->
|
||||||
|
ok = application:ensure_started(hakuzaru),
|
||||||
|
ok = hz:chain_nodes([{"testnet.tsuriai.jp", 3013},
|
||||||
|
{"testnet.gajumaru.io", 3013}]),
|
||||||
|
ok = io:format("Hello, World! Args: ~tp~n", [ArgV]),
|
||||||
|
zx:silent_stop().
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
{name,"rq"}.
|
||||||
|
{type,cli}.
|
||||||
|
{modules,[]}.
|
||||||
|
{mod,"rq"}.
|
||||||
|
{author,"Peter Harpending"}.
|
||||||
|
{prefix,none}.
|
||||||
|
{desc,[]}.
|
||||||
|
{package_id,{"otpr","rq",{0,1,0}}}.
|
||||||
|
{deps,[{"otpr","hakuzaru",{0,9,1}}]}.
|
||||||
|
{key_name,none}.
|
||||||
|
{a_email,[]}.
|
||||||
|
{c_email,[]}.
|
||||||
|
{copyright,"Peter Harpending"}.
|
||||||
|
{file_exts,[]}.
|
||||||
|
{license,skip}.
|
||||||
|
{repo_url,[]}.
|
||||||
|
{tags,[]}.
|
||||||
|
{ws_url,[]}.
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env escript
|
#!/usr/bin/env escript
|
||||||
|
|
||||||
|
%% authentication
|
||||||
%% needs:
|
%% needs:
|
||||||
%% - line parsing
|
%% - line parsing
|
||||||
%% - keyboard input
|
%% - keyboard input
|
||||||
@@ -29,15 +30,21 @@ main_ii(PortNum) ->
|
|||||||
spawn_link(fun() -> kbd_loop(Self) end),
|
spawn_link(fun() -> kbd_loop(Self) end),
|
||||||
j_loop(#js{tsock = TSock, nsock = NSock}).
|
j_loop(#js{tsock = TSock, nsock = NSock}).
|
||||||
|
|
||||||
|
|
||||||
|
server_pubkey() ->
|
||||||
|
<<116, 159, 91, 248, 138, 250, 73, 40, 231, 50, 81, 110, 137,
|
||||||
|
163, 44, 76, 48, 130, 225, 95, 168, 121, 93, 44, 148, 42, 180,
|
||||||
|
103, 11, 40, 168, 96>>.
|
||||||
|
|
||||||
noise_options() ->
|
noise_options() ->
|
||||||
% totally safe crypto
|
% totally safe crypto
|
||||||
KP = enoise_keypair:new(dh25519),
|
KP = enoise_keypair:new(dh25519),
|
||||||
[{noise, "Noise_NN_25519_ChaChaPoly_BLAKE2b"},
|
[{noise, "Noise_NK_25519_ChaChaPoly_BLAKE2b"},
|
||||||
|
{rs, server_pubkey()},
|
||||||
{e, KP}].
|
{e, KP}].
|
||||||
|
|
||||||
|
|
||||||
j_loop(JS = #js{rcv = Rcv, tsock = TSock, nsock = NSock}) ->
|
j_loop(JS = #js{rcv = Rcv, tsock = TSock, nsock = NSock}) ->
|
||||||
%ok = inet:setopts(TSock, [{active, once}]),
|
|
||||||
receive
|
receive
|
||||||
{noise, NSock, Bytes} ->
|
{noise, NSock, Bytes} ->
|
||||||
NewRcv = <<Rcv/binary, Bytes/binary>>,
|
NewRcv = <<Rcv/binary, Bytes/binary>>,
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ noise_options() ->
|
|||||||
148, 42, 180, 103, 11, 40, 168, 96>>,
|
148, 42, 180, 103, 11, 40, 168, 96>>,
|
||||||
KP = enoise_keypair:new(dh25519, Secret, Public),
|
KP = enoise_keypair:new(dh25519, Secret, Public),
|
||||||
[{noise, "Noise_NN_25519_ChaChaPoly_BLAKE2b"},
|
[{noise, "Noise_NN_25519_ChaChaPoly_BLAKE2b"},
|
||||||
{e, KP}].
|
{s, KP}].
|
||||||
|
|
||||||
|
|
||||||
% pimp process startup
|
% pimp process startup
|
||||||
|
|||||||
@@ -1,3 +1,14 @@
|
|||||||
|
pubkey:
|
||||||
|
|
||||||
|
<<116, 159, 91, 248, 138, 250, 73, 40, 231, 50, 81, 110, 137, 163, 44, 76, 48, 130, 225, 95, 168, 121, 93, 44, 148, 42, 180, 103, 11, 40, 168, 96>>
|
||||||
|
|
||||||
|
rbx_tuple =
|
||||||
|
<<116,159,91,248,138,250,73,40,231,50,81,110,137,163,44,76,48,130,225,95,168,121,93,44,148,42,180,103,11,40,168,96>>
|
||||||
|
|
||||||
|
[{"127.0.0.1", 6969, "tcp", "Noise_NN_25519_ChaChaPoly_BLAKE2b", <<116,159,91,248,138,250,73,40,231,50,81,110,137,163,44,76,48,130,225,95,168,121,93,44,148,42,180,103,11,40,168,96>>, <<>>}]
|
||||||
|
|
||||||
|
{"127.0.0.1", 6970, "tcp", <<116,159,91,248,138,250,73,40,231,50,81,110,137,163,44,76,48,130,225,95,168,121,93,44,148,42,180,103,11,40,168,96>>, <<>>},
|
||||||
|
{"127.0.0.1", 6971, "tcp", <<116,159,91,248,138,250,73,40,231,50,81,110,137,163,44,76,48,130,225,95,168,121,93,44,148,42,180,103,11,40,168,96>>, <<>>}]
|
||||||
|
|
||||||
liquidate_hos([{HoPid, _HoRef} | Hos]) ->
|
liquidate_hos([{HoPid, _HoRef} | Hos]) ->
|
||||||
p_logfln("liquidating ~tp", [HoPid]),
|
p_logfln("liquidating ~tp", [HoPid]),
|
||||||
|
|||||||
Reference in New Issue
Block a user