[Freeciv-Dev] Re: (PR#6848) Re: [Freeciv] connection restriction
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=6848 >
On Thu, Nov 13, 2003 at 02:34:33AM -0800, Christian Knoke wrote:
>
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=6848 >
>
> On Thu, Nov 13, 2003 at 12:44:31AM +0100, mail man wrote:
> > Dear freeciv dev. & maintainers,
> > I enjoy playing Your game very much. But now, I would like to ask how t=
> > o disable all internet connections to the civserver, so that only my ci=
> > vclient can play (with AI's of course)? Thank you.
>
> We should implement that.
This was already done:
Date: Sun, 5 Jan 2003 18:03:08 +0100
From: Patrick Duchstein <duchstei@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
I have updated the patch. Can you please test.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"Many of my assistants were fans of Tolkien, who wrote 'Lord of the Rings'
and a number of other children's stories for adults. The first character
alphabet that was programmed for my plotter was Elvish rather than Latin."
-- from SAIs "life as a computer for a quarter of a century"
Index: server/civserver.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/civserver.c,v
retrieving revision 1.215
diff -u -u -r1.215 civserver.c
--- server/civserver.c 2003/05/05 12:11:13 1.215
+++ server/civserver.c 2003/11/16 15:36:00
@@ -89,6 +89,8 @@
showhelp = TRUE;
break;
}
+ } else if ((option = get_option("--bindip", argv, &inx, argc))) {
+ srvarg.ip = option;
} else if ((option = get_option("--read", argv, &inx, argc)))
srvarg.script_filename = option;
else if ((option = get_option("--quitidle", argv, &inx, argc))) {
@@ -125,6 +127,7 @@
if (showhelp) {
fprintf(stderr, _("Usage: %s [option ...]\nValid options are:\n"),
argv[0]);
+ fprintf(stderr, _(" -b --bindip IP\tListen for clients on ip IP\n"));
#ifdef DEBUG
fprintf(stderr, _(" -d, --debug NUM\tSet debug log level (0 to 4,"
" or 4:file1,min,max:...)\n"));
Index: server/meta.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/meta.c,v
retrieving revision 1.57
diff -u -u -r1.57 meta.c
--- server/meta.c 2003/04/04 15:47:50 1.57
+++ server/meta.c 2003/11/16 15:36:00
@@ -50,6 +50,9 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
#ifdef HAVE_WINSOCK
#include <winsock.h>
#endif
@@ -178,6 +181,7 @@
{
char *metaname = srvarg.metaserver_addr;
int metaport;
+ struct sockaddr_in bind_addr;
/*
* Fill in the structure "meta_addr" with the address of the
@@ -208,6 +212,17 @@
* Bind any local address for us and
* associate datagram socket with server.
*/
+ /* set source IP */
+ if (srvarg.ip != NULL) {
+ inet_aton(srvarg.ip, &bind_addr.sin_addr); /* exception has been catched
before */
+ bind_addr.sin_family = AF_INET;
+ bind_addr.sin_port = 0;
+ if (bind(sockfd, (struct sockaddr *) &bind_addr, sizeof(bind_addr)) == -1)
{
+ freelog(LOG_ERROR, "Metaserver: bind failed: %s", mystrerror(errno));
+ metaserver_failed();
+ return;
+ }
+ }
/* no, this is not weird, see man connect(2) --vasc */
if (connect(sockfd, (struct sockaddr *) &meta_addr, sizeof(meta_addr))==-1) {
freelog(LOG_ERROR, "Metaserver: connect failed: %s", mystrerror(errno));
Index: server/sernet.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/sernet.c,v
retrieving revision 1.108
diff -u -u -r1.108 sernet.c
--- server/sernet.c 2003/07/24 17:42:27 1.108
+++ server/sernet.c 2003/11/16 15:36:00
@@ -786,8 +786,16 @@
memset(&src, 0, sizeof(src));
src.sin_family = AF_INET;
- src.sin_addr.s_addr = htonl(INADDR_ANY);
src.sin_port = htons(srvarg.port);
+
+ if (srvarg.ip != NULL) {
+ if (inet_aton(srvarg.ip, &src.sin_addr) == 0) {
+ freelog(LOG_FATAL, "inet_aton failed: address not valid");
+ exit(EXIT_FAILURE);
+ }
+ } else {
+ src.sin_addr.s_addr = htonl(INADDR_ANY);
+ }
if(bind(sock, (struct sockaddr *) &src, sizeof (src)) == -1) {
freelog(LOG_FATAL, "bind failed: %s", mystrerror(errno));
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.144
diff -u -u -r1.144 srv_main.c
--- server/srv_main.c 2003/11/10 20:33:58 1.144
+++ server/srv_main.c 2003/11/16 15:36:02
@@ -162,6 +162,7 @@
sz_strlcpy(srvarg.metaserver_addr, DEFAULT_META_SERVER_ADDR);
srvarg.metaserver_port = DEFAULT_META_SERVER_PORT;
+ srvarg.ip = NULL;
srvarg.port = DEFAULT_SOCK_PORT;
srvarg.loglevel = LOG_NORMAL;
Index: server/srv_main.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.h,v
retrieving revision 1.15
diff -u -u -r1.15 srv_main.h
--- server/srv_main.h 2003/03/24 22:20:58 1.15
+++ server/srv_main.h 2003/11/16 15:36:02
@@ -25,6 +25,8 @@
char metaserver_info_line[256];
char metaserver_addr[256];
unsigned short int metaserver_port;
+ /* this server's listen ip */
+ unsigned char *ip;
/* this server's listen port */
int port;
/* the log level */
|
|