[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 Sun, Nov 16, 2003 at 07:37:40AM -0800, Raimar Falke wrote:
>
> <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.
For the records: this patch was applied.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"Sit, disk, sit. Good boy. Now spin up. Very good. Here's a netscape
cookie for you. Fetch me some data. Come on, you can do it. No, not that
data. Bad disk. Bad."
-- Calle Dybedahl, alt.sysadmin.recovery
? auth6q.diff
? bindip1.diff
? bindip2.diff
? cal5.diff
? cal6.diff.gz
? cm3.diff
? cm4.diff
? cma_reset1.diff
? cmabug.tar.bz2
? contact.gz
? diff_vor_linuxtag
? enable_splint1.diff
? enum-problems.gz
? enum_impr_range1.diff
? enum_improvement1.diff
? enum_terrain1.diff
? enum_tile_special_type1.diff
? err
? error
? fscope.cmd
? fscope.pl
? gen.py
? goto.gz
? goto_exec1.diff
? goto_fix1.diff
? goto_test.gz
? goto_test3.gz
? government_iterate.diff
? gtk2
? helicrash.diff
? lanannouncev1.diff
? lanannouncev3.diff
? leaks-gtk1
? leaks-gtk1.tar.bz2
? leaks-xaw
? leaks-xaw.tar.bz2
? lint1.diff
? moreintl3.diff
? moreintl4.diff
? quit_freeciv.diff
? rapture_cm.diff
? splint2.diff
? start.diff
? test.gz
? time1.diff
? unsigned-bitops.diff
? upgrade_msg1.diff
? upgrade_patch1.diff
? verbose.diff
? warnings.diff
? warnings_A_1.diff
? client/cmd.sh
? client/cmd2.sh
? client/cmd3.sh
? client/compile_sdl
? client/gtk1-times
? client/gtk2-times
? data/deluxe
? data/deluxe.tilespec
? data/theme
? data/theme.tar.gz
? data/zalt
Index: common/netintf.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/netintf.c,v
retrieving revision 1.17
diff -u -u -r1.17 netintf.c
--- common/netintf.c 2003/04/04 15:47:49 1.17
+++ common/netintf.c 2003/11/19 11:01:59
@@ -176,6 +176,11 @@
sock->sin_family = AF_INET;
sock->sin_port = htons(port);
+ if (!name) {
+ sock->sin_addr.s_addr = htonl(INADDR_ANY);
+ return TRUE;
+ }
+
#ifdef HAVE_INET_ATON
if (inet_aton(name, &sock->sin_addr) != 0) {
return TRUE;
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/19 11:02:00
@@ -89,6 +89,8 @@
showhelp = TRUE;
break;
}
+ } else if ((option = get_option("--bind", argv, &inx, argc))) {
+ srvarg.bind_addr = 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 --bind ADDR\tListen for clients on ADDR\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/19 11:02: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,21 @@
* Bind any local address for us and
* associate datagram socket with server.
*/
+ if (!net_lookup_service(srvarg.bind_addr, 0,
+ (struct sockaddr *) &bind_addr,
+ sizeof(bind_addr))) {
+ freelog(LOG_ERROR, _("Metaserver: bad address: [%s:%d]."),
+ srvarg.bind_addr, 0);
+ metaserver_failed();
+ }
+
+ /* set source IP */
+ 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/19 11:02:00
@@ -784,10 +784,13 @@
freelog(LOG_ERROR, "SO_REUSEADDR failed: %s", mystrerror(errno));
}
- 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 (!net_lookup_service
+ (srvarg.bind_addr, srvarg.port, (struct sockaddr *) &src,
+ sizeof(src))) {
+ freelog(LOG_ERROR, _("Server: bad address: [%s:%d]."),
+ srvarg.bind_addr, srvarg.port);
+ exit(EXIT_FAILURE);
+ }
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/19 11:02:01
@@ -162,6 +162,7 @@
sz_strlcpy(srvarg.metaserver_addr, DEFAULT_META_SERVER_ADDR);
srvarg.metaserver_port = DEFAULT_META_SERVER_PORT;
+ srvarg.bind_addr = 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/19 11:02:01
@@ -25,6 +25,8 @@
char metaserver_info_line[256];
char metaserver_addr[256];
unsigned short int metaserver_port;
+ /* address this server is to listen on (NULL => INADDR_ANY) */
+ char *bind_addr;
/* this server's listen port */
int port;
/* the log level */
|
|