Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anuken
2021-01-02 11:58:43 -05:00
2 changed files with 16 additions and 8 deletions

View File

@@ -563,25 +563,32 @@ public class JoinDialog extends BaseDialog{
transient Host lastHost;
void setIP(String ip){
//parse ip:port, if unsuccessful, use default values
if(ip.lastIndexOf(':') != -1 && ip.lastIndexOf(':') != ip.length() - 1){
try{
try{
boolean isIpv6 = Strings.count(ip, ':') > 1;
if(isIpv6 && ip.lastIndexOf("]:") != -1 && ip.lastIndexOf("]:") != ip.length() - 1){
int idx = ip.indexOf("]:");
this.ip = ip.substring(1, idx);
this.port = Integer.parseInt(ip.substring(idx + 2, ip.length()));
}else if(!isIpv6 && ip.lastIndexOf(':') != -1 && ip.lastIndexOf(':') != ip.length() - 1){
int idx = ip.lastIndexOf(':');
this.ip = ip.substring(0, idx);
this.port = Integer.parseInt(ip.substring(idx + 1));
}catch(Exception e){
}else{
this.ip = ip;
this.port = Vars.port;
}
}else{
}catch(Exception e){
this.ip = ip;
this.port = Vars.port;
}
}
String displayIP(){
return ip + (port != Vars.port ? ":" + port : "");
if(Strings.count(ip, ':') > 1){
return port != Vars.port ? "[" + ip + "]:" + port : ip;
}else{
return ip + (port != Vars.port ? ":" + port : "");
}
}
public Server(){