Просмотр исходного кода

Fix tools/config.pl

Add current path to @inc
Add more support for public_ip / private_ip.
Add pincode support
lighta 7 лет назад
Родитель
Сommit
03da2f6854
1 измененных файлов с 26 добавлено и 4 удалено
  1. 26 4
      tools/config.pl

+ 26 - 4
tools/config.pl

@@ -3,7 +3,7 @@
 # by lighta
 # TODO:
 # - Don't always override import/file, sed grep ?
-
+use lib '.';
 use File::Basename;
 use DBI;
 use DBD::mysql;
@@ -13,15 +13,19 @@ use Getopt::Long;
 use Net::Ping;
 use strict;
 use rA_Common;
+use LWP::Simple;
 
 use constant {
     SERV_UID => "Serv_userid",
     SERV_PW => "Serv_userpass",
+    LOGIN_PRIV_IP => "login_priv_ip",
+	CHAR_PRIV_IP => "char_priv_ip",
     SERV_WAN_IP => "Serv_wan_ip",
     MAP_PORT => "Map_port",
     CHAR_PORT => "Char_port",
     LOGIN_PORT => "Login_port",
     MD5_ENABLE => "enable_MD5",
+    PINCODE_ENABLE => "enable_pincode",
     SQL_HOST => "SQL_host",
     SQL_PORT => "SQL_port",
     SQL_UID => "SQL_userid",
@@ -87,13 +91,17 @@ sub Main {
     chdir $dir; #put ourself like was called in tools
     print "Running rAthena's configuration tool...\n";
     #default conf
+    my $pubip = GetPublicIP();
     my %hDefConf = (    SERV_UID => "s1",
 			SERV_PW => "p1",
-			SERV_WAN_IP => "localhost",
+			SERV_WAN_IP => $pubip || "localhost",
+			LOGIN_PRIV_IP => "localhost",
+			CHAR_PRIV_IP => "localhost",
 			MAP_PORT => "5121",
 			CHAR_PORT => "6121",
 			LOGIN_PORT => "6900",
 			MD5_ENABLE => "yes",
+			PINCODE_ENABLE => "no",
 			SQL_HOST => "localhost",
 			SQL_PORT => "3306",
 			SQL_UID => "ragnarok",
@@ -101,6 +109,7 @@ sub Main {
 			SQL_MAIN_DB => "ragnarok",
 			SQL_LOG_DB => ,"ragnarok",
 			);
+			
 
 	my $sBasedir = getcwd; #for setupdb
 	if($sTarget =~ /All|Inst/i){ InstallSoft(); }
@@ -173,6 +182,15 @@ sub EnableCoredump {
 	}
 }
 
+sub GetPublicIP {
+	print "\n== Resolving Public IP_addr";
+	my $content = get("http://checkip.dyndns.org");
+	$content =~ s/.*Current IP Address: ([\d.]+).*/$1/;
+	$content =~ s/\r|\n//gm;
+	print "\n found = $content ==\n";
+	return $content;
+}
+
 sub GetOS {
 	#yes we could $^0 or uname -r but $^0 only give perl binary build OS and uname hmm...
 	open PIPE,"lsb_release -i  |" or die $!;
@@ -297,7 +315,8 @@ sub ApplyMapConf { my ($rhUserConf,$sCurfile) = @_;
     print FILE "passwd: " . $$rhUserConf{SERV_PW}."\n\n";
 
     print FILE "map_ip: " . $$rhUserConf{SERV_WAN_IP}."\n";
-    print FILE "map_port: " . $$rhUserConf{MAP_PORT}."\n";
+    print FILE "map_port: " . $$rhUserConf{MAP_PORT}."\n";    
+    print FILE "char_ip: " . $$rhUserConf{CHAR_PRIV_IP}."\n";
     print FILE "char_port: " . $$rhUserConf{CHAR_PORT}."\n";
 }
 
@@ -305,10 +324,13 @@ sub ApplyCharConf { my ($rhUserConf,$sCurfile) = @_;
     open FILE, "> $sCurfile" || die "Couldn't open file '$sCurfile'.\n";
     print FILE "userid: " . $$rhUserConf{SERV_UID}."\n";
     print FILE "passwd: " . $$rhUserConf{SERV_PW}."\n\n";
-
+	
     print FILE "char_ip: " . $$rhUserConf{SERV_WAN_IP}."\n";
     print FILE "char_port: " . $$rhUserConf{CHAR_PORT}."\n";
+    print FILE "login_ip: " . $$rhUserConf{LOGIN_PRIV_IP}."\n";
     print FILE "login_port: " . $$rhUserConf{LOGIN_PORT}."\n";
+    
+    print FILE "pincode_enabled: " . $$rhUserConf{PINCODE_ENABLE}."\n";
 }
 
 sub ApplyLoginConf { my ($rhUserConf,$sCurfile) = @_;