[cvslog] (2002-09-22 08:50:56 UTC) Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Sun Sep 22 03:51:01 CST 2002


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2002-09-22 08:50:56 UTC
Commited by: stdarg <stdarg at techmonkeys.org>

Modified files:
     lib/eggdrop/eggnet.c lib/eggdrop/eggnet.h lib/eggdrop/my_socket.c
     lib/eggdrop/my_socket.h lib/eggdrop/sockbuf.c
     lib/eggdrop/sockbuf.h modules/server/Makefile.am
     modules/server/binds.c modules/server/binds.h
     modules/server/scriptcmds.c modules/server/server.c
     modules/server/server.h src/scriptnet.c

Added files:
     modules/server/dcc.c modules/server/dcc.h

Log message:

* Added a command to initiate dcc chats

---------------------- diff included ----------------------
Index: eggdrop1.7/lib/eggdrop/eggnet.c
diff -u eggdrop1.7/lib/eggdrop/eggnet.c:1.1 eggdrop1.7/lib/eggdrop/eggnet.c:1.2
--- eggdrop1.7/lib/eggdrop/eggnet.c:1.1	Thu Sep 19 21:06:25 2002
+++ eggdrop1.7/lib/eggdrop/eggnet.c	Sun Sep 22 03:50:46 2002
@@ -52,7 +52,7 @@
 }
 
 /* Create a listening socket on a port. */
-int egg_server(const char *vip, int port)
+int egg_server(const char *vip, int port, int *real_port)
 {
 	int idx, sock, ntries;
 
@@ -60,7 +60,11 @@
 	do {
 		sock = socket_create(NULL, 0, vip, port+ntries, SOCKET_SERVER|SOCKET_TCP|SOCKET_NONBLOCK);
 		ntries++;
-	} while (sock < 0 && ntries < 20);
+	} while (sock < 0 && ntries < 20 && port);
+
+	if (sock < 0) return(sock);
+
+	if (real_port) socket_get_name(sock, NULL, real_port);
 
 	idx = sockbuf_new();
 	sockbuf_set_sock(idx, sock, SOCKBUF_SERVER);
@@ -84,12 +88,12 @@
 
 /* Open a listen port. If proxies/firewalls/vhosts are configured, it will
  * automatically use them. Returns an idx for the new socket. */
-int egg_listen(int port)
+int egg_listen(int port, int *real_port)
 {
 	int idx;
 
 	/* Proxy/firewall/vhost code goes here. */
-	idx = egg_server(NULL, port);
+	idx = egg_server(NULL, port, real_port);
 	return(idx);
 }
 
Index: eggdrop1.7/lib/eggdrop/eggnet.h
diff -u eggdrop1.7/lib/eggdrop/eggnet.h:1.1 eggdrop1.7/lib/eggdrop/eggnet.h:1.2
--- eggdrop1.7/lib/eggdrop/eggnet.h:1.1	Thu Sep 19 21:06:25 2002
+++ eggdrop1.7/lib/eggdrop/eggnet.h	Sun Sep 22 03:50:46 2002
@@ -2,9 +2,9 @@
 #define _EGGNET_H_
 
 int egg_iprintf(int idx, const char *format, ...);
-int egg_server(const char *vip, int port);
+int egg_server(const char *vip, int port, int *real_port);
 int egg_client(const char *ip, int port, const char *vip, int vport);
-int egg_listen(int port);
+int egg_listen(int port, int *real_port);
 int egg_connect(const char *host, int port, int timeout);
 int egg_ident_lookup(const char *ip, int their_port, int our_port, int timeout, int (*callback)(), void *client_data);
 int egg_dns_lookup(const char *host_or_ip, int timeout, int (*callback)(), void *client_data);
Index: eggdrop1.7/lib/eggdrop/my_socket.c
diff -u eggdrop1.7/lib/eggdrop/my_socket.c:1.2 eggdrop1.7/lib/eggdrop/my_socket.c:1.3
--- eggdrop1.7/lib/eggdrop/my_socket.c:1.2	Fri Sep 20 15:18:22 2002
+++ eggdrop1.7/lib/eggdrop/my_socket.c	Sun Sep 22 03:50:46 2002
@@ -38,14 +38,6 @@
 {
 	memset(name, 0, sizeof(*name));
 
-	if (!ipaddr) {
-		#ifdef DO_IPV6
-		ipaddr = "::";
-		#else
-		ipaddr = "0.0.0.0";
-		#endif
-	}
-
 	#ifdef DO_IPV6
 	if (inet_pton(AF_INET6, ipaddr, &name->u.ipv6.sin6_addr) > 0) {
 		name->len = sizeof(name->u.ipv6);
@@ -69,29 +61,67 @@
 	return(-1);
 }
 
+int socket_get_name(int sock, char **ip, int *port)
+{
+	sockname_t name;
+	int namelen;
+
+	if (ip) *ip = NULL;
+	if (port) *port = 0;
+
+	#ifdef DO_IPV4
+	namelen = sizeof(name.u.ipv4);
+	if (!getsockname(sock, &name.u.addr, &namelen) && namelen == sizeof(name.u.ipv4)) {
+		if (ip) {
+			*ip = (char *)malloc(32);
+			inet_ntop(AF_INET, &name.u.ipv4.sin_addr, *ip, 32);
+		}
+		if (port) *port = ntohs(name.u.ipv4.sin_port);
+		return(0);
+	}
+	#endif
+	#ifdef DO_IPV6
+	namelen = sizeof(name.u.ipv6);
+	if (!getsockname(sock, &name.u.addr, &namelen) && namelen == sizeof(name.u.ipv6)) {
+		if (ip) {
+			*ip = (char *)malloc(128);
+			inet_ntop(AF_INET6, &name.u.ipv6.sin6_addr, *ip, 128);
+		}
+		if (port) *port = ntohs(name.u.ipv6.sin6_port);
+		return(0);
+	}
+	#endif
+
+	return(-1);
+}
+
 int socket_get_peer_name(int sock, char **peer_ip, int *peer_port)
 {
 	sockname_t name;
 	int namelen;
 
-	*peer_ip = NULL;
-	*peer_port = 0;
+	if (peer_ip) *peer_ip = NULL;
+	if (peer_port) *peer_port = 0;
 
 	#ifdef DO_IPV4
 	namelen = sizeof(name.u.ipv4);
 	if (!getpeername(sock, &name.u.addr, &namelen) && namelen == sizeof(name.u.ipv4)) {
-		*peer_ip = (char *)malloc(32);
-		*peer_port = ntohs(name.u.ipv4.sin_port);
-		inet_ntop(AF_INET, &name.u.ipv4.sin_addr, *peer_ip, 32);
+		if (peer_ip) {
+			*peer_ip = (char *)malloc(32);
+			inet_ntop(AF_INET, &name.u.ipv4.sin_addr, *peer_ip, 32);
+		}
+		if (peer_port) *peer_port = ntohs(name.u.ipv4.sin_port);
 		return(0);
 	}
 	#endif
 	#ifdef DO_IPV6
 	namelen = sizeof(name.u.ipv6);
 	if (!getpeername(sock, &name.u.addr, &namelen) && namelen == sizeof(name.u.ipv6)) {
-		*peer_ip = (char *)malloc(128);
-		*peer_port = ntohs(name.u.ipv6.sin6_port);
-		inet_ntop(AF_INET6, &name.u.ipv6.sin6_addr, *peer_ip, 128);
+		if (peer_ip) {
+			*peer_ip = (char *)malloc(128);
+			inet_ntop(AF_INET6, &name.u.ipv6.sin6_addr, *peer_ip, 128);
+		}
+		if (peer_port) *peer_port = ntohs(name.u.ipv6.sin6_port);
 		return(0);
 	}
 	#endif
@@ -143,25 +173,31 @@
 /* -4: connect() failure */
 int socket_create(const char *dest_ip, int dest_port, const char *src_ip, int src_port, int flags)
 {
-	int sock, pfamily;
+	char *passive[] = {"::", "0.0.0.0"};
+	int sock = -1, pfamily, try;
 	sockname_t dest_name, src_name;
 
-	/* Resolve the ip addresses. */
-	socket_name(&dest_name, dest_ip, dest_port);
-	socket_name(&src_name, src_ip, src_port);
-
-	if (src_ip || src_port) flags |= SOCKET_BIND;
-
-	if (flags & SOCKET_CLIENT) pfamily = dest_name.family;
-	else if (flags & SOCKET_SERVER) pfamily = src_name.family;
-	else {
-		errno = EADDRNOTAVAIL;
-		return(-1);
-	}
-
-	/* Create the socket. */
-	if (flags & SOCKET_UDP) sock = socket(pfamily, SOCK_DGRAM, 0);
-	else sock = socket(pfamily, SOCK_STREAM, 0);
+	/* If no source ip address is given, try :: and 0.0.0.0 (passive). */
+	for (try = 0; try < 2; try++) {
+		/* Resolve the ip addresses. */
+		socket_name(&dest_name, dest_ip ? dest_ip : passive[try], dest_port);
+		socket_name(&src_name, src_ip ? src_ip : passive[try], src_port);
+
+		if (src_ip || src_port) flags |= SOCKET_BIND;
+
+		if (flags & SOCKET_CLIENT) pfamily = dest_name.family;
+		else if (flags & SOCKET_SERVER) pfamily = src_name.family;
+		else {
+			errno = EADDRNOTAVAIL;
+			return(-1);
+		}
+
+		/* Create the socket. */
+		if (flags & SOCKET_UDP) sock = socket(pfamily, SOCK_DGRAM, 0);
+		else sock = socket(pfamily, SOCK_STREAM, 0);
+
+		if (sock >= 0) break;
+	}
 
 	if (sock < 0) return(-2);
 
Index: eggdrop1.7/lib/eggdrop/my_socket.h
diff -u eggdrop1.7/lib/eggdrop/my_socket.h:1.1 eggdrop1.7/lib/eggdrop/my_socket.h:1.2
--- eggdrop1.7/lib/eggdrop/my_socket.h:1.1	Thu Sep 19 21:10:33 2002
+++ eggdrop1.7/lib/eggdrop/my_socket.h	Sun Sep 22 03:50:46 2002
@@ -11,6 +11,7 @@
 int socket_create(const char *dest_ip, int dest_port, const char *src_ip, int src_port, int flags);
 int socket_close(int sock);
 int socket_set_nonblock(int desc, int value);
+int socket_get_name(int sock, char **ip, int *port);
 int socket_get_peer_name(int sock, char **peer_ip, int *peer_port);
 int socket_get_error(int sock);
 int socket_accept(int sock, char **peer_ip, int *peer_port);
Index: eggdrop1.7/lib/eggdrop/sockbuf.c
diff -u eggdrop1.7/lib/eggdrop/sockbuf.c:1.2 eggdrop1.7/lib/eggdrop/sockbuf.c:1.3
--- eggdrop1.7/lib/eggdrop/sockbuf.c:1.2	Sat Sep 21 02:40:16 2002
+++ eggdrop1.7/lib/eggdrop/sockbuf.c	Sun Sep 22 03:50:46 2002
@@ -362,6 +362,12 @@
 	return(idx);
 }
 
+int sockbuf_get_sock(int idx)
+{
+	if (!sockbuf_isvalid(idx)) return(-1);
+	return(sockbufs[idx].sock);
+}
+
 int sockbuf_set_sock(int idx, int sock, int flags)
 {
 	int i;
Index: eggdrop1.7/lib/eggdrop/sockbuf.h
diff -u eggdrop1.7/lib/eggdrop/sockbuf.h:1.2 eggdrop1.7/lib/eggdrop/sockbuf.h:1.3
--- eggdrop1.7/lib/eggdrop/sockbuf.h:1.2	Sat Sep 21 02:40:16 2002
+++ eggdrop1.7/lib/eggdrop/sockbuf.h	Sun Sep 22 03:50:46 2002
@@ -67,6 +67,7 @@
 int sockbuf_close(int idx);
 int sockbuf_flush(int idx);
 int sockbuf_set_handler(int idx, sockbuf_handler_t *handler, void *client_data);
+int sockbuf_get_sock(int idx);
 int sockbuf_set_sock(int idx, int sock, int flags);
 int sockbuf_attach_listener(int fd);
 int sockbuf_detach_listener(int fd);
Index: eggdrop1.7/modules/server/Makefile.am
diff -u eggdrop1.7/modules/server/Makefile.am:1.6 eggdrop1.7/modules/server/Makefile.am:1.7
--- eggdrop1.7/modules/server/Makefile.am:1.6	Thu Sep 19 21:06:25 2002
+++ eggdrop1.7/modules/server/Makefile.am	Sun Sep 22 03:50:46 2002
@@ -1,10 +1,10 @@
-# $Id: Makefile.am,v 1.6 2002/09/20 02:06:25 stdarg Exp $
+# $Id: Makefile.am,v 1.7 2002/09/22 08:50:46 stdarg Exp $
 
 # FIXME: optionally allow a system wide install by ignoring the line below.
 pkglibdir		= $(exec_prefix)/modules
 
 pkglib_LTLIBRARIES	= server.la
-server_la_SOURCES	= server.c binds.c input.c output.c parse.c serverlist.c channels.c nicklist.c scriptcmds.c servsock.c dcc_commands.c
+server_la_SOURCES	= server.c binds.c input.c output.c parse.c serverlist.c channels.c nicklist.c scriptcmds.c servsock.c dcc_commands.c dcc.c
 server_la_LDFLAGS	= -module -avoid-version -no-undefined
 server_la_LIBADD	= @TCL_LIBS@ @LIBS@ \
 			$(top_builddir)/lib/eggdrop/libeggdrop.la
Index: eggdrop1.7/modules/server/binds.c
diff -u eggdrop1.7/modules/server/binds.c:1.1 eggdrop1.7/modules/server/binds.c:1.2
--- eggdrop1.7/modules/server/binds.c:1.1	Fri Sep 20 15:28:09 2002
+++ eggdrop1.7/modules/server/binds.c	Sun Sep 22 03:50:46 2002
@@ -15,7 +15,8 @@
 	*BT_pub = NULL,
 	*BT_pubm = NULL,
 	*BT_ctcp = NULL,
-	*BT_ctcr = NULL;
+	*BT_ctcr = NULL,
+	*BT_dcc_chat = NULL;
 
 void server_binds_destroy()
 {
@@ -29,6 +30,7 @@
 	bind_table_del(BT_pub);
 	bind_table_del(BT_ctcr);
 	bind_table_del(BT_ctcp);
+	bind_table_del(BT_dcc_chat);
 }
 
 void server_binds_init()
@@ -44,6 +46,7 @@
 	BT_pubm = bind_table_add("pubm", 5, "ssUss", MATCH_MASK, BIND_STACKABLE | BIND_USE_ATTR);
 	BT_ctcr = bind_table_add("ctcr", 6, "ssUsss", MATCH_MASK, BIND_USE_ATTR | BIND_STACKABLE);
 	BT_ctcp = bind_table_add("ctcp", 6, "ssUsss", MATCH_MASK, BIND_USE_ATTR | BIND_STACKABLE);
+	BT_dcc_chat = bind_table_add("dcc_chat", 4, "ssss", MATCH_MASK, BIND_USE_ATTR | BIND_STACKABLE);
 }
 
 void check_tcl_notc(char *nick, char *uhost, struct userrec *u, char *dest, char *arg)
Index: eggdrop1.7/modules/server/binds.h
diff -u eggdrop1.7/modules/server/binds.h:1.1 eggdrop1.7/modules/server/binds.h:1.2
--- eggdrop1.7/modules/server/binds.h:1.1	Fri Sep 20 15:18:22 2002
+++ eggdrop1.7/modules/server/binds.h	Sun Sep 22 03:50:46 2002
@@ -10,7 +10,8 @@
 	*BT_pub,
 	*BT_pubm,
 	*BT_ctcp,
-	*BT_ctcr;
+	*BT_ctcr,
+	*BT_dcc_chat;
 
 extern void server_binds_destroy();
 extern void server_binds_init();
Index: eggdrop1.7/modules/server/dcc.c
diff -u /dev/null eggdrop1.7/modules/server/dcc.c:1.1
--- /dev/null	Sun Sep 22 03:50:56 2002
+++ eggdrop1.7/modules/server/dcc.c	Sun Sep 22 03:50:46 2002
@@ -0,0 +1,179 @@
+/*
+ * dcc.c -- take care of dcc stuff
+ */
+
+#include "lib/eggdrop/module.h"
+#include "server.h"
+#include "output.h"
+#include "parse.h"
+#include "binds.h"
+#include <netinet/in.h>
+
+typedef struct dcc_chat {
+	int serv, idx;
+	int timer_id, timeout;
+} dcc_chat_t;
+
+static int dcc_chat_server_newclient(void *client_data, int idx, int newidx, const char *peer_ip, int peer_port);
+static int dcc_chat_server_delete(void *client_data, int idx);
+static int dcc_chat_client_delete(void *client_data, int idx);
+static int dcc_chat_timeout(void *client_data);
+
+static sockbuf_handler_t dcc_chat_server_handler = {
+	"DCC chat server",
+	NULL, NULL, dcc_chat_server_newclient,
+	NULL, NULL,
+	dcc_chat_server_delete
+};
+
+#define DCC_FILTER_LEVEL	(SOCKBUF_LEVEL_INTERNAL+1)
+static sockbuf_filter_t dcc_chat_client_filter = {
+	"DCC chat client", DCC_FILTER_LEVEL,
+	NULL, NULL, NULL,
+	NULL, NULL,
+	NULL, dcc_chat_client_delete
+};
+
+/* Starts a chat with the specified nick.
+ * If timeout is 0, the default timeout is used.
+ * If timeout is -1, there is no timeout.
+ * We don't make sure the nick is valid, so if it's not, you won't know until
+ * the chat times out. */
+int dcc_start_chat(const char *nick, int timeout)
+{
+	dcc_chat_t *chat;
+	int serv, idx, longip, port;
+	egg_timeval_t howlong;
+
+	/* Create a listening idx to accept the chat connection. */
+	serv = egg_listen(0, &port);
+	if (serv < 0) return(serv);
+	chat = calloc(1, sizeof(*chat));
+	sockbuf_set_handler(serv, &dcc_chat_server_handler, chat);
+
+	/* Create an empty sockbuf that will eventually be used for the
+	 * dcc chat (when they connect to us). */
+	idx = sockbuf_new();
+	sockbuf_attach_filter(idx, &dcc_chat_client_filter, chat);
+
+	chat->serv = serv;
+	chat->idx = idx;
+
+	/* See if they want the default timeout. */
+	if (!timeout) timeout = config.dcc_timeout;
+
+	if (timeout > 0) {
+		howlong.sec = timeout;
+		howlong.usec = 0;
+		chat->timer_id = timer_create_complex(&howlong, dcc_chat_timeout, chat, 0);
+	}
+
+	longip = htonl(getmyip());
+	printserv(SERVER_NORMAL, "PRIVMSG %s :%cDCC CHAT chat %u %d%c", nick, 1, longip, port, 1);
+	return(idx);
+}
+
+static int dcc_chat_server_newclient(void *client_data, int idx, int newidx, const char *peer_ip, int peer_port)
+{
+	int sock;
+	dcc_chat_t *chat = client_data;
+
+	putlog(LOG_MISC, "*", "dcc_chat_server: got new client (%s:%d)", peer_ip, peer_port);
+
+	sock = sockbuf_get_sock(newidx);
+	sockbuf_set_sock(newidx, -1, 0);
+	sockbuf_delete(newidx);
+
+	/* Give the waiting sockbuf the new socket and mark it as a client
+	 * so that it fires the on_connect event. */
+	sockbuf_set_sock(chat->idx, sock, SOCKBUF_CLIENT);
+
+	/* Delete the listening idx since it's not needed. */
+	chat->idx = -1;
+	sockbuf_delete(idx);
+	return(0);
+}
+
+static int dcc_chat_server_delete(void *client_data, int idx)
+{
+	dcc_chat_t *chat = client_data;
+
+	/* If the timer is still going, kill it. */
+	if (chat->timer_id != -1) {
+		timer_destroy(chat->timer_id);
+		chat->timer_id = -1;
+	}
+
+	/* If we're still waiting for the connection to come in, then send
+	 * an error to the associated client sock. */
+	if (chat->idx != -1) {
+		sockbuf_detach_filter(chat->idx, &dcc_chat_client_filter, NULL);
+		if (chat->timeout) {
+			sockbuf_on_eof(chat->idx, DCC_FILTER_LEVEL, -1, "DCC chat timed out");
+		}
+		else {
+			sockbuf_on_eof(chat->idx, DCC_FILTER_LEVEL, -1, "DCC chat listening socket unexpectedly closed");
+		}
+	}
+	free(chat);
+	return(0);
+}
+
+static int dcc_chat_client_delete(void *client_data, int idx)
+{
+	dcc_chat_t *chat = client_data;
+
+	/* If the listening idx is still open, close it down. */
+	if (chat->serv != -1) {
+		chat->idx = -1;
+		sockbuf_delete(chat->serv);
+	}
+	return(0);
+}
+
+static int dcc_chat_timeout(void *client_data)
+{
+	dcc_chat_t *chat = client_data;
+
+	chat->timeout = 1;
+	chat->timer_id = -1;
+	sockbuf_delete(chat->serv);
+	return(0);
+}
+
+static void got_chat(char *nick, char *uhost, user_t *u, char *text)
+{
+	char type[256], ip[256], port[32];
+	int nport;
+
+	sscanf(text, "%255s %255s %31s", type, ip, port);
+
+	/* Check if the ip is 'new-style' (dotted decimal or ipv6). If not,
+	 * it's the old-style long ip. */
+	if (!strchr(ip, '.') && !strchr(ip, ':')) {
+		int longip;
+		longip = atoi(ip);
+		sprintf(ip, "%d.%d.%d.%d", longip & 255, (longip >> 8) & 255, (longip >> 16) & 255, (longip >> 24) & 255);
+	}
+
+	nport = atoi(port);
+
+	check_bind(BT_dcc_chat, nick, NULL, nick, uhost, u, type, ip, nport);
+}
+
+/* PRIVMSG ((target) :^ADCC CHAT ((type) ((longip) ((port)^A */
+static int got_dcc(char *nick, char *uhost, struct userrec *u, char *cmd, char *text)
+{
+	if (!strncasecmp(text, "chat ", 5)) {
+		got_chat(nick, uhost, u, text+5);
+	}
+	else if (!strncasecmp(text, "send ", 5)) {
+		//got_send(nick, uhost, u, text+5);
+	}
+	return(0);
+}
+
+cmd_t my_ctcp_binds[] = {
+	{"DCC", "", (Function) got_dcc, NULL},
+	{NULL, NULL, NULL, NULL}
+};
Index: eggdrop1.7/modules/server/dcc.h
diff -u /dev/null eggdrop1.7/modules/server/dcc.h:1.1
--- /dev/null	Sun Sep 22 03:50:56 2002
+++ eggdrop1.7/modules/server/dcc.h	Sun Sep 22 03:50:46 2002
@@ -0,0 +1,6 @@
+#ifndef _SERVER_DCC_H_
+#define _SERVER_DCC_H_
+
+int dcc_start_chat(const char *nick, int timeout);
+
+#endif
Index: eggdrop1.7/modules/server/scriptcmds.c
diff -u eggdrop1.7/modules/server/scriptcmds.c:1.11 eggdrop1.7/modules/server/scriptcmds.c:1.12
--- eggdrop1.7/modules/server/scriptcmds.c:1.11	Sat Sep 21 02:40:16 2002
+++ eggdrop1.7/modules/server/scriptcmds.c	Sun Sep 22 03:50:46 2002
@@ -22,7 +22,7 @@
 
 /* FIXME: #include mess
 #ifndef lint
-static const char rcsid[] = "$Id: scriptcmds.c,v 1.11 2002/09/21 07:40:16 stdarg Exp $";
+static const char rcsid[] = "$Id: scriptcmds.c,v 1.12 2002/09/22 08:50:46 stdarg Exp $";
 #endif
 */
 
@@ -33,6 +33,7 @@
 #include "nicklist.h"
 #include "output.h"
 #include "servsock.h"
+#include "dcc.h"
 
 static int script_isbotnick (char *nick);
 static int script_putserv(char *queue, char *next, char *text);
@@ -62,6 +63,7 @@
 	{"", "nick_add", nick_add, NULL, 1, "s", "nick", SCRIPT_INTEGER, 0},
 	{"", "nick_del", nick_del, NULL, 1, "i", "nick-num", SCRIPT_INTEGER, 0},
 	{"", "nick_clear", nick_clear, NULL, 0, "", "", SCRIPT_INTEGER, 0},
+	{"", "dcc_chat", dcc_start_chat, NULL, 1, "si", "nick ?timeout?", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},
         {0}
 };
 
Index: eggdrop1.7/modules/server/server.c
diff -u eggdrop1.7/modules/server/server.c:1.36 eggdrop1.7/modules/server/server.c:1.37
--- eggdrop1.7/modules/server/server.c:1.36	Thu Sep 19 21:06:25 2002
+++ eggdrop1.7/modules/server/server.c	Sun Sep 22 03:50:46 2002
@@ -20,6 +20,7 @@
 	10,	/* cycle delay */
 	6667,	/* default port */
 	30,	/* ping timeout */
+	30,	/* dcc timeout */
 	NULL,	/* user */
 	NULL,	/* real name */
 };
@@ -128,6 +129,8 @@
 
 	/* Let's wait for the new config system before we redo all this mess. */
 	memcpy(&config, &default_config, sizeof(config));
+	config.user = strdup("user");
+	config.realname = strdup("real name");
 
 	memset(&current_server, 0, sizeof(current_server));
 	current_server.idx = -1;
Index: eggdrop1.7/modules/server/server.h
diff -u eggdrop1.7/modules/server/server.h:1.8 eggdrop1.7/modules/server/server.h:1.9
--- eggdrop1.7/modules/server/server.h:1.8	Thu Sep 19 21:06:25 2002
+++ eggdrop1.7/modules/server/server.h	Sun Sep 22 03:50:46 2002
@@ -11,6 +11,7 @@
 	int cycle_delay;
 	int default_port;
 	int ping_timeout;
+	int dcc_timeout;
 	char *user;
 	char *realname;
 } server_config_t;
Index: eggdrop1.7/src/scriptnet.c
diff -u eggdrop1.7/src/scriptnet.c:1.1 eggdrop1.7/src/scriptnet.c:1.2
--- eggdrop1.7/src/scriptnet.c:1.1	Sat Sep 21 02:40:16 2002
+++ eggdrop1.7/src/scriptnet.c	Sun Sep 22 03:50:46 2002
@@ -145,12 +145,18 @@
 
 static int script_net_handler(int idx, const char *event, script_callback_t *callback)
 {
-	script_net_info_t *info = script_net_info_lookup(idx);
+	script_net_info_t *info;
 	script_callback_t **replace = NULL;
 	const char *newsyntax;
 
-	/* Not a script-controlled idx. */
-	if (!info) return(-1);
+	/* See if it's already script-controlled. */
+	info = script_net_info_lookup(idx);
+	if (!info) {
+		/* Nope, take it over. */
+		script_net_takeover(idx);
+		info = script_net_info_lookup(idx);
+		if (!info) return(-1);
+	}
 
 	if (!strcasecmp(event, "connect")) {
 		replace = &info->on_connect;
----------------------- End of diff -----------------------



More information about the Changes mailing list