-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProxyClass.java
More file actions
50 lines (44 loc) · 1.66 KB
/
Copy pathProxyClass.java
File metadata and controls
50 lines (44 loc) · 1.66 KB
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
41
42
43
44
45
46
47
48
49
50
package proxies;
import java.net.Proxy;
import java.net.Proxy.Type;
public class ProxyClass implements Comparable<ProxyClass> {
public short ping = (short) (Math.pow(2, 15)-1);
public String proxy;
public String exitAddress = "";
private double uptime;
public int times_checked;
public int times_up;
public int failed_consecutive; //more than n, delete proxy
public Type type;
public String anon; //Anonymous, elite, transparent
public String CO; //Country code
public boolean dead = false;
public long last_checked = 0;
public long last_used = 0;
public int compareTo(ProxyClass p){
return p.ping < this.ping && System.currentTimeMillis() - p.last_checked < 30000 && System.currentTimeMillis() - p.last_used > 30000 ? 1 : -1; //checked less than 30 seconds ago, last used more than 30 seconds
}
public double getUptime(){
return (times_up/times_checked)*100D;
}
public ProxyClass(String proxy, String... args){ //sets proxy, type, anon, CO. in that order
this.proxy = proxy;
type = Proxy.Type.valueOf("HTTP");
for(int i = 0;i<args.length;i++){
switch(i){
case 0:
type = Proxy.Type.valueOf(args[i]);
break;
case 1:
anon = args[i];
break;
case 2:
CO = args[i];
break;
}
}
}
public String toString(){
return String.format("%s %dms dead:%b lastChecked:%d", proxy, ping, dead, last_checked);
}
}