* Check if port is valid before setting it
* Validate user input
* Change proxyPort to int
This commit is contained in:
yushijinhun
2018-12-16 15:49:57 +08:00
parent 176968d883
commit 9f060be3fd
5 changed files with 21 additions and 13 deletions

View File

@@ -43,7 +43,7 @@ public class LaunchOptions implements Serializable {
private String serverIp;
private String wrapper;
private String proxyHost;
private String proxyPort;
private int proxyPort;
private String proxyUser;
private String proxyPass;
private boolean noGeneratedJVMArgs;
@@ -160,7 +160,7 @@ public class LaunchOptions implements Serializable {
/**
* the port of the proxy address.
*/
public String getProxyPort() {
public int getProxyPort() {
return proxyPort;
}
@@ -275,7 +275,7 @@ public class LaunchOptions implements Serializable {
return this;
}
public Builder setProxyPort(String proxyPort) {
public Builder setProxyPort(int proxyPort) {
options.proxyPort = proxyPort;
return this;
}

View File

@@ -162,11 +162,11 @@ public class DefaultLauncher extends Launcher {
if (options.isFullscreen())
res.add("--fullscreen");
if (StringUtils.isNotBlank(options.getProxyHost()) && StringUtils.isNotBlank(options.getProxyPort())) {
if (StringUtils.isNotBlank(options.getProxyHost())) {
res.add("--proxyHost");
res.add(options.getProxyHost());
res.add("--proxyPort");
res.add(options.getProxyPort());
res.add(String.valueOf(options.getProxyPort()));
if (StringUtils.isNotBlank(options.getProxyUser()) && StringUtils.isNotBlank(options.getProxyPass())) {
res.add("--proxyUser");
res.add(options.getProxyUser());