Patch against gkrellm-2.3.0 to (optionally) bind gkrellmd to a specific interface
Martijn Ras <[email protected]>
| Newsgroups | gmane.comp.gnome.apps.gkrellm |
|---|---|
| Message-ID | <[email protected]> |
Heya Folks, I've attached a patch that adds the possibility to (optionally) bind gkrellmd to a specific interface. I like to be able to specify which network interface are bound by services that I run. Since gkrellmd does not yet offer that possibility and i had a little time to spare I implemented it. Hopefully it will be helpful to others as well. Mazzel, Martijn. _______________________________________________ Gkrellm mailing list [email protected] http://lists.jutley.org/cgi-bin/mailman/listinfo/gkrellm
gkrellm-bind-single-interface.patch
(text/plain, 3.6 KB)
diff -ru gkrellm-2.3.0-original/gkrellmd.1 gkrellm-2.3.0-martijn/gkrellmd.1
--- gkrellm-2.3.0-original/gkrellmd.1 2006-11-28 20:33:15.000000000 +0100
+++ gkrellm-2.3.0-martijn/gkrellmd.1 2007-10-04 18:36:31.000000000 +0200
@@ -15,7 +15,7 @@
.B \-u
|
.B \-\-update-hz
-N
+f
]
[
.B \-m
@@ -24,10 +24,16 @@
N
]
[
+.B \-A
+|
+.B \-\-address
+server_address
+]
+[
.B \-P
|
.B \-\-port
-N
+server_port
]
[
.B \-a
@@ -162,6 +168,11 @@
Sets the maximum number of simultaneous clients allowed to connect
to the server.
.TP
+.B \-A, \-\-address server_address
+Use
+.I server_address
+for the network connection.
+.TP
.B \-P, \-\-port server_port
Use
.I server_port
diff -ru gkrellm-2.3.0-original/server/gkrellmd.conf gkrellm-2.3.0-martijn/server/gkrellmd.conf
--- gkrellm-2.3.0-original/server/gkrellmd.conf 2006-11-28 20:34:37.000000000 +0100
+++ gkrellm-2.3.0-martijn/server/gkrellmd.conf 2007-10-04 00:59:46.000000000 +0200
@@ -10,6 +10,11 @@
#
max-clients 2
+# Specify a specific network interface to listen on for connections.
+# By default gkrellmd listens on all available network interfaces.
+#
+address 127.0.0.1
+
# Specify the port to listen on for connections.
#
port 19150
diff -ru gkrellm-2.3.0-original/server/gkrellmd-private.h gkrellm-2.3.0-martijn/server/gkrellmd-private.h
--- gkrellm-2.3.0-original/server/gkrellmd-private.h 2007-07-19 23:39:56.000000000 +0200
+++ gkrellm-2.3.0-martijn/server/gkrellmd-private.h 2007-10-04 00:43:31.000000000 +0200
@@ -102,6 +102,7 @@
gint *server_fd;
gint max_clients;
gint server_port;
+ gchar* server_address;
gint verbose;
time_t start_time;
time_t time_now;
diff -ru gkrellm-2.3.0-original/server/main.c gkrellm-2.3.0-martijn/server/main.c
--- gkrellm-2.3.0-original/server/main.c 2007-07-07 01:58:37.000000000 +0200
+++ gkrellm-2.3.0-martijn/server/main.c 2007-10-04 00:45:17.000000000 +0200
@@ -462,6 +462,8 @@
_GK.update_HZ = atoi(arg);
else if (!strcmp(config, "port") || !strcmp(config, "P"))
_GK.server_port = atoi(arg);
+ else if (!strcmp(config, "address") || !strcmp(config, "A"))
+ _GK.server_address = arg;
else if (!strcmp(config, "max-clients") || !strcmp(config, "m"))
_GK.max_clients = atoi(arg);
else if (!strcmp(config, "allow-host") || !strcmp(config, "a"))
@@ -636,6 +638,7 @@
printf(_("options:\n"));
printf(_(" -u, --update-hz F Monitor update frequency\n"));
printf(_(" -m, --max-clients N Number of simultaneous clients\n"));
+ printf(_(" -A, --address A Address of network interface to listen on\n"));
printf(_(" -P, --port P Server port to listen on\n"));
printf(_(" -a, --allow-host host Allow connections from specified hosts\n"));
printf(_(" -c, --clear-hosts Clears the current list of allowed hosts\n"));
@@ -737,7 +740,14 @@
hints.ai_flags = AI_PASSIVE;
hints.ai_family = af;
snprintf(portnumber, sizeof(portnumber), "%d", _GK.server_port);
- error = getaddrinfo(NULL, portnumber, &hints, &res);
+ if (strlen(_GK.server_address) == 0)
+ {
+ error = getaddrinfo(NULL, portnumber, &hints, &res);
+ }
+ else
+ {
+ error = getaddrinfo(_GK.server_address, portnumber, &hints, &res);
+ }
if (error)
{
fprintf(stderr, "gkrellmd %s\n", gai_strerror(error));
@@ -752,7 +762,14 @@
hints.ai_next = NULL;
hints.ai_addr = (struct sockaddr *) &sin;
sin.sin_family = PF_INET;
- sin.sin_addr.s_addr = INADDR_ANY;
+ if (strlen(_GK.server_address) == 0)
+ {
+ sin.sin_addr.s_addr = INADDR_ANY;
+ }
+ else
+ {
+ sin.sin_addr.s_addr = inet_addr(_GK.server_address);
+ }
sin.sin_port = htons(_GK.server_port);
res = &hints;
#endif