-- 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: c991fa11ff171f021edc089016b2d8cb6412901b: path_to: revision_to:
commit c991fa11ff171f021edc089016b2d8cb6412901b Author: root <root@d3v11.ano> Date: Fri Feb 15 06:00:01 2013 +0000 [URC] limit 1kb/s per connect (inbound) diff --git a/src/urc2sd.pyx b/src/urc2sd.pyx
--- a/src/urc2sd.pyx +++ b/src/urc2sd.pyx @@ -12,9 +12,10 @@ import sys import re import os -user = str(os.getpid()) -RE = 'a-zA-Z0-9^(\)\-_{\}[\]|' -nick = open('nick','rb').read().split('\n')[0] +LIMIT = 1 +user = str(os.getpid()) +RE = 'a-zA-Z0-9^(\)\-_{\}[\]|' +nick = open('nick','rb').read().split('\n')[0] channels = collections.deque([],64) for dst in open('channels','rb').read().split('\n'): @@ -69,13 +70,21 @@ client_POLLIN.register(rd,3) server_POLLIN=select.poll() server_POLLIN.register(sd,3) +now = time.time() +def limit(): + if ((time.time() - now) > LIMIT): + global now + now = time.time() + return 0 + return 1 + def client_poll(): - return len( client_POLLIN.poll(256- + return 0 if limit() else len( client_POLLIN.poll(256- (256*len( server_POLLIN.poll(0))) )) def server_poll(): - return len( server_POLLIN.poll(256- + return 0 if limit() else len( server_POLLIN.poll(256- (256*len( client_POLLIN.poll(0))) )) diff --git a/src/urcd.pyx b/src/urcd.pyx
--- a/src/urcd.pyx +++ b/src/urcd.pyx @@ -12,6 +12,7 @@ import sys import re import os +LIMIT = 1 NICKLEN = 32 TOPICLEN = 512 CHANLIMIT = 64 @@ -68,8 +69,16 @@ client_POLLIN.register(rd,3) server_POLLIN=select.poll() server_POLLIN.register(sd,3) +now = time.time() +def limit(): + if ((time.time() - now) > LIMIT): + global now + now = time.time() + return 0 + return 1 + def client_poll(): - return len( client_POLLIN.poll(256- + return 0 if limit() else len( client_POLLIN.poll(256- (256*len( server_POLLIN.poll(0))) )) diff --git a/src/urcrecv.pyx b/src/urcrecv.pyx
--- a/src/urcrecv.pyx +++ b/src/urcrecv.pyx @@ -1,9 +1,12 @@ #!/usr/bin/env python import socket +import time import pwd import sys import os +LIMIT = 1 + uid = pwd.getpwnam('urcd')[2] os.chdir(sys.argv[1]) os.chroot(os.getcwd()) @@ -25,6 +28,8 @@ while 1: if byte == '\n': break + time.sleep(LIMIT) + for path in os.listdir(root): try: sock.sendto(buffer,path) diff --git a/src/urcstream.pyx b/src/urcstream.pyx
--- a/src/urcstream.pyx +++ b/src/urcstream.pyx @@ -2,11 +2,13 @@ import socket import select import signal +import time import pwd import sys import os -user = str(os.getpid()) +user = str(os.getpid()) +LIMIT = 1 wr = 1 if int(os.getenv('TCPCLIENT',0)): @@ -44,8 +46,16 @@ client_POLLIN.register(rd,3) server_POLLIN=select.poll() server_POLLIN.register(sd,3) +now = time.time() +def limit(): + if ((time.time() - now) > LIMIT): + global now + now = time.time() + return 0 + return 1 + def client_poll(): - return len( client_POLLIN.poll(256- + return 0 if limit() else len( client_POLLIN.poll(256- (256*len( server_POLLIN.poll(0))) ))
-----END OF PAGE-----
-- Response ended
-- Page fetched on Sun Jun 2 18:23:37 2024