-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: urcd
action: commit
revision:
path_from:
revision_from: 49a719d0f35c1cd33a05ffab0245f6ff4646717e:
path_to:
revision_to:

git.thebackupbox.net

urcd

git://git.thebackupbox.net/urcd

commit 49a719d0f35c1cd33a05ffab0245f6ff4646717e
Author: root <root@d3v11.ano>
Date:   Fri Jun 14 18:35:11 2013 +0000

    [*.c] some #include's, [urc2sd.pyx] vanity, [urcd.pyx] antiflood + bugfix in rd file descriptor name

diff --git a/src/ucspi-client2server.c b/src/ucspi-client2server.c

index 8b1d1ab94edfbd2aa80926a2728179264be9be38..

index ..c9d5c9c4eab88af9109a11b71298dfe972086f01 100644

--- a/src/ucspi-client2server.c
+++ b/src/ucspi-client2server.c
@@ -1,4 +1,5 @@
 #include <unistd.h>
+#include <string.h>
 #define USAGE "Usage: ucspi-client2server prog [args]\n"
 int main (int argc, char **argv) {
  if (argc>2) {
@@ -7,5 +8,5 @@ int main (int argc, char **argv) {
   execvp(argv[1],argv+1);
  }
  write(2,USAGE,strlen(USAGE));
- exit(255);
+ return 255;
 }
diff --git a/src/ucspi-server2client.c b/src/ucspi-server2client.c

index 6b7215e8770293006919886771bb3af0e4167359..

index ..a953d3727d28b113695915784c7b6e958a4d2dc9 100644

--- a/src/ucspi-server2client.c
+++ b/src/ucspi-server2client.c
@@ -1,4 +1,5 @@
 #include <unistd.h>
+#include <string.h>
 #define USAGE "Usage: ucspi-server2client prog [args]\n"
 int main (int argc, char **argv) {
  if (argc>2) {
@@ -7,5 +8,5 @@ int main (int argc, char **argv) {
   execvp(argv[1],argv+1);
  }
  write(2,USAGE,strlen(USAGE));
- exit(255);
+ return 255;
 }
diff --git a/src/ucspi-socks4aclient.c b/src/ucspi-socks4aclient.c

index 546102c85ad733c90bab36d13f342cd989075f0e..

index ..986bc1eea2afb90c2655128cc797ec0a481115fe 100644

--- a/src/ucspi-socks4aclient.c
+++ b/src/ucspi-socks4aclient.c
@@ -1,9 +1,11 @@
+#include <strings.h>
+#include <string.h>
 #define USAGE "Usage: ucspi-socks4aclient addr port prog [args]\n"
 int main(int argc, char **argv){

 if ((argc<4)||(strlen(argv[1])>256)||(atoi(argv[2])<0)||(atoi(argv[2])>65535)){
   write(2,USAGE,strlen(USAGE));
-  exit(64);}
+  return 64;}

 unsigned char packet[512]={0};
 packet[ 0] = '\x04';
@@ -18,8 +20,8 @@ packet[11] = 'p';
 packet[12] = 'i';

 memmove(&packet[14],argv[1],strlen(argv[1])+1);
-if (write(7,packet,14+strlen(argv[1])+1)<14+strlen(argv[1])+1) exit(128+111);
+if (write(7,packet,14+strlen(argv[1])+1)<14+strlen(argv[1])+1) return 128+111;
 bzero(packet,512);
-if (read(6,packet,8)<8) exit(128+32);
-if ((packet[0]!=0)||(packet[1]!=90)) exit(128+111);
+if (read(6,packet,8)<8) return 128+32;
+if ((packet[0]!=0)||(packet[1]!=90)) return 128+111;
 execvp(argv[3],argv+3);}
diff --git a/src/ucspi-stream.c b/src/ucspi-stream.c

index cf6163f2d15ba9748d390ce38e264f32da8cba71..

index ..c5e91d44c686eb7cd65b4a2c4de317c8f14e4245 100644

--- a/src/ucspi-stream.c
+++ b/src/ucspi-stream.c
@@ -1,4 +1,5 @@
 #include <sys/fcntl.h>
+#include <string.h>
 #include <poll.h>
 int main(){

diff --git a/src/urc2sd.pyx b/src/urc2sd.pyx

index 134f098a7968af506cab87e765150f70a8ca1054..

index ..4d9c758b9e94886d58090c478961c63a48010f58 100644

--- a/src/urc2sd.pyx
+++ b/src/urc2sd.pyx
@@ -162,16 +162,14 @@ while 1:
       if len(buffer.split(' :'))<2: buffer += ' :'
       sock_write(buffer+'\n')

-    elif re_CLIENT_PING(buffer):
-      try_write(1,'PONG '+re_SPLIT(buffer,1)[1]+'\n')
+    elif re_CLIENT_PING(buffer): try_write(1,'PONG '+re_SPLIT(buffer,1)[1]+'\n')

     elif re_CLIENT_JOIN(buffer):
       sock_write(buffer+'\n')
       dst = buffer.split(':')[2].lower()
       if not dst in channels:
         if len(channels) - 1 < CHANLIMIT:
-          BAN[dst] = list()
-          EXCEPT[dst] = list()
+          BAN[dst], EXCEPT[dst] = list(), list()
           channels.append(dst)
           try_write(1,'MODE '+dst+' b\n')
           time.sleep(LIMIT)
diff --git a/src/urcd.pyx b/src/urcd.pyx

index c5641cb019bdcc7c363e62e382ca9c98f3a22f3a..

index ..06be66be662bb1171f249fdbc00d8198339f30be 100644

--- a/src/urcd.pyx
+++ b/src/urcd.pyx
@@ -41,6 +41,7 @@ re_SERVER_KICK = re.compile('^:['+RE+']+![~'+RE+'.]+@['+RE+'.]+ KICK [#&!+]['+RE

 PING = int(open('env/PING','rb').read().split('\n')[0]) if os.path.exists('env/PING') else 0
 URCDB = open('env/URCDB','rb').read().split('\n')[0] if os.path.exists('env/URCDB') else str()
+FLOOD = int(open('env/FLOOD','rb').read().split('\n')[0]) if os.path.exists('env/FLOOD') else 0
 LIMIT = float(open('env/LIMIT','rb').read().split('\n')[0]) if os.path.exists('env/LIMIT') else 1
 COLOUR = int(open('env/COLOUR','rb').read().split('\n')[0]) if os.path.exists('env/COLOUR') else 0
 UNICODE = int(open('env/UNICODE','rb').read().split('\n')[0]) if os.path.exists('env/UNICODE') else 0
@@ -54,10 +55,12 @@ CHANNELLEN = int(open('env/CHANNELLEN','rb').read().split('\n')[0]) if os.path.e
 PONG = int()
 nick = str()
 Nick = str()
+flood = int()
 seen = time.time()
 ping = time.time()
 user = str(os.getpid())
 channel_struct = dict()
+flood_expiry = time.time()
 WAIT = PING << 10 if PING else 16384
 channels = collections.deque([],CHANLIMIT)
 motd = open('env/motd','rb').read().split('\n')
@@ -92,17 +95,17 @@ signal.signal(signal.SIGINT,sock_close)
 signal.signal(signal.SIGTERM,sock_close)
 signal.signal(signal.SIGCHLD,sock_close)

-rd = 0
 if os.access('stdin',1):
   p = subprocess.Popen(['./stdin'],stdout=subprocess.PIPE)
   rd = p.stdout.fileno()
   del p
+else: rd = 0

-wr = 1
 if os.access('stdout',1):
   p = subprocess.Popen(['./stdout'],stdin=subprocess.PIPE)
   wr = p.stdin.fileno()
   del p
+else: wr = 1

 uid, gid = pwd.getpwnam('urcd')[2:4]
 os.chdir(sys.argv[1])
@@ -226,7 +229,12 @@ while 1:

     elif not nick: pass

-    elif re_CLIENT_PRIVMSG_NOTICE_TOPIC_PART(buffer):
+    elif re_CLIENT_PRIVMSG_NOTICE_TOPIC_PART(buffer):
+
+      if FLOOD:
+        if now - flood_expiry >= FLOOD: flood = 0
+        flood, flood_expiry = flood + 1, now
+        if flood >= FLOOD: continue

       cmd, dst, msg = re_SPLIT(buffer,2)
       cmd = cmd.upper()

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 16:34:50 2024