1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2024-12-01 15:24:16 +01:00
yubikey-val/travis/server.pl

34 lines
729 B
Perl
Raw Normal View History

2013-11-08 10:32:12 +01:00
#!/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 => '8002',
2013-11-08 10:32:12 +01:00
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;
}