-
Notifications
You must be signed in to change notification settings - Fork 9
/
director-test.pl
executable file
·109 lines (94 loc) · 3.03 KB
/
director-test.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env perl
# run also director-test-admin.sh
use IO::Socket::UNIX;
use Time::HiRes qw( usleep gettimeofday tv_interval );
use MIME::Base64;
use strict;
my $director_count = 4;
my $requests_per_sec = 10000;
my $total_num_users = 1000000;
# v2.2.17+ way of doing fast lookups without auth process:
my $authreply_socket = 1;
my @sockets;
sub socket_handshake {
my $socknum = $_[0];
my $socket = $sockets[$socknum];
my $socket_pid = $socknum.$$;
if ($authreply_socket) {
print $socket "VERSION\tdirector-authreply-client\t1\t1\n";
my $version_line = <$socket>;
die if $version_line !~ /^VERSION\tdirector-authreply-server\t1\t/;
return;
}
print $socket "VERSION\t1\t1\nCPID\t$socket_pid\n";
my $version_line = <$socket>;
die if $version_line !~ /^VERSION\t1\t/;
while (<$socket>) {
chomp;
if (/^SPID\t/) {
} elsif (/^CUID\t/) {
} elsif (/^COOKIE\t/) {
} elsif (/^MECH\t/) {
} elsif (/^DONE$/) {
last;
} else {
die "Unknown server input: $_";
}
}
print "$socknum handshaked\n";
}
sub send_request {
my ($socknum, $username) = @_;
my $socket = $sockets[$socknum];
my $resp = encode_base64("\0$username\0pass", "");