1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2024-11-29 00:24:13 +01:00
yubikey-val/travis/server.pl
Jean Paul Galea c8bf5216d2 Fix failing tests.
- bug introduced in 382cfc2ab5.

- travis perl server test should use port 8002 to simulate ksm server.
2015-08-12 10:50:08 +02:00

34 lines
729 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 => '8002',
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;
}