Просмотр исходного кода

* Removed the UFF stuff

svn: 930
Bryan Drewery 22 лет назад
Родитель
Сommit
8a871bafd4
3 измененных файлов с 22 добавлено и 386 удалено
  1. 22 55
      src/mod/share.mod/share.c
  2. 0 28
      src/mod/share.mod/share.h
  3. 0 303
      src/mod/share.mod/uf_features.c

+ 22 - 55
src/mod/share.mod/share.c

@@ -29,18 +29,8 @@
 #  include "src/mod/irc.mod/irc.h"
 #  include "src/mod/irc.mod/irc.h"
 #endif /* LEAF */
 #endif /* LEAF */
 
 
-/* Minimum version I will share with. */
-static const int min_share = 1000000;
-
-/* Earliest version that supports exempts and invites. */
-static const int min_exemptinvite = 1000000;
-
-/* Minimum version that supports userfile features. */
-static const int min_uffeature = 1000000;
-
 static struct flag_record fr = { 0, 0, 0, 0 };
 static struct flag_record fr = { 0, 0, 0, 0 };
 
 
-
 struct delay_mode {
 struct delay_mode {
   struct delay_mode *next;
   struct delay_mode *next;
   struct chanset_t *chan;
   struct chanset_t *chan;
@@ -52,21 +42,6 @@ struct delay_mode {
 
 
 static struct delay_mode *start_delay = NULL;
 static struct delay_mode *start_delay = NULL;
 
 
-
-/* Store info for sharebots */
-struct share_msgq {
-  struct chanset_t *chan;
-  char *msg;
-  struct share_msgq *next;
-};
-
-typedef struct tandbuf_t {
-  char bot[HANDLEN + 1];
-  time_t timer;
-  struct share_msgq *q;
-  struct tandbuf_t *next;
-} tandbuf;
-
 /* Prototypes */
 /* Prototypes */
 #ifdef HUB
 #ifdef HUB
 static void start_sending_users(int);
 static void start_sending_users(int);
@@ -76,8 +51,6 @@ static void cancel_user_xfer(int, void *);
 
 
 #include "share.h"
 #include "share.h"
 
 
-#include "uf_features.c"
-
 /*
 /*
  *   Sup's delay code
  *   Sup's delay code
  */
  */
@@ -957,7 +930,10 @@ share_ufyes(int idx, char *par)
     dcc[idx].status &= ~STAT_OFFERED;
     dcc[idx].status &= ~STAT_OFFERED;
     dcc[idx].status |= STAT_SHARE;
     dcc[idx].status |= STAT_SHARE;
     dcc[idx].status |= STAT_SENDING;
     dcc[idx].status |= STAT_SENDING;
-    uf_features_parse(idx, par);
+
+    dcc[idx].u.bot->uff_flags |= (UFF_OVERRIDE | UFF_INVITE | UFF_EXEMPT );
+    dprintf(idx, "s feats overbots invites exempts\n");
+
     lower_bot_linked(idx);
     lower_bot_linked(idx);
 
 
     start_sending_users(idx);
     start_sending_users(idx);
@@ -986,7 +962,7 @@ share_userfileq(int idx, char *par)
     if (!ok)
     if (!ok)
       dprintf(idx, "s un Already sharing.\n");
       dprintf(idx, "s un Already sharing.\n");
     else {
     else {
-      dprintf(idx, "s uy %s\n", uf_features_dump(idx));
+      dprintf(idx, "s uy overbots invites exempts\n");
       /* Set stat-getting to astatic void race condition (robey 23jun1996) */
       /* Set stat-getting to astatic void race condition (robey 23jun1996) */
       dcc[idx].status |= STAT_SHARE | STAT_GETTING | STAT_AGGRESSIVE;
       dcc[idx].status |= STAT_SHARE | STAT_GETTING | STAT_AGGRESSIVE;
 #ifdef HUB
 #ifdef HUB
@@ -1105,7 +1081,7 @@ share_end(int idx, char *par)
 static void
 static void
 share_feats(int idx, char *par)
 share_feats(int idx, char *par)
 {
 {
-  (int) uf_features_check(idx, par);
+   dcc[idx].u.bot->uff_flags |= (UFF_OVERRIDE | UFF_INVITE | UFF_EXEMPT );
 }
 }
 
 
 
 
@@ -1290,7 +1266,6 @@ write_tmp_userfile(char *fn, struct userrec *bu, int idx)
     putlog(LOG_MISC, "@", USERF_ERRWRITE2);
     putlog(LOG_MISC, "@", USERF_ERRWRITE2);
   return ok;
   return ok;
 }
 }
-#endif /* HUB */
 
 
 
 
 /* Create a copy of the entire userlist (for sending user lists to clone
 /* Create a copy of the entire userlist (for sending user lists to clone
@@ -1362,6 +1337,7 @@ dup_userlist(int t)
   noshare = 0;
   noshare = 0;
   return retu;
   return retu;
 }
 }
+#endif /* HUB */
 
 
 /* Erase old user list, switch to new one.
 /* Erase old user list, switch to new one.
  */
  */
@@ -1378,7 +1354,8 @@ finish_share(int idx)
   if (j == -1)
   if (j == -1)
     return;
     return;
 
 
-  if (!uff_call_receiving(j, dcc[idx].u.xfer->filename)) {
+/* compress.mod 
+  if (!uncompressfile(dcc[idx].u.xfer->filename)) {
     char xx[1024] = "";
     char xx[1024] = "";
 
 
     putlog(LOG_BOTS, "*", "A uff parsing function failed for the userfile!");
     putlog(LOG_BOTS, "*", "A uff parsing function failed for the userfile!");
@@ -1394,12 +1371,7 @@ finish_share(int idx)
 
 
     return;
     return;
   }
   }
-
-  if (dcc[j].u.bot->uff_flags & UFF_OVERRIDE)
-    debug1("NOTE: Sharing passively with %s, overriding local bots.", dcc[j].nick);
-  else
-    /* Copy the bots over. The entries will be used in the new user list. */
-    u = dup_userlist(1);
+*/
 
 
   /*
   /*
    * This is where we remove all global and channel bans/exempts/invites and
    * This is where we remove all global and channel bans/exempts/invites and
@@ -1432,14 +1404,11 @@ finish_share(int idx)
    * are set to NULL. If our userfile will be overriden, just set _all_
    * are set to NULL. If our userfile will be overriden, just set _all_
    * to NULL directly.
    * to NULL directly.
    */
    */
-  if (u == NULL)
-    for (i = 0; i < dcc_total; i++)
-      dcc[i].user = NULL;
-  else
-    for (i = 0; i < dcc_total; i++)
-      dcc[i].user = get_user_by_handle(u, dcc[i].nick);
+  for (i = 0; i < dcc_total; i++)
+    dcc[i].user = NULL;
 
 
-  conf.bot->u = NULL;
+  if (conf.bot->u)
+    conf.bot->u = NULL;
 
 
   /* Read the transferred userfile. Add entries to u, which already holds
   /* Read the transferred userfile. Add entries to u, which already holds
    * the bot entries in non-override mode.
    * the bot entries in non-override mode.
@@ -1478,6 +1447,7 @@ finish_share(int idx)
 
 
     return;
     return;
   }
   }
+
   unlink(dcc[idx].u.xfer->filename);    //I mean really, shit fills up the quota fast.
   unlink(dcc[idx].u.xfer->filename);    //I mean really, shit fills up the quota fast.
 
 
   loading = 0;
   loading = 0;
@@ -1499,11 +1469,11 @@ finish_share(int idx)
   for (u = userlist; u; u = u->next) {
   for (u = userlist; u; u = u->next) {
     struct userrec *u2 = get_user_by_handle(ou, u->handle);
     struct userrec *u2 = get_user_by_handle(ou, u->handle);
 
 
-    if ((dcc[j].u.bot->uff_flags & UFF_OVERRIDE) && u2 && (u2->flags & USER_BOT)) {
+    if (u2 && (u2->flags & USER_BOT)) {
       /* We knew this bot before, copy flags and the password back over. */
       /* We knew this bot before, copy flags and the password back over. */
       set_user(&USERENTRY_BOTFL, u, get_user(&USERENTRY_BOTFL, u2));
       set_user(&USERENTRY_BOTFL, u, get_user(&USERENTRY_BOTFL, u2));
       set_user(&USERENTRY_PASS, u, get_user(&USERENTRY_PASS, u2));
       set_user(&USERENTRY_PASS, u, get_user(&USERENTRY_PASS, u2));
-    } else if ((dcc[j].u.bot->uff_flags & UFF_OVERRIDE) && (u->flags & USER_BOT)) {
+    } else if (u->flags & USER_BOT) {
       /* This bot was unknown to us, reset it's flags and password. */
       /* This bot was unknown to us, reset it's flags and password. */
       set_user(&USERENTRY_BOTFL, u, NULL);
       set_user(&USERENTRY_BOTFL, u, NULL);
       set_user(&USERENTRY_PASS, u, NULL);
       set_user(&USERENTRY_PASS, u, NULL);
@@ -1555,22 +1525,21 @@ start_sending_users(int idx)
   int i = 1;
   int i = 1;
 
 
   egg_snprintf(share_file, sizeof share_file, "%s.share.%s.%li", tempdir, dcc[idx].nick, now);
   egg_snprintf(share_file, sizeof share_file, "%s.share.%s.%li", tempdir, dcc[idx].nick, now);
-  if (dcc[idx].u.bot->uff_flags & UFF_OVERRIDE) {
-    debug1("NOTE: Sharing aggressively with %s, overriding its local bots.", dcc[idx].nick);
-    u = dup_userlist(2);        /* All entries          */
-  } else
-    u = dup_userlist(0);        /* Only non-bots        */
+
+  u = dup_userlist(2);        /* All entries          */
 
 
   write_tmp_userfile(share_file, u, idx);
   write_tmp_userfile(share_file, u, idx);
   clear_userlist(u);
   clear_userlist(u);
 
 
-  if (!uff_call_sending(idx, share_file)) {     /* compress! */
+/* compress.mod
+  if (!compress_file(share_file, compress_level)) {
     unlink(share_file);
     unlink(share_file);
     dprintf(idx, "s e %s\n", "uff parsing failed");
     dprintf(idx, "s e %s\n", "uff parsing failed");
     putlog(LOG_BOTS, "*", "uff parsing failed");
     putlog(LOG_BOTS, "*", "uff parsing failed");
     dcc[idx].status &= ~(STAT_SHARE | STAT_SENDING | STAT_AGGRESSIVE);
     dcc[idx].status &= ~(STAT_SHARE | STAT_SENDING | STAT_AGGRESSIVE);
     return;
     return;
   }
   }
+*/
 
 
   if ((i = raw_dcc_send(share_file, "*users", "(users)", share_file)) > 0) {
   if ((i = raw_dcc_send(share_file, "*users", "(users)", share_file)) > 0) {
     unlink(share_file);
     unlink(share_file);
@@ -1688,6 +1657,4 @@ share_init()
   timer_create_secs(1, "check_delay", (Function) check_delay);
   timer_create_secs(1, "check_delay", (Function) check_delay);
   def_dcc_bot_kill = DCC_BOT.kill;
   def_dcc_bot_kill = DCC_BOT.kill;
   DCC_BOT.kill = cancel_user_xfer;
   DCC_BOT.kill = cancel_user_xfer;
-  uff_init();
-  uff_addtable(internal_uff_table);
 }
 }

+ 0 - 28
src/mod/share.mod/share.h

@@ -10,38 +10,10 @@
 #define UFF_INVITE	BIT1	/* Send invites in user file	    */
 #define UFF_INVITE	BIT1	/* Send invites in user file	    */
 #define UFF_EXEMPT	BIT2	/* Send exempts in user file	    */
 #define UFF_EXEMPT	BIT2	/* Send exempts in user file	    */
 
 
-/* Currently reserved flags for other modules:
- *      UFF_COMPRESS    0x000008	   Compress the user file
- *      UFF_ENCRYPT	0x000010	   Encrypt the user file
- */
-
-/* Currently used priorities:
- *        0		UFF_OVERRIDE
- *        0		UFF_INVITE
- *        0		UFF_EXEMPT
- *       90		UFF_ENCRYPT
- *      100             UFF_COMPRESS
- */
-
-typedef struct {
-  char	 *feature;		/* Name of the feature			*/
-  int	  flag;			/* Flag representing the feature	*/
-  int	(*ask_func)(int);	/* Pointer to the function that tells
-				   us wether the feature should be
-				   considered as on.			*/
-  int	  priority;		/* Priority with which this entry gets
-				   called.				*/
-  int	(*snd)(int, char *);	/* Called before sending. Handled
-				   according to `priority'.		*/
-  int	(*rcv)(int, char *);	/* Called on receive. Handled according
-				   to `priority'.			*/
-} uff_table_t;
-
 void sharein(int, char *);
 void sharein(int, char *);
 void shareout(struct chanset_t *, ...);
 void shareout(struct chanset_t *, ...);
 void finish_share(int);
 void finish_share(int);
 void dump_resync(int);
 void dump_resync(int);
-void uff_addtable(uff_table_t *);
 void share_report(int, int);
 void share_report(int, int);
 #ifdef HUB
 #ifdef HUB
 void hook_read_userfile();
 void hook_read_userfile();

+ 0 - 303
src/mod/share.mod/uf_features.c

@@ -1,303 +0,0 @@
-/*
- * uf_features.c -- part of share.mod
- *
- */
-/*
- * Userfile feature protocol description:
- *
- *
- *		 LEAF				       HUB
- *
- *   uf_features_dump():
- *	Finds out which features
- *	it supports / wants to use
- *	and then dumps those. The
- *	list is appended to the
- *	user file send ack.
- *
- *	"s uy <features>"   --+
- *			      |
- *			      +-->   uf_features_parse():
- *					Parses the given list of features,
- *					given in a string, seperated with
- *					spaces. Decides which features to
- *					accept/use. Those features are then
- *					locally set:
- *
- *					dcc[idx].u.bot->uff_flags |= <feature_flag>
- *
- *					and sent back to the LEAF:
- *
- *				+---	"s feats <accepted_features>"
- *				|
- *   uf_features_check():    <--+
- *	Checks wether the responded
- *	features are still accepted
- *	by us. If they are, we set
- *	the flags locally:
- *
- *	dcc[idx].u.bot->uff_flags |= <feature_flag>
- */
-
-
-typedef struct uff_list_struct {
-  struct uff_list_struct *next;	/* Pointer to next entry		*/
-  struct uff_list_struct *prev;	/* Pointer to previous entry		*/
-  uff_table_t *entry;		/* Pointer to entry in table. This is
-				   not copied or anything, we just refer
-				   to the original table entry.		*/
-} uff_list_t;
-
-typedef struct {
-  uff_list_t		*start;
-  uff_list_t		*end;
-} uff_head_t;
-
-static uff_head_t	uff_list;
-static char		uff_sbuf[512] = "";
-
-
-/*
- *    Userfile features management functions
- */
-
-static void uff_init(void)
-{
-  egg_bzero(&uff_list, sizeof(uff_head_t));
-}
-
-/* Search for a feature in the uff feature list that matches a supplied
- * feature flag. Returns a pointer to the entry in the list or NULL if
- * no feature uses the flag.
- */
-static uff_list_t *uff_findentry_byflag(int flag)
-{
-  uff_list_t *ul = NULL;
-
-  for (ul = uff_list.start; ul; ul = ul->next)
-    if (ul->entry->flag & flag)
-      return ul;
-  return NULL;
-}
-
-/* Search for a feature in the uff feature list. Returns a pointer to the
- * entry in the list or NULL if no such feature exists.
- */
-static uff_list_t *uff_findentry_byname(char *feature)
-{
-  uff_list_t *ul = NULL;
-
-  for (ul = uff_list.start; ul; ul = ul->next)
-    if (!strcmp(ul->entry->feature, feature))
-      return ul;
-  return NULL;
-}
-
-/* Insert entry into sorted list.
- */
-static void uff_insert_entry(uff_list_t *nul)
-{
-  uff_list_t *ul = NULL, *lul = NULL;
-
-  ul = uff_list.start;
-  while (ul && ul->entry->priority < nul->entry->priority) {
-    lul = ul;
-    ul = ul->next;
-  }
-
-  nul->prev = NULL;
-  nul->next = NULL;
-  if (lul) {
-    if (lul->next)
-      lul->next->prev = nul;
-    nul->next = lul->next;
-    nul->prev = lul;
-    lul->next = nul;
-  } else if (ul) {
-    uff_list.start->prev = nul;
-    nul->next = uff_list.start;
-    uff_list.start = nul;
-  } else
-    uff_list.start = nul;
-  if (!nul->next)
-    uff_list.end = nul;
-}
-
-/* Add a single feature to the list.
- */
-static void uff_addfeature(uff_table_t *ut)
-{
-  uff_list_t *ul = NULL;
-
-  if (uff_findentry_byname(ut->feature)) {
-    putlog(LOG_MISC, "*", "(!) share: same feature name used twice: %s", ut->feature);
-    return;
-  }
-  ul = uff_findentry_byflag(ut->flag);
-  if (ul) {
-    putlog(LOG_MISC, "*", "(!) share: feature flag %d used twice by %s and %s", ut->flag, ut->feature, ul->entry->feature);
-    return;
-  }
-  ul = calloc(1, sizeof(uff_list_t));
-  ul->entry = ut;
-  uff_insert_entry(ul);
-}
-
-/* Add a complete table to the list.
- */
-void uff_addtable(uff_table_t *ut)
-{
-  if (!ut)
-    return;
-  for (; ut->feature; ++ut)
-    uff_addfeature(ut);
-}
-
-/*
- *    Userfile feature parsing functions
- */
-
-#ifdef HUB
-/* Parse the given features string, set internal flags apropriately and
- * eventually respond with all features we will use.
- */
-static void uf_features_parse(int idx, char *par)
-{
-  char *buf = NULL, *s = NULL, *p = NULL;
-  uff_list_t *ul = NULL;
-
-  uff_sbuf[0] = 0;				/* Reset static buffer	*/
-  p = s = buf = strdup(par);
-
-  /* Clear all currently set features. */
-  dcc[idx].u.bot->uff_flags = 0;
-
-  /* Parse string */
-  while ((s = strchr(s, ' ')) != NULL) {
-    *s = '\0';
-
-    /* Is the feature available and active? */
-    ul = uff_findentry_byname(p);
-    if (ul && (ul->entry->ask_func == NULL || ul->entry->ask_func(idx))) {
-      dcc[idx].u.bot->uff_flags |= ul->entry->flag; /* Set flag	*/
-      strcat(uff_sbuf, ul->entry->feature);	 /* Add feature to list	*/
-      strcat(uff_sbuf, " ");
-    }
-    p = ++s;
-  }
-  free(buf);
-
-  /* Send response string						*/
-  if (uff_sbuf[0])
-    dprintf(idx, "s feats %s\n", uff_sbuf);
-}
-#endif /* HUB */
-
-/* Return a list of features we are supporting.
- */
-static char *uf_features_dump(int idx)
-{
-  uff_list_t *ul = NULL;
-
-  uff_sbuf[0] = 0;
-  for (ul = uff_list.start; ul; ul = ul->next)
-    if (ul->entry->ask_func == NULL || ul->entry->ask_func(idx)) {
-      strcat(uff_sbuf, ul->entry->feature);	/* Add feature to list	*/
-      strcat(uff_sbuf, " ");
-    }
-  return uff_sbuf;
-}
-
-static int uf_features_check(int idx, char *par)
-{
-  char *buf = NULL, *s = NULL, *p = NULL;
-  uff_list_t *ul = NULL;
-
-  uff_sbuf[0] = 0;				/* Reset static buffer	*/
-  p = s = buf = strdup(par);
-
-  /* Clear all currently set features. */
-  dcc[idx].u.bot->uff_flags = 0;
-
-  /* Parse string */
-  while ((s = strchr(s, ' ')) != NULL) {
-    *s = '\0';
-
-    /* Is the feature available and active? */
-    ul = uff_findentry_byname(p);
-    if (ul && (ul->entry->ask_func == NULL || ul->entry->ask_func(idx)))
-      dcc[idx].u.bot->uff_flags |= ul->entry->flag; /* Set flag	*/
-    else {
-      /* It isn't, and our hub wants to use it! This either happens
-       * because the hub doesn't look at the features we suggested to
-       * use or because our admin changed the flags, so that formerly
-       * active features are now deactivated.
-       *
-       * In any case, we abort user file sharing.
-       */
-      putlog(LOG_BOTS, "*", "Bot %s tried unsupported feature!", dcc[idx].nick);
-      dprintf(idx, "s e Attempt to use an unsupported feature\n");
-      zapfbot(idx);
-
-      free(buf);
-      return 0;
-    }
-    p = ++s;
-  }
-  free(buf);
-  return 1;
-}
-
-#ifdef HUB
-/* Call all active feature functions, sorted by their priority. This
- * should be called when we're about to send a user file.
- */
-static int uff_call_sending(int idx, char *user_file)
-{
-  uff_list_t *ul = NULL;
-
-  for (ul = uff_list.start; ul; ul = ul->next)
-    if (ul->entry && ul->entry->snd &&
-	(dcc[idx].u.bot->uff_flags & ul->entry->flag))
-      if (!(ul->entry->snd(idx, user_file)))
-	return 0;	/* Failed! */
-  return 1;
-}
-#endif /* HUB */
-
-/* Call all active feature functions, sorted by their priority. This
- * should be called when we've received a user file and are about to
- * parse it.
- */
-static int uff_call_receiving(int idx, char *user_file)
-{
-  uff_list_t *ul = NULL;
-
-  for (ul = uff_list.end; ul; ul = ul->prev)
-    if (ul->entry && ul->entry->rcv &&
-	(dcc[idx].u.bot->uff_flags & ul->entry->flag))
-      if (!(ul->entry->rcv(idx, user_file)))
-	return 0;	/* Failed! */
-  return 1;
-}
-
-
-/*
- *    Userfile feature handlers
- */
-
-
-/*
- *     Internal user file feature table
- */
-
-int
-blah() {
-  return 1;
-}
-static uff_table_t internal_uff_table[] = {
-  {"overbots",	UFF_OVERRIDE,	blah,			0, NULL, NULL},
-  {"invites",	UFF_INVITE,	NULL,			0, NULL, NULL},
-  {"exempts",	UFF_EXEMPT,	NULL,			0, NULL, NULL},
-  {NULL,	0,		NULL,			0, NULL, NULL}
-};