HushList Protocol Whitepaper
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

72 lines
1.3 KiB

#!/usr/bin/env perl
use strict;
use warnings;
use Try::Tiny;
use lib 'lib';
use Hush::List;
use Hush::Util qw/barf/;
use Data::Dumper;
# we only need one
my $list = Hush::List->new;
my $command = shift || help();
my $COMMANDS = {
"add" => \&add,
"contact" => \&contact,
"new" => \&new,
"remove" => \&remove,
"send" => \&send,
};
run();
sub help {
print "It would be nice to give some help\n";
}
sub contact {
my $cmd = shift || '';
if ($cmd eq 'new') {
# add a hust contact, yay
my ($name,$zaddr) = @ARGV;
die Dumper [ $name, $zaddr ];
}
}
sub new {
my $name = shift || '';
#TODO: better validation and allow safe unicode stuff
die "Invalid hushlist name '$name' !" unless $name && ($name =~ m/^[A-z0-9_-]{0,64}/);
$list->new_list($name);
print "hushlist '$name' created, enjoy your private comms :)\n";
}
sub run {
print "Running command $command\n";
my $cmd = $COMMANDS->{$command};
if ($cmd) {
$cmd->(@ARGV);
} else {
help();
}
}
sub add {
my ($list_name,$zaddr) = @_;
$list->add_zaddr($list_name,$zaddr);
}
sub remove {
my ($list_name,$zaddr) = @_;
$list->remove_zaddr($list_name,$zaddr);
}
sub send {
my ($list_name,$from,$memo) = @_;
$list->send_message($from, $list_name, $memo);
}