diff options
author | Valaris <Valaris@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-01-29 16:10:48 +0000 |
---|---|---|
committer | Valaris <Valaris@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-01-29 16:10:48 +0000 |
commit | 620e60eebce2c1f35c5c9a82f6ca365b316587f5 (patch) | |
tree | 38a39e0415f419d9a49ae456ed0e26654c23d559 /tools/checkversion | |
parent | a2675f07d7da22a7c6ae11f545bf8f671e785a82 (diff) | |
download | hercules-620e60eebce2c1f35c5c9a82f6ca365b316587f5.tar.gz hercules-620e60eebce2c1f35c5c9a82f6ca365b316587f5.tar.bz2 hercules-620e60eebce2c1f35c5c9a82f6ca365b316587f5.tar.xz hercules-620e60eebce2c1f35c5c9a82f6ca365b316587f5.zip |
AS OF SVN REV. 5901, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. EVERYTHING ELSE
GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5094 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'tools/checkversion')
-rw-r--r-- | tools/checkversion | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/tools/checkversion b/tools/checkversion new file mode 100644 index 000000000..135165236 --- /dev/null +++ b/tools/checkversion @@ -0,0 +1,85 @@ +#!/usr/bin/perl -w
+
+##########################################################################
+# INFORMATION TOOL ABOUT THE SERVERS VERSION OF ATHENA
+#
+# By connection on a server, this software display the version of the
+# designed server.
+#-------------------------------------------------------------------------
+# Usages:
+# ./checkversion IP:port
+# ./checkversion IP port
+# perl checkversion IP:port
+# perl checkversion IP port
+#
+# note: default port: 6900
+#
+# When successfull, the software return the value 0.
+#
+##########################################################################
+
+#------------------------- start of configuration ------------------------
+
+$connecttimeout = 10; # Connection Timeout (in seconds)
+
+#-------------------------- End of configuration -------------------------
+
+use IO::Socket;
+
+unless($ARGV[0]) {
+ print "USAGE: $0 server_ip:port\n";
+ exit(1);
+}
+
+$server = $ARGV[0];
+$port = $ARGV[1];
+$port = $1 if ($server =~ s/:(\d+)//);
+$port ||= 6900;
+
+# Connection to the server
+my($so,$er) = ();
+eval{
+ $so = IO::Socket::INET->new(
+ PeerAddr=> $server,
+ PeerPort=> $port,
+ Proto => "tcp",
+ Timeout => $connecttimeout) or $er = 1;
+};
+
+if($er || $@) {
+ print "Can't not connect to server [$server:$port] !\n";
+ exit(2);
+}
+
+# Request for the server version
+print $so pack("v",30000); # 0x7530
+$so->flush();
+
+# Receiving of the answer of the server
+if (read($so,$buf,10) < 10) {
+ print "Invalid answer. It isn't an athena server or it is a too old version.\n";
+ exit(5);
+}
+
+# Sending end of connection to the server
+print $so pack("v",30002); # 0x7532
+$so->flush();
+
+# Analyse of the answer
+my($ret,$maver,$miver,$rev,$dev,$mod,$type,$mdver) = unpack("v c6 v",$buf);
+
+if ($ret != 30001) { # 0x7531
+ print "Invalid answer. It isn't an athena server or it is a too old version.\n";
+ exit(6);
+}
+
+my(@stype) = ();
+foreach $i(0..3) {
+ push @stype,(("login","char","inter","map")[$i]) if( $type & (1<<$i) );
+}
+print " ".join("/",@stype)." server [$server:$port].\n";
+printf " Athena version %s-%d.%d", ("stable","dev")[$dev], $maver,$miver;
+printf " revision %d",$rev if $rev;
+printf "%s%d\n",("","-mod")[$mod],$mdver;
+
+exit(0);
|