--- 3m-810.pl 2010/02/11 14:14:21 66 +++ 3m-810.pl 2010/02/11 14:59:56 67 @@ -103,6 +103,22 @@ print $client "HTTP/1.0 $status $method\r\nLocation: $server_url\r\n\r\n"; + } elsif ( $method =~ m{/secure} ) { + + my $status = 501; # Not implementd + + foreach my $p ( keys %$param ) { + next unless $p =~ m/^(E[0-9A-F]{15})$/; + my $tag = $1; + my $data = $param->{$p}; + $status = 302; + + warn "SECURE $tag $data\n"; + secure_tag_with( $tag, $data ); + } + + print $client "HTTP/1.0 $status $method\r\nLocation: $server_url\r\n\r\n"; + } else { print $client "HTTP/1.0 404 Unkown method\r\n"; } @@ -395,6 +411,12 @@ return $hash; } +sub forget_tag { + my $tag = shift; + delete $tags_data->{$tag}; + delete $visible_tags->{$tag}; +} + sub read_tag { my ( $tag ) = @_; @@ -483,9 +505,18 @@ rename $path, $to; print ">> $to\n"; - # force re-read of tag - delete $tags_data->{$tag}; - delete $visible_tags->{$tag}; + forget_tag $tag; +} + +sub secure_tag_with { + my ( $tag, $data ) = @_; + + cmd( + "d6 00 0c 09 $tag $data BEEF", "secure $tag -> $data", + "d6 00 0c 09 00 $tag BEEF", sub { assert() }, + ); + + forget_tag $tag; } sub secure_tag { @@ -494,10 +525,7 @@ my $path = "$secure_path/$tag"; my $data = substr(read_file( $path ),0,2); - cmd( - "d6 00 0c 09 $tag $data BEEF", "secure $tag -> $data", - "d6 00 0c 09 00 $tag BEEF", sub { assert() }, - ); + secure_tag_with( $tag, $data ); my $to = $path; $to .= '.' . time();