99 |
|
|
100 |
warn "PROGRAM $tag $content\n"; |
warn "PROGRAM $tag $content\n"; |
101 |
write_tag( $tag, $content ); |
write_tag( $tag, $content ); |
102 |
|
secure_tag_with( $tag, $param->{$p} =~ /^130/ ? 'DA' : 'D7' ); |
103 |
|
} |
104 |
|
|
105 |
|
print $client "HTTP/1.0 $status $method\r\nLocation: $server_url\r\n\r\n"; |
106 |
|
|
107 |
|
} elsif ( $method =~ m{/secure} ) { |
108 |
|
|
109 |
|
my $status = 501; # Not implementd |
110 |
|
|
111 |
|
foreach my $p ( keys %$param ) { |
112 |
|
next unless $p =~ m/^(E[0-9A-F]{15})$/; |
113 |
|
my $tag = $1; |
114 |
|
my $data = $param->{$p}; |
115 |
|
$status = 302; |
116 |
|
|
117 |
|
warn "SECURE $tag $data\n"; |
118 |
|
secure_tag_with( $tag, $data ); |
119 |
} |
} |
120 |
|
|
121 |
print $client "HTTP/1.0 $status $method\r\nLocation: $server_url\r\n\r\n"; |
print $client "HTTP/1.0 $status $method\r\nLocation: $server_url\r\n\r\n"; |
412 |
return $hash; |
return $hash; |
413 |
} |
} |
414 |
|
|
415 |
|
sub forget_tag { |
416 |
|
my $tag = shift; |
417 |
|
delete $tags_data->{$tag}; |
418 |
|
delete $visible_tags->{$tag}; |
419 |
|
} |
420 |
|
|
421 |
sub read_tag { |
sub read_tag { |
422 |
my ( $tag ) = @_; |
my ( $tag ) = @_; |
423 |
|
|
506 |
rename $path, $to; |
rename $path, $to; |
507 |
print ">> $to\n"; |
print ">> $to\n"; |
508 |
|
|
509 |
# force re-read of tag |
forget_tag $tag; |
510 |
delete $tags_data->{$tag}; |
} |
511 |
delete $visible_tags->{$tag}; |
|
512 |
|
sub secure_tag_with { |
513 |
|
my ( $tag, $data ) = @_; |
514 |
|
|
515 |
|
cmd( |
516 |
|
"d6 00 0c 09 $tag $data BEEF", "secure $tag -> $data", |
517 |
|
"d6 00 0c 09 00 $tag BEEF", sub { assert() }, |
518 |
|
); |
519 |
|
|
520 |
|
forget_tag $tag; |
521 |
} |
} |
522 |
|
|
523 |
sub secure_tag { |
sub secure_tag { |
526 |
my $path = "$secure_path/$tag"; |
my $path = "$secure_path/$tag"; |
527 |
my $data = substr(read_file( $path ),0,2); |
my $data = substr(read_file( $path ),0,2); |
528 |
|
|
529 |
cmd( |
secure_tag_with( $tag, $data ); |
|
"d6 00 0c 09 $tag $data BEEF", "secure $tag -> $data", |
|
|
"d6 00 0c 09 00 $tag BEEF", sub { assert() }, |
|
|
); |
|
530 |
|
|
531 |
my $to = $path; |
my $to = $path; |
532 |
$to .= '.' . time(); |
$to .= '.' . time(); |