-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.py
More file actions
executable file
·38 lines (31 loc) · 946 Bytes
/
proxy.py
File metadata and controls
executable file
·38 lines (31 loc) · 946 Bytes
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import attr
@attr.s(cmp=False)
class Proxy:
ip = attr.ib()
port = attr.ib()
create_time = attr.ib()
source = attr.ib()
state = attr.ib(default=200)
user = attr.ib(default=None)
pwd = attr.ib(default=None)
used_times = attr.ib(default=0)
expired_time = attr.ib(default=None)
validate_time = attr.ib(default=None)
protocol = attr.ib(default='http')
anonymous = attr.ib(default=False)
def to_dict(self):
return self.__dict__
@property
def proxy_url(self):
if self.user:
return f'{self.protocol}://{self.user}:{self.pwd}@{self.ip}:{self.port}'
else:
return f'{self.protocol}://{self.ip}:{self.port}'
def __hash__(self):
return hash(self.ip)
def __eq__(self, other):
if isinstance(other, self.__class__):
return self.ip == other.ip
return False