mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-27 02:40:51 +01:00
show error when the IP is invalid
This commit is contained in:
parent
f1e5496837
commit
70261751d6
@ -7,11 +7,13 @@ import gearth.protocol.connection.HState;
|
||||
import gearth.protocol.connection.HStateSetter;
|
||||
import gearth.protocol.hostreplacer.ipmapping.IpMapper;
|
||||
import gearth.protocol.hostreplacer.ipmapping.IpMapperFactory;
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.layout.Region;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.*;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
@ -48,7 +50,23 @@ public class RawIpProxyProvider extends ProxyProvider {
|
||||
|
||||
Queue<Socket> preConnectedServerConnections = new LinkedList<>();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
preConnectedServerConnections.add(new Socket(proxy.getActual_domain(), proxy.getActual_port()));
|
||||
Socket s1 = new Socket();
|
||||
s1.setSoTimeout(1200);
|
||||
try {
|
||||
s1.connect(new InetSocketAddress(proxy.getActual_domain(), proxy.getActual_port()), 1200);
|
||||
}
|
||||
catch (SocketTimeoutException e) {
|
||||
stateSetter.setState(HState.NOT_CONNECTED);
|
||||
Platform.runLater(() -> {
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR, "You entered invalid connection information, G-Earth could not connect", ButtonType.OK);
|
||||
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
|
||||
alert.setResizable(false);
|
||||
alert.show();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
preConnectedServerConnections.add(s1);
|
||||
Thread.sleep(50);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user