scratch
This commit is contained in:
+10
-23
@@ -4,41 +4,28 @@
|
||||
* Author: Peter Harpending <peterharpending@qpq.swiss>
|
||||
* Date: 2026-08-12
|
||||
*/
|
||||
|
||||
contract Rubicon =
|
||||
// this could/should be a record, but records aren't really
|
||||
// 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 =
|
||||
// {ip : string,
|
||||
// port : int,
|
||||
// protocol : string, // "tcp", "udp", "sctp", etc
|
||||
// noise : string, // Noise_Foo_Bar_Baz_Quux
|
||||
// pubkey : bytes, // service's pubkey
|
||||
// salt : bytes} // ???
|
||||
// pubkey : bytes, // responder static pubkey (noise rs field)
|
||||
// prologue : bytes} // noise prologue (empty = no prologue)
|
||||
|
||||
// (ip, port, protocol, noise, pubkey)
|
||||
type rbx_tuple = string * int * string * string * bytes
|
||||
// (ip, port, protocol, noise, pubkey, prologue)
|
||||
type rbx_tuple = string * int * string * string * bytes * bytes
|
||||
type state = list(rbx_tuple)
|
||||
|
||||
entrypoint
|
||||
init : list(rbx_tuple) => state
|
||||
init(services) =
|
||||
services
|
||||
entrypoint init(tuples: list(rbx_tuple)): state =
|
||||
tuples
|
||||
|
||||
stateful entrypoint
|
||||
set_services : list(rbx_tuple) => ()
|
||||
set_services(_) | Call.caller != Contract.creator =
|
||||
abort("Not allowed")
|
||||
set_services(svs) =
|
||||
put(svs)
|
||||
stateful entrypoint set(tuples: list(rbx_tuple)): unit =
|
||||
require(Call.caller == Contract.creator, "Not allowed")
|
||||
put(tuples)
|
||||
|
||||
entrypoint
|
||||
get_services : () => list(rbx_tuple)
|
||||
get_services() =
|
||||
entrypoint lookup(): list(rbx_tuple) =
|
||||
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
|
||||
|
||||
%% authentication
|
||||
%% needs:
|
||||
%% - line parsing
|
||||
%% - keyboard input
|
||||
@@ -29,15 +30,21 @@ main_ii(PortNum) ->
|
||||
spawn_link(fun() -> kbd_loop(Self) end),
|
||||
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() ->
|
||||
% totally safe crypto
|
||||
KP = enoise_keypair:new(dh25519),
|
||||
[{noise, "Noise_NN_25519_ChaChaPoly_BLAKE2b"},
|
||||
[{noise, "Noise_NK_25519_ChaChaPoly_BLAKE2b"},
|
||||
{rs, server_pubkey()},
|
||||
{e, KP}].
|
||||
|
||||
|
||||
j_loop(JS = #js{rcv = Rcv, tsock = TSock, nsock = NSock}) ->
|
||||
%ok = inet:setopts(TSock, [{active, once}]),
|
||||
receive
|
||||
{noise, NSock, Bytes} ->
|
||||
NewRcv = <<Rcv/binary, Bytes/binary>>,
|
||||
|
||||
@@ -39,7 +39,7 @@ noise_options() ->
|
||||
148, 42, 180, 103, 11, 40, 168, 96>>,
|
||||
KP = enoise_keypair:new(dh25519, Secret, Public),
|
||||
[{noise, "Noise_NN_25519_ChaChaPoly_BLAKE2b"},
|
||||
{e, KP}].
|
||||
{s, KP}].
|
||||
|
||||
|
||||
% 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]) ->
|
||||
p_logfln("liquidating ~tp", [HoPid]),
|
||||
|
||||
Reference in New Issue
Block a user