|
|
|
@ -2,6 +2,8 @@ package us.codecraft.webmagic.proxy;
|
|
|
|
|
|
|
|
|
|
public class Proxy {
|
|
|
|
|
|
|
|
|
|
private String scheme;
|
|
|
|
|
|
|
|
|
|
private String host;
|
|
|
|
|
|
|
|
|
|
private int port;
|
|
|
|
@ -11,8 +13,13 @@ public class Proxy {
|
|
|
|
|
private String password;
|
|
|
|
|
|
|
|
|
|
public Proxy(String host, int port) {
|
|
|
|
|
this(host, port, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Proxy(String host, int port, String scheme) {
|
|
|
|
|
this.host = host;
|
|
|
|
|
this.port = port;
|
|
|
|
|
this.scheme = scheme;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Proxy(String host, int port, String username, String password) {
|
|
|
|
@ -22,6 +29,14 @@ public class Proxy {
|
|
|
|
|
this.password = password;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getScheme() {
|
|
|
|
|
return scheme;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setScheme(String scheme) {
|
|
|
|
|
this.scheme = scheme;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getHost() {
|
|
|
|
|
return host;
|
|
|
|
|
}
|
|
|
|
@ -47,6 +62,7 @@ public class Proxy {
|
|
|
|
|
|
|
|
|
|
if (port != proxy.port) return false;
|
|
|
|
|
if (host != null ? !host.equals(proxy.host) : proxy.host != null) return false;
|
|
|
|
|
if (scheme != null ? !scheme.equals(proxy.scheme) : proxy.scheme != null) return false;
|
|
|
|
|
if (username != null ? !username.equals(proxy.username) : proxy.username != null) return false;
|
|
|
|
|
return password != null ? password.equals(proxy.password) : proxy.password == null;
|
|
|
|
|
}
|
|
|
|
@ -55,6 +71,7 @@ public class Proxy {
|
|
|
|
|
public int hashCode() {
|
|
|
|
|
int result = host != null ? host.hashCode() : 0;
|
|
|
|
|
result = 31 * result + port;
|
|
|
|
|
result = 31 * result + (scheme != null ? scheme.hashCode() : 0);
|
|
|
|
|
result = 31 * result + (username != null ? username.hashCode() : 0);
|
|
|
|
|
result = 31 * result + (password != null ? password.hashCode() : 0);
|
|
|
|
|
return result;
|
|
|
|
@ -62,12 +79,8 @@ public class Proxy {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String toString() {
|
|
|
|
|
return "Proxy{" +
|
|
|
|
|
"host='" + host + '\'' +
|
|
|
|
|
", port=" + port +
|
|
|
|
|
", username='" + username + '\'' +
|
|
|
|
|
", password='" + password + '\'' +
|
|
|
|
|
'}';
|
|
|
|
|
return String.format("Proxy{scheme='%1$s', host='%2$s', port=%3$d, username='%4$s', password='%5$s'}",
|
|
|
|
|
scheme, host, port, username, password);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|