THRIFT-3402: add unix socket support to perl
Client: Perl
Patch: James E. King, III
This closes #670
diff --git a/test/perl/TestClient.pl b/test/perl/TestClient.pl
index 9d4aab2..7ec32bf 100755
--- a/test/perl/TestClient.pl
+++ b/test/perl/TestClient.pl
@@ -35,6 +35,7 @@
use Thrift::FramedTransport;
use Thrift::SSLSocket;
use Thrift::Socket;
+use Thrift::UnixSocket;
use ThriftTest::ThriftTest;
use ThriftTest::Types;
@@ -48,6 +49,7 @@
Options: (default)
--cert Certificate to use.
Required if using --ssl.
+ --domain-socket <file> Use a unix domain socket.
--help Show usage.
--port <portnum> 9090 Port to use.
--protocol {binary} binary Protocol to use.
@@ -65,6 +67,7 @@
GetOptions(\%opts, qw (
cert=s
+ domain-socket=s
help
host=s
port=i
@@ -84,7 +87,9 @@
}
my $socket = undef;
-if ($opts{ssl}) {
+if ($opts{"domain-socket"}) {
+ $socket = new Thrift::UnixSocket($opts{"domain-socket"});
+} elsif ($opts{ssl}) {
$socket = new Thrift::SSLSocket($opts{host}, $opts{port});
} else {
$socket = new Thrift::Socket($opts{host}, $opts{port});
diff --git a/test/perl/TestServer.pl b/test/perl/TestServer.pl
index 5bfa640..4e0cc79 100644
--- a/test/perl/TestServer.pl
+++ b/test/perl/TestServer.pl
@@ -36,6 +36,7 @@
use Thrift::SSLServerSocket;
use Thrift::ServerSocket;
use Thrift::Server;
+use Thrift::UnixServerSocket;
use ThriftTest::ThriftTest;
use ThriftTest::Types;
@@ -50,6 +51,7 @@
--ca Certificate authority file (optional).
--cert Certificate file.
Required if using --ssl.
+ --domain-socket <file> Use a unix domain socket.
--help Show usage.
--key Private key file for certificate.
Required if using --ssl and private key is
@@ -71,6 +73,7 @@
GetOptions(\%opts, qw (
ca=s
cert=s
+ domain-socket=s
help
host=s
key=s
@@ -93,7 +96,10 @@
my $handler = new ThriftTestHandler();
my $processor = new ThriftTest::ThriftTestProcessor($handler);
my $serversocket;
-if ($opts{ssl}) {
+if ($opts{"domain-socket"}) {
+ unlink($opts{"domain-socket"});
+ $serversocket = new Thrift::UnixServerSocket($opts{"domain-socket"});
+} elsif ($opts{ssl}) {
$serversocket = new Thrift::SSLServerSocket(\%opts);
} else {
$serversocket = new Thrift::ServerSocket(\%opts);
@@ -119,8 +125,12 @@
if ($opts{ssl}) {
$ssltag = "(SSL)";
}
+my $listening_on = "$opts{port} $ssltag";
+if ($opts{"domain-socket"}) {
+ $listening_on = $opts{"domain-socket"};
+}
my $server = new Thrift::SimpleServer($processor, $serversocket, $transport, $protocol);
-print "Starting \"simple\" server ($opts{transport}/$opts{protocol}) listen on: $opts{port} $ssltag\n";
+print "Starting \"simple\" server ($opts{transport}/$opts{protocol}) listen on: $listening_on\n";
$server->serve();
###
diff --git a/test/tests.json b/test/tests.json
index aeff933..0c35df2 100644
--- a/test/tests.json
+++ b/test/tests.json
@@ -126,8 +126,8 @@
"framed"
],
"sockets": [
- "ip-ssl",
- "ip"
+ "ip",
+ "ip-ssl"
],
"protocols": [
"compact",
@@ -190,8 +190,8 @@
"framed"
],
"sockets": [
- "ip-ssl",
- "ip"
+ "ip",
+ "ip-ssl"
],
"protocols": [
"compact",
@@ -221,8 +221,8 @@
"framed"
],
"sockets": [
- "ip-ssl",
"ip",
+ "ip-ssl",
"domain"
],
"protocols": [
@@ -307,7 +307,8 @@
],
"sockets": [
"ip",
- "ip-ssl"
+ "ip-ssl",
+ "domain"
],
"protocols": [
"binary"