cobbzilla/s3s3mirror

Problem with setting proxy

Closed this issue · 1 comments

Hi,
In the MirrorMain.java file when setting the proxy, proxy_port will never be set since after setting the proxy_host, options_getHasProxy will become true and it will skip the proxy_port setting.
Here is the code:
else if (!options.getHasProxy() && line.trim().startsWith("proxy_host")) {
options.setProxyHost(line.substring(line.indexOf("=") + 1).trim());
} else if (!options.getHasProxy() && line.trim().startsWith("proxy_port")){
options.setProxyPort(Integer.parseInt(line.substring(line.indexOf("=") + 1).trim()));
}

I modify as follows:
String proxyHost = null;
Integer proxyPort = null;
while ((line = reader.readLine()) != null) {
if (line.trim().startsWith("access_key")) {
options.setAWSAccessKeyId(line.substring(line.indexOf("=") + 1).trim());
} else if (line.trim().startsWith("secret_key")) {
options.setAWSSecretKey(line.substring(line.indexOf("=") + 1).trim());
} else if (!options.getHasProxy() && line.trim().startsWith("proxy_host")) {
proxyHost = line.substring(line.indexOf("=") + 1).trim();
} else if (!options.getHasProxy() && line.trim().startsWith("proxy_port")){
proxyPort = Integer.parseInt(line.substring(line.indexOf("=") + 1).trim());
}
}
if(proxyHost != null && proxyPort != null){
options.setProxyHost(proxyHost);
options.setProxyPort(proxyPort);
}

Best,
Shasha

@shasha-chen good find -- could you submit a pull request? I would be happy to merge it.