Skip to content
This repository has been archived by the owner on Sep 17, 2018. It is now read-only.

Commit

Permalink
important addition, .fwd and .hist requests must have at least one ma…
Browse files Browse the repository at this point in the history
…tching sig, can't do * scraping
  • Loading branch information
quartzjer committed Feb 9, 2010
1 parent 4bb285c commit 3e99918
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion org/index.html
Expand Up @@ -163,7 +163,7 @@ <h2>Notes</h2>

<p>For any incoming telex, once any _ring/_line is sorted out, a Writer then processes any commands (each is stateless and processed on their own). If there is an end signal, it should cause a .see response of some sort, and possibly trigger caching this telex (for .hist processing) if the Writer is the closest. Next, any and all contained signals should be checked against any active .fwd requests, and all matching .fwd Writers should get a copy of the telex.

<p>When an incoming {.fwd={sigA=5,sigB=10},sigC=foo} is received, it is registering to only receive telexes that contain a sigC=foo and any sigA or sigB signals (up to 5 or 10 times respectively). This can be used for more complex selection and filtering.
<p>When an incoming {.fwd={sigA=5,sigB=10},sigC=foo} is received, it is registering to only receive telexes that contain a sigC=foo and any sigA or sigB signals (up to 5 or 10 times respectively). This can be used for more complex selection and filtering. At least one matching signal (like sigC) is required for any .fwd or .hist command.

<p>Signals should primarily only ever contain hashes or generic (like xpath) content references and never actual content, as the sending and recipient parties must both be independently aware of the context or content in question so as to avoid any injection or attract spamming from 3rd parties.

Expand Down
21 changes: 13 additions & 8 deletions perl/writer.pl
Expand Up @@ -98,8 +98,8 @@

# first process all commands

# they want recent telexes matching these signals
if($j->{".hist"})
# they want recent telexes matching these signals (at least one matching signal required)
if($j->{".hist"} && scalar grep(/^[[:alnum:]]+/, keys %$j) > 0)
{
my $hist = $j->{".hist"};
# sanitize hist request
Expand Down Expand Up @@ -161,11 +161,15 @@
my $fwd = $j->{".fwd"};
my %fwds = map {$_ => ($fwd->{$_}>100)?100:int($fwd->{$_})} grep(/^[[:alnum:]]+/, keys %$fwd);
my %t = map { $_ => $j->{$_} } grep(/^[[:alnum:]]+/, keys %$j);
$t{".fwd"} = \%fwds;
$forwards{$writer} = \%t; # always replace any existing
my $jo = tnew($writer);
$jo->{"fwds"} = \%fwds; # just confirm whatever they sent for now
tsend($jo);
# only accept it if there's at least one signal to filter on
if(scalar keys %t > 0)
{
$t{".fwd"} = \%fwds;
$forwards{$writer} = \%t; # always replace any existing
my $jo = tnew($writer);
$jo->{"fwds"} = \%fwds; # just confirm whatever they sent for now
tsend($jo);
}
}

# now process signals, if any
Expand Down Expand Up @@ -221,7 +225,8 @@
}
}

# cache in history, max 1000
# cache in history if there's any signals, max 1000
next unless(scalar grep(/^[[:alnum:]]+/, keys %$j) > 0);
$j->{"at"} = time() unless($j->{"at"}); # make sure an at signal is set
unshift(@history,$j);
@history = splice(@history,0,1000);
Expand Down

0 comments on commit 3e99918

Please sign in to comment.