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

Merge branch 'streaming-userfile-aggressiveness' into next

* streaming-userfile-aggressiveness:
  Add aggressive check before transfering userfile for compat
  This check doesn't work here as a separate dcc is created for transfer
  Validate sooner when the update is first offered and initiated
Bryan Drewery 13 лет назад
Родитель
Сommit
965a54532c
2 измененных файлов с 22 добавлено и 16 удалено
  1. 7 7
      src/mod/share.mod/share.c
  2. 15 9
      src/mod/update.mod/update.c

+ 7 - 7
src/mod/share.mod/share.c

@@ -985,6 +985,13 @@ share_userfileq(int idx, char *par)
 static void
 share_ufsend(int idx, char *par)
 {
+  if (bot_aggressive_to(dcc[idx].user)) {
+    putlog(LOG_ERRORS, "*", "%s attempted to start sending userfile [compat] - I'm supposed to be aggressive to it [likely a hack]", dcc[idx].nick);
+    dprintf(idx, "s un I have you marked for Agressive sharing.\n");
+    botunlink(-2, dcc[idx].nick, "I'm aggressive to you");
+    return;
+  }
+
   char *port = NULL, *ip = NULL;
   char s[1024] = "";
   int i, sock;
@@ -1307,13 +1314,6 @@ finish_share(int idx)
   if (j == -1)
     return;
 
-  if (bot_aggressive_to(dcc[idx].user)) {
-    putlog(LOG_ERRORS, "*", "%s attempted to end user transfer [compat] - I'm supposed to be aggressive to it [likely a hack]", dcc[idx].nick);
-    dprintf(idx, "s un I have you marked for Agressive sharing.\n");
-    botunlink(-2, dcc[idx].nick, "I'm aggressive to you");
-    return;
-  }
-
   const char salt1[] = SALT1;
   EncryptedStream stream(salt1);
   stream.loadFile(dcc[idx].u.xfer->filename);

+ 15 - 9
src/mod/update.mod/update.c

@@ -93,6 +93,13 @@ static void update_fileq(int idx, char *par)
   if (dcc[idx].status & STAT_GETTINGU || updated) 
     return;
 
+  if (!dcc[idx].hub) {
+    putlog(LOG_ERRORS, "*", "%s attemped to offer binary transfer - they are not a hub [likely a hack]", dcc[idx].nick);
+    dprintf(idx, "s un You are not allowed to send me binaries.\n");
+    botunlink(-2, dcc[idx].nick, "You are not allowed to send me binaries.");
+    return;
+  }
+
   if (!conf.bot->hub) {
     if (!conf.bot->localhub)
       return;
@@ -110,6 +117,12 @@ static void update_fileq(int idx, char *par)
  */
 static void update_ufsend(int idx, char *par)
 {
+  if (!dcc[idx].hub) {
+    putlog(LOG_ERRORS, "*", "%s attempted to initiate binary transfer - they are not a hub [likely a hack]", dcc[idx].nick);
+    dprintf(idx, "s un You are not allowed to send me binaries.\n");
+    botunlink(-2, dcc[idx].nick, "You are not allowed to send me binaries.");
+    return;
+  }
 
   char *ip = NULL, *port = NULL, s[1024] = "";
   int i, sock;
@@ -166,7 +179,7 @@ static void update_stream_line(int idx, char *par) {
 
 static void update_stream_start(int idx, char *par) {
   if (!dcc[idx].hub) {
-    putlog(LOG_ERRORS, "*", "%s attempted to initiate binary transfer - they are not a hub [likely a hack]", dcc[idx].nick);
+    putlog(LOG_ERRORS, "*", "%s attempted to initiate streaming binary transfer - they are not a hub [likely a hack]", dcc[idx].nick);
     dprintf(idx, "s un You are not allowed to send me binaries.\n");
     botunlink(-2, dcc[idx].nick, "You are not allowed to send me binaries.");
     return;
@@ -178,7 +191,7 @@ static void update_stream_start(int idx, char *par) {
 
 static void update_stream_end(int idx, char *par) {
   if (!dcc[idx].hub) {
-    putlog(LOG_ERRORS, "*", "%s attempted to end binary transfer - they are not a hub [likely a hack]", dcc[idx].nick);
+    putlog(LOG_ERRORS, "*", "%s attempted to end streaming binary transfer - they are not a hub [likely a hack]", dcc[idx].nick);
     dprintf(idx, "s un You are not allowed to send me binaries.\n");
     botunlink(-2, dcc[idx].nick, "You are not allowed to send me binaries.");
     return;
@@ -288,13 +301,6 @@ ulsend(int idx, const char* data, size_t datalen)
 }
 
 void finish_update(int idx) {
-  if (!dcc[idx].hub) {
-    putlog(LOG_ERRORS, "*", "%s attemped to finish binary transfer - they are not a hub [likely a hack]", dcc[idx].nick);
-    dprintf(idx, "s un You are not allowed to send me binaries.\n");
-    botunlink(-2, dcc[idx].nick, "You are not allowed to send me binaries.");
-    return;
-  }
-
   bd::Stream stream;
   stream.loadFile(dcc[idx].u.xfer->filename);
   unlink(dcc[idx].u.xfer->filename);