summaryrefslogtreecommitdiff
path: root/proxy.py
diff options
context:
space:
mode:
authorYves <yvesf-git@xapek.org>2010-03-13 12:47:23 +0100
committerYves <yvesf-git@xapek.org>2010-03-13 12:47:23 +0100
commit90892bd87d5422822f3e0541399a6324b11d74da (patch)
tree80ceb004b3d4d50a1bd971a1094b19b6de550626 /proxy.py
parent068d5d5bb4e37e88ee4828e8cd9fd0e4e05e1445 (diff)
downloadmagicproxy-90892bd87d5422822f3e0541399a6324b11d74da.tar.gz
magicproxy-90892bd87d5422822f3e0541399a6324b11d74da.zip
Use proxy address instead of endpoint index
Diffstat (limited to 'proxy.py')
-rwxr-xr-xproxy.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/proxy.py b/proxy.py
index 2522abd..b79672c 100755
--- a/proxy.py
+++ b/proxy.py
@@ -31,15 +31,14 @@ FETCHER_JUMPSTART = 32 * kB
#################
class Fetcher(asynchat.async_chat):
- def __init__(self, reader, endpoint, url, headers, range):
+ def __init__(self, reader, proxy, url, headers, range):
self.reader = reader
- self.endpoint = endpoint
+ self.proxy = proxy
self.url = url
self.headers = headers
self.range = range
self.pos = self.range[0]
- self.proxy = ENDPOINTS[endpoint]
self.start_time = 0
self.stop_time = 0
self.http_status = ""
@@ -110,8 +109,8 @@ class MultipleProxyReader(object):
self.blocks = list()
self.fetchers = list()
- for i in range(len(ENDPOINTS)):
- self.fetchers.append( Fetcher(self, i, self.url, self.header, self.next_range(INIT_BLOCKSIZE)) )
+ for proxy in ENDPOINTS:
+ self.fetchers.append( Fetcher(self, proxy, self.url, self.header, self.next_range(INIT_BLOCKSIZE)) )
def handle_incoming_data(self, fetcher, data):
if len(data) == 0:
@@ -121,12 +120,12 @@ class MultipleProxyReader(object):
if fetcher.range[1] - fetcher.pos < FETCHER_JUMPSTART \
and self.fetch_pos + 1 < self.content_length and not self.channel.is_closed \
- and len( filter( (lambda f: f.endpoint == fetcher.endpoint), self.fetchers) ) < 2:
+ and len( filter( (lambda f: f.proxy == fetcher.proxy), self.fetchers) ) < 2:
#Start a new fetcher on this line if this fetchers is X-Bytes before finishing his jobs
blocksize = min(TIME_SLICE * int(fetcher.speed()), MIN_BLOCKSIZE)
fetch_range = self.next_range(blocksize)
print "Start new Fetcher, bs=%s range=%s" % (blocksize,fetch_range)
- self.fetchers.append( Fetcher(self, fetcher.endpoint, self.url, self.header, fetch_range) )
+ self.fetchers.append( Fetcher(self, fetcher.proxy, self.url, self.header, fetch_range) )
while self.send_next_data():
pass