diff options
author | Alexander Sulfrian <alex@spline.inf.fu-berlin.de> | 2016-06-21 20:26:59 +0200 |
---|---|---|
committer | Alexander Sulfrian <alex@spline.inf.fu-berlin.de> | 2016-06-21 20:26:59 +0200 |
commit | 99b5ef197b23ea72220ef568b38f0f3c97943293 (patch) | |
tree | b504975d07a5536e517c4b25805daae5eb563c49 /Spline/Socketmap | |
parent | ea57f7b2b7b295a06c6cb361f5c1e61f78e7b456 (diff) | |
download | srs-99b5ef197b23ea72220ef568b38f0f3c97943293.tar.gz srs-99b5ef197b23ea72220ef568b38f0f3c97943293.tar.bz2 srs-99b5ef197b23ea72220ef568b38f0f3c97943293.zip |
No Socketmap protocol in Spline::Srs
Better error handling.
Diffstat (limited to 'Spline/Socketmap')
-rw-r--r-- | Spline/Socketmap/Srs.pm | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/Spline/Socketmap/Srs.pm b/Spline/Socketmap/Srs.pm index c4a9623..785fd04 100644 --- a/Spline/Socketmap/Srs.pm +++ b/Spline/Socketmap/Srs.pm @@ -9,8 +9,31 @@ use Spline::Srs; sub lookup($$) { my $self = shift; my ($map, $key) = @_; + my $result; - $self->{srs}->handle($map, $key); + eval { + $result = $self->{srs}->handle($map, $key); + }; + + my $err = $@; + if ($err) { + if ($err =~ m/(Invalid hash|Invalid timestamp)/) { + $self->log(0, "Error: $err"); + return "PERM $err"; + } + } + + if (defined $result) { + if ($result eq $key) { + $self->log(1, 'Not mapping "' . $key . '"'); + return 'NOTFOUND '; + } + + $self->log(1, 'Mapping "' . $key . '" to "' . $result . '"'); + return "OK $result"; + } + + return 'NOTFOUND '; } sub options($$) { @@ -70,7 +93,7 @@ sub post_configure_hook { close($file); } else { - $self->log(1, 'ERROR: Cannot open secret_file: "' . $filename . '"'); + $self->log(0, 'ERROR: Cannot open secret_file: "' . $filename . '"'); } } |