1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2024-11-29 09:24:12 +01:00
yubikey-val/travis/server.pl
2013-11-08 10:32:12 +01:00

34 lines
727 B
Perl

#!/usr/bin/perl
use IO::Socket::INET;
use strict;
use warnings;
my %otps = (
'idkfefrdhtrutjduvtcjbfeuvhehdvjjlbchtlenfgku' => 'OK counter=0001 low=8d40 high=0f use=00',
'idkfefrdhtrutjduvtcjbfeuvhehdvjjlbchtlenfgkv' => 'ERR Corrupt OTP',
);
my $socket = new IO::Socket::INET (
LocalHost => '127.0.0.1',
LocalPort => '80',
Proto => 'tcp',
Listen => 10,
Reuse => 1
) or die "Oops: $! \n";
while (1) {
my $clientsocket = $socket->accept();
my $clientdata = <$clientsocket>;
my $ret = "ERR Unknown yubikey";
if($clientdata =~ m/otp=([cbdefghijklnrtuv]+)/) {
my $otp = $1;
if($otps{$otp}) {
$ret = $otps{$otp};
}
}
print $clientsocket "\n$ret\n";
close $clientsocket;
}