Ver Fonte

* Removed myip[] myip6[] hostname[] hostname6[]
Now using conf.bot->ip/ip6/host/hos6
* Forgot to fill origbotname if (localhub) in conf.c


svn: 688

Bryan Drewery há 22 anos atrás
pai
commit
4d7d826f8f
10 ficheiros alterados com 42 adições e 46 exclusões
  1. 2 2
      src/chanprog.c
  2. 5 3
      src/conf.c
  3. 0 1
      src/main.c
  4. 3 3
      src/mod/channels.mod/cmdschan.c
  5. 3 3
      src/mod/channels.mod/userchan.c
  6. 4 4
      src/mod/module.h
  7. 3 2
      src/mod/server.mod/server.c
  8. 7 7
      src/modules.c
  9. 14 19
      src/net.c
  10. 1 2
      src/tcl.c

+ 2 - 2
src/chanprog.c

@@ -30,7 +30,7 @@
 #include "modules.h"
 
 extern struct userrec	*userlist;
-extern char		 ver[], firewall[], myip[], 
+extern char		 ver[], firewall[],  
 			 motdfile[], userfile[], tempdir[],
 			 owner[], 
                          botuser[], *owners, *hubs;
@@ -577,7 +577,7 @@ void chanprog()
     conf.bot->u = get_user_by_handle(userlist, conf.bot->nick);
     bi = malloc(sizeof(struct bot_addr));
 
-    bi->address = strdup(myip);
+    bi->address = strdup(conf.bot->ip);
     /* bi->telnet_port = atoi(buf) ? atoi(buf) : 3333; */
     bi->telnet_port = bi->relay_port = 3333;
 #ifdef HUB

+ 5 - 3
src/conf.c

@@ -18,7 +18,7 @@
 #include <sys/types.h>
 
 extern char             origbotname[], tempdir[],
-                        userfile[], myip[], myip6[], natip[], hostname[], hostname6[];
+                        userfile[], natip[];
 extern int              localhub;
 extern uid_t		myuid;
 extern conf_t           conf;
@@ -31,6 +31,7 @@ void init_conf() {
   conffile.bots = (conf_bot *) calloc(1, sizeof(conf_bot));
   conffile.bots->nick = NULL;
   conffile.bots->next = NULL;
+  conffile.bot = NULL;
 
   conffile.comments = calloc(1, 1);
   conffile.autocron = 1;
@@ -383,9 +384,10 @@ void fillconf(conf_t *inconf) {
   conf_bot *bot;
   char *mynick = NULL;
 
-  if (localhub)
+  if (localhub) {
     mynick = strdup(conffile.bots->nick);
-  else
+    strncpyz(origbotname, conffile.bots->nick, NICKLEN + 1);
+  } else
     mynick = strdup(origbotname);
 
   for (bot = conffile.bots; bot && bot->nick; bot = bot->next)

+ 0 - 1
src/main.c

@@ -667,7 +667,6 @@ printf("I AM : %s (%d)\n", conf.bot->nick, conf.bot->pid);
   }
 
   chanprog();
-printf("MY HANDLE: %s\n", conf.bot->u->handle);
 //fatal("WOOT", 0);
 
   dns_init();

+ 3 - 3
src/mod/channels.mod/cmdschan.c

@@ -96,7 +96,7 @@ static void cmd_pls_ban(struct userrec *u, int idx, char *par)
       egg_snprintf(s1, sizeof s1, "%s!%s", me->funcs[SERVER_BOTNAME],
 	            me->funcs[SERVER_BOTUSERHOST]);
     else
-      egg_snprintf(s1, sizeof s1, "%s!%s@%s", origbotname, botuser, hostname);
+      egg_snprintf(s1, sizeof s1, "%s!%s@%s", origbotname, botuser, conf.bot->host);
     if (wild_match(s, s1)) {
       dprintf(idx, "I'm not going to ban myself.\n");
       putlog(LOG_CMDS, "*", "#%s# attempted +ban %s", dcc[idx].nick, s);
@@ -236,7 +236,7 @@ static void cmd_pls_exempt(struct userrec *u, int idx, char *par)
       egg_snprintf(s1, sizeof s1, "%s!%s", me->funcs[SERVER_BOTNAME],
 		     me->funcs[SERVER_BOTUSERHOST]);
     else
-      egg_snprintf(s1, sizeof s1, "%s!%s@%s", origbotname, botuser, hostname);
+      egg_snprintf(s1, sizeof s1, "%s!%s@%s", origbotname, botuser, conf.bot->host);
 
     /* IRC can't understand exempts longer than 70 characters */
     if (strlen(s) > 70) {
@@ -366,7 +366,7 @@ static void cmd_pls_invite(struct userrec *u, int idx, char *par)
       egg_snprintf(s1, sizeof s1, "%s!%s", me->funcs[SERVER_BOTNAME],
 		     me->funcs[SERVER_BOTUSERHOST]);
     else
-      egg_snprintf(s1, sizeof s1, "%s!%s@%s", origbotname, botuser, hostname);
+      egg_snprintf(s1, sizeof s1, "%s!%s@%s", origbotname, botuser, conf.bot->host);
 
     /* IRC can't understand invites longer than 70 characters */
     if (strlen(s) > 70) {

+ 3 - 3
src/mod/channels.mod/userchan.c

@@ -398,7 +398,7 @@ static int u_addban(struct chanset_t *chan, char *ban, char *from, char *note,
     simple_sprintf(s, "%s!%s", me->funcs[SERVER_BOTNAME],
 		   me->funcs[SERVER_BOTUSERHOST]);
   else
-    simple_sprintf(s, "%s!%s@%s", origbotname, botuser, hostname);
+    simple_sprintf(s, "%s!%s@%s", origbotname, botuser, conf.bot->host);
   if (wild_match(host, s)) {
     putlog(LOG_MISC, "*", IRC_IBANNEDME);
     return 0;
@@ -483,7 +483,7 @@ static int u_addinvite(struct chanset_t *chan, char *invite, char *from,
     simple_sprintf(s, "%s!%s", me->funcs[SERVER_BOTNAME],
 		   me->funcs[SERVER_BOTUSERHOST]);
   else
-    simple_sprintf(s, "%s!%s@%s", origbotname, botuser, hostname);
+    simple_sprintf(s, "%s!%s@%s", origbotname, botuser, conf.bot->host);
 
   for (l = *u; l; l = l->next)
     if (!rfc_casecmp(l->mask, host)) {
@@ -562,7 +562,7 @@ static int u_addexempt(struct chanset_t *chan, char *exempt, char *from,
     simple_sprintf(s, "%s!%s", me->funcs[SERVER_BOTNAME],
 		   me->funcs[SERVER_BOTUSERHOST]);
   else
-    simple_sprintf(s, "%s!%s@%s", origbotname, botuser, hostname);
+    simple_sprintf(s, "%s!%s@%s", origbotname, botuser, conf.bot->host);
 
   for (l = *u; l; l = l->next)
     if (!rfc_casecmp(l->mask, host)) {

+ 4 - 4
src/mod/module.h

@@ -246,7 +246,7 @@
 /* 112 - 115 */
 #define tempdir ((char *)(global[112]))
 #define natip ((char *)(global[113]))
-#define hostname ((char *)(global[114]))
+/* UNUSED 114 */
 #define origbotname ((char *)(global[115]))
 /* 116 - 119 */
 #define botuser ((char *)(global[116]))
@@ -489,7 +489,7 @@
 #define bot_aggressive_to ((int (*)(struct userrec *))global[295])
 #define botunlink ((int (*)(int, char *, char *))global[296])
 /* 297 - 300 */
-#define hostname6 ((char *)(global[297]))
+/* UNUSED 297 */
 #define timesync (*(int*)global[298])
 /* UNUSED 299 */
 #define kickreason ((char *(*)(int))global[300])
@@ -525,8 +525,8 @@
 #define authkey ((char *)(global[321]))
 #endif /* S_AUTHHASH */
 #define USERENTRY_SECPASS (*(struct user_entry_type *)(global[322]))
-#define myip ((char *)(global[323]))
-#define myip6 ((char *)(global[324]))
+/* UNUSED 323 */
+/* UNUSED 324 */
 /* 325 - 328 */
 #define cmdprefix ((char *)(global[325]))
 #define replace ((char*(*)(char *, char *, char *))global[326])

+ 3 - 2
src/mod/server.mod/server.c

@@ -1006,7 +1006,7 @@ void servers_changed(struct cfg_entry * entry, char * olddata, int * valid) {
 #ifdef LEAF
   char *slist, *p;
 
-  if (hostname6[0] || myip6[0]) //we want to use the servers6 entry.
+  if (conf.bot->host6 || conf.bot->ip6) /* we want to use the servers6 entry. */
     return;
 
   slist = (char *) (entry->ldata ? entry->ldata : (entry->gdata ? entry->gdata : ""));
@@ -1027,8 +1027,9 @@ void servers6_changed(struct cfg_entry * entry, char * olddata, int * valid) {
 #ifdef LEAF
   char *slist, *p;
 
-  if (!hostname6[0] && !myip6[0]) //we probably want to use the normal server list..
+  if (!conf.bot->host6 && !conf.bot->ip6) /* we probably want to use the normal server list.. */
     return;
+
   slist = (char *) (entry->ldata ? entry->ldata : (entry->gdata ? entry->gdata : ""));
   if (serverlist) {
     clearq(serverlist);

+ 7 - 7
src/modules.c

@@ -43,13 +43,13 @@ extern struct auth_t    *auth;
 extern Tcl_Interp	*interp;
 extern struct userrec	*userlist, *lastuser;
 extern char		 tempdir[], botname[], natip[], cmdprefix[],
-			 hostname[], origbotname[], botuser[], admin[],
+			 origbotname[], botuser[], admin[],
 			 userfile[], ver[], kickprefix[], bankickprefix[],
-			 version[], quit_msg[], hostname6[], bdhash[], dcc_prefix[],
 #ifdef S_AUTHHASH
                          authkey[], 
 #endif /* S_AUTHHASH */
-			 myip[], myip6[];
+			 version[], quit_msg[], bdhash[], dcc_prefix[];
+
 extern int	 	 noshare, loading, role, server_lag, 
 #ifdef S_AUTHCMDS
 			 auth_total, 
@@ -309,7 +309,7 @@ Function global_table[] =
   /* 112 - 115 */
   (Function) tempdir,		 /* char *				*/
   (Function) natip,		 /* char *				*/
-  (Function) hostname,		 /* char *				*/
+  (Function) 0,	
   (Function) origbotname,	 /* char *				*/
   /* 116 - 119 */
   (Function) botuser,		 /* char *				*/
@@ -552,7 +552,7 @@ Function global_table[] =
   (Function) higher_bot_linked,
   (Function) bot_aggressive_to,
   (Function) botunlink,
-  (Function) hostname6,		 /* char *				*/
+  (Function) 0,
   (Function) & timesync, /* int					*/
   (Function) 0, 
   (Function) kickreason,
@@ -591,8 +591,8 @@ Function global_table[] =
   (Function) 0,
 #endif /* S_AUTHHASH */
   (Function) & USERENTRY_SECPASS,
-  (Function) myip,
-  (Function) myip6,
+  (Function) 0,
+  (Function) 0,
   (Function) cmdprefix,
   (Function) replace,
   (Function) degarble,

+ 14 - 19
src/net.c

@@ -58,11 +58,6 @@ union sockaddr_union cached_myip6_so;
 unsigned long notalloc = 0;
 #endif /* USE_IPV6 */
 
-char	hostname[121] = "";	/* Hostname can be specified in the config
-				   file					    */
-char	myip[121] = "";		/* IP can be specified in the config file   */
-char    myip6[121] = "";        /* IP can be specified in the config file   */
-char    hostname6[121] = "";    /* Hostname can be specified in the config file */
 char	firewall[121] = "";	/* Socks server for firewall		    */
 int	firewallport = 1080;	/* Default port of Sock4/5 firewalls	    */
 char	botuser[21] = "wraith"; /* Username of the user running the bot    */
@@ -293,13 +288,13 @@ void cache_my_ip()
 #ifdef USE_IPV6
   egg_memset(&cached_myip6_so, 0, sizeof(union sockaddr_union));
 
-  if (myip6 != NULL && myip6[1]) {
-    sdprintf("myip6: %s", myip6);
-    if (get_ip(myip6, &cached_myip6_so))
+  if (conf.bot->ip6) {
+    sdprintf("ip6: %s", conf.bot->ip6);
+    if (get_ip(conf.bot->ip6, &cached_myip6_so))
       any = 1;
-  } else if (hostname != NULL && hostname6[1]) {
-    sdprintf("myhostname6: %s", hostname6);
-    if (get_ip(hostname6, &cached_myip6_so))
+  } else if (conf.bot->host6) {
+    sdprintf("host6: %s", conf.bot->host6);
+    if (get_ip(conf.bot->host6, &cached_myip6_so))
       any = 1;
   } else
     any = 1;
@@ -312,15 +307,15 @@ void cache_my_ip()
 #endif /* USE_IPV6 */
 
   error = 0;
-  if (myip[0]) {
-    if (get_ip(myip, &cached_myip4_so))
+  if (conf.bot->ip) {
+    if (get_ip(conf.bot->ip, &cached_myip4_so))
       error = 1;
-  } else if (hostname[0]) {
-    if (get_ip(hostname, &cached_myip4_so))
+  } else if (conf.bot->host) {
+    if (get_ip(conf.bot->host, &cached_myip4_so))
       error = 2;
   } else {
     gethostname(s, 120);
-    if (get_ip(hostname, &cached_myip4_so)) {
+    if (get_ip(conf.bot->host, &cached_myip4_so)) {
       /* error = 3; */
       cached_myip4_so.sin.sin_family = AF_INET;
       cached_myip4_so.sin.sin_addr.s_addr = INADDR_ANY;
@@ -820,9 +815,9 @@ int open_address_listen(IP addr, int *port)
 inline int open_listen(int *port)
 {
 #ifdef USE_IPV6
-  return open_address_listen(myip[0] ? getmyip() : INADDR_ANY, AF_INET, port);
+  return open_address_listen(conf.bot->ip ? getmyip() : INADDR_ANY, AF_INET, port);
 #else
-  return open_address_listen(myip[0] ? getmyip() : INADDR_ANY, port);
+  return open_address_listen(conf.bot->ip ? getmyip() : INADDR_ANY, port);
 #endif /* USE_IPV6 */
 }
 
@@ -833,7 +828,7 @@ inline int open_listen(int *port)
 inline int open_listen_by_af(int *port, int af_def)
 {
 #ifdef USE_IPV6
-  return open_address_listen(myip[0] ? getmyip() : INADDR_ANY, af_def, port);
+  return open_address_listen(conf.bot->ip ? getmyip() : INADDR_ANY, af_def, port);
 #else
   return 0;
 #endif /* USE_IPV6 */

+ 1 - 2
src/tcl.c

@@ -42,8 +42,7 @@ extern int	backgrd, flood_telnet_thr, flood_telnet_time,
 		dcc_sanitycheck, sort_users, tands, resolve_timeout,
 		default_uflags, strict_host, userfile_perm;
 extern char	origbotname[], botuser[], motdfile[], admin[], userfile[],
-                firewall[], hostname[], hostname6[], myip[], myip6[],
-		tempdir[], owner[], network[], 
+                firewall[], tempdir[], owner[], network[], 
 		egg_version[], natip[], 
 		dcc_prefix[];