forked from Bitwise-01/Instagram-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproxy.py
40 lines (33 loc) · 1008 Bytes
/
proxy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Date: 12/28/2018
# Author: Mohamed
# Description: Proxy
import time
import typing
class Proxy(object):
def __init__(self, ip: str, port: int, addr: typing.Dict) -> None:
self.__ip = ip
self.__port = port
self.__total_used = 0
self.__total_passed = 0
self.__last_used = None
self.__addr = addr
@property
def addr(self) -> dict:
self.__total_used += 1
self.__last_used = time.time()
return self.__addr
def incr_success(self) -> None:
"""Incremented when proxy works"""
self.__total_passed += 1
def decr_usage(self) -> None:
"""Takes away usage data for this session"""
self.__total_used = 0
self.__total_passed = 0
def info(self) -> dict:
return {
"ip": self.__ip,
"port": self.__port,
"last_used": self.__last_used,
"total_used": self.__total_used,
"total_passed": self.__total_passed,
}