<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40755 >

 Server can have several dns names, and sometimes you want to
communicate some other than one returned by hostname() to metaserver.
Attached patch adds commandline parameter to set used server name
manually.
 Since this can also work around some dns problems some users are
reporting, I plan to commit this to S2_1 too.


 - ML

diff -Nurd -X.diff_ignore freeciv/server/civserver.c freeciv/server/civserver.c
--- freeciv/server/civserver.c	2008-10-27 22:28:21.000000000 +0200
+++ freeciv/server/civserver.c	2009-04-07 20:58:17.000000000 +0300
@@ -143,13 +143,17 @@
       fc_fprintf(stderr, _("Warning: the %s option is obsolete.  "
 			   "Use -m to enable the metaserver.\n"), argv[inx]);
       showhelp = TRUE;
-    } else if (is_option("--meta", argv[inx]))
+    } else if (is_option("--meta", argv[inx])) {
       srvarg.metaserver_no_send = FALSE;
-    else if ((option = get_option_malloc("--Metaserver",
+    } else if ((option = get_option_malloc("--Metaserver",
 					 argv, &inx, argc))) {
       sz_strlcpy(srvarg.metaserver_addr, option);
       free(option);
       srvarg.metaserver_no_send = FALSE;      /* --Metaserver implies --meta */
+    } else if ((option = get_option_malloc("--identity",
+					   argv, &inx, argc))) {
+      sz_strlcpy(srvarg.metaserver_name, option);
+      free(option);
     } else if ((option = get_option_malloc("--port", argv, &inx, argc))) {
       if (sscanf(option, "%d", &srvarg.port) != 1) {
 	showhelp = TRUE;
@@ -227,7 +231,7 @@
   if (showhelp) {
     fc_fprintf(stderr,
 	       _("Usage: %s [option ...]\nValid options are:\n"), argv[0]);
-    fc_fprintf(stderr, _("  -A  --announce PROTO\tAnnounce game in LAN using protocol PROTO (IPv4/IPv6/none)\n"));
+    fc_fprintf(stderr, _("  -A  --Announce PROTO\tAnnounce game in LAN using protocol PROTO (IPv4/IPv6/none)\n"));
 #ifdef HAVE_AUTH
     fc_fprintf(stderr, _("  -a  --auth FILE\tEnable server authentication "
                          "with configuration from FILE.\n"));
@@ -247,6 +251,7 @@
     fc_fprintf(stderr, _("  -f, --file FILE\tLoad saved game FILE\n"));
     fc_fprintf(stderr,
 	       _("  -h, --help\t\tPrint a summary of the options\n"));
+   fc_fprintf(stderr, _("  -i, --identity ADDR\tBe known as ADDR at metaserver\n"));
     fc_fprintf(stderr, _("  -l, --log FILE\tUse FILE as logfile\n"));
     fc_fprintf(stderr, _("  -m, --meta\t\tNotify metaserver and "
 			 "send server's info\n"));
diff -Nurd -X.diff_ignore freeciv/server/meta.c freeciv/server/meta.c
--- freeciv/server/meta.c	2008-10-27 22:28:21.000000000 +0200
+++ freeciv/server/meta.c	2009-04-07 20:46:10.000000000 +0300
@@ -245,7 +245,9 @@
   }
 
   /* get hostname */
-  if (my_gethostname(host, sizeof(host)) != 0) {
+  if (srvarg.metaserver_name[0] != '\0') {
+    sz_strlcpy(host, srvarg.metaserver_name);
+  } else if (my_gethostname(host, sizeof(host)) != 0) {
     sz_strlcpy(host, "unknown");
   }
 
diff -Nurd -X.diff_ignore freeciv/server/srv_main.c freeciv/server/srv_main.c
--- freeciv/server/srv_main.c	2009-03-19 19:48:17.000000000 +0200
+++ freeciv/server/srv_main.c	2009-04-07 20:44:43.000000000 +0300
@@ -167,6 +167,7 @@
 
   srvarg.metaserver_no_send = DEFAULT_META_SERVER_NO_SEND;
   sz_strlcpy(srvarg.metaserver_addr, DEFAULT_META_SERVER_ADDR);
+  srvarg.metaserver_name[0] = '\0';
 
   srvarg.bind_addr = NULL;
   srvarg.port = DEFAULT_SOCK_PORT;
diff -Nurd -X.diff_ignore freeciv/server/srv_main.h freeciv/server/srv_main.h
--- freeciv/server/srv_main.h	2008-10-27 22:28:21.000000000 +0200
+++ freeciv/server/srv_main.h	2009-04-07 20:41:28.000000000 +0300
@@ -25,6 +25,7 @@
   /* metaserver information */
   bool metaserver_no_send;
   char metaserver_addr[256];
+  char metaserver_name[256];
   unsigned short int metaserver_port;
   /* address this server is to listen on (NULL => INADDR_ANY) */
   char *bind_addr;
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to