Fix bug #45
This commit is contained in:
parent
7b2e77a08a
commit
30923d95eb
3 changed files with 48 additions and 16 deletions
2
pom.xml
2
pom.xml
|
@ -8,7 +8,7 @@
|
||||||
<name>NS-USBloader</name>
|
<name>NS-USBloader</name>
|
||||||
|
|
||||||
<artifactId>ns-usbloader</artifactId>
|
<artifactId>ns-usbloader</artifactId>
|
||||||
<version>2.0-SNAPSHOT</version>
|
<version>2.1-SNAPSHOT</version>
|
||||||
|
|
||||||
<url>https://github.com/developersu/ns-usbloader/</url>
|
<url>https://github.com/developersu/ns-usbloader/</url>
|
||||||
<description>
|
<description>
|
||||||
|
|
|
@ -124,20 +124,35 @@ public class NETCommunications extends Task<Void> { // todo: thows IOException?
|
||||||
catch (SocketException | UnknownHostException e2) {
|
catch (SocketException | UnknownHostException e2) {
|
||||||
logPrinter.print("NET: Can't get your computer IP using Renmin Ribao server. Returned:\n\t"+e2.getMessage(), EMsgType.FAIL);
|
logPrinter.print("NET: Can't get your computer IP using Renmin Ribao server. Returned:\n\t"+e2.getMessage(), EMsgType.FAIL);
|
||||||
logPrinter.print("Try using 'Expert mode' and set IP manually.", EMsgType.INFO);
|
logPrinter.print("Try using 'Expert mode' and set IP manually.", EMsgType.INFO);
|
||||||
|
this.showAvalIpExamples();
|
||||||
|
isValid = false;
|
||||||
|
close(EFileStatus.FAILED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Say hello to MacOS Catalina
|
||||||
|
// Also this part could be used instead of what we have above. One day it has to be tested on all platforms and fixed (replace code above).
|
||||||
|
if (hostIP.equals("0.0.0.0")) {
|
||||||
|
Socket scoketK;
|
||||||
try {
|
try {
|
||||||
Enumeration enumeration = NetworkInterface.getNetworkInterfaces();
|
scoketK = new Socket();
|
||||||
while (enumeration.hasMoreElements()) {
|
scoketK.connect(new InetSocketAddress("google.com", 80));
|
||||||
NetworkInterface n = (NetworkInterface) enumeration.nextElement();
|
hostIP = scoketK.getLocalAddress().getHostAddress();
|
||||||
Enumeration enumeration1 = n.getInetAddresses();
|
scoketK.close();
|
||||||
while (enumeration1.hasMoreElements()) {
|
} catch (Exception scoketKex) {
|
||||||
InetAddress i = (InetAddress) enumeration1.nextElement();
|
scoketKex.printStackTrace();
|
||||||
logPrinter.print("Check for: " + i.getHostAddress(), EMsgType.INFO);
|
logPrinter.print("NET: Can't get your computer IP using Google server (InetSocketAddress). Returned:\n\t"+scoketKex.getMessage(), EMsgType.INFO);
|
||||||
}
|
try {
|
||||||
}
|
scoketK = new Socket();
|
||||||
}
|
scoketK.connect(new InetSocketAddress("people.com.cn", 80));
|
||||||
catch (SocketException socketException) { // Good block.
|
hostIP = scoketK.getLocalAddress().getHostAddress();
|
||||||
logPrinter.print("Can't determine possible variants. Returned:\n\t"+socketException.getMessage(), EMsgType.FAIL);
|
scoketK.close();
|
||||||
}
|
} catch (Exception scoketKexx) {
|
||||||
|
scoketKex.printStackTrace();
|
||||||
|
logPrinter.print("NET: Can't get your computer IP using Renmin Ribao server (InetSocketAddress). Returned:\n\t"+scoketKexx.getMessage(), EMsgType.FAIL);
|
||||||
|
logPrinter.print("Try using 'Expert mode' and set IP manually.", EMsgType.INFO);
|
||||||
|
this.showAvalIpExamples();
|
||||||
isValid = false;
|
isValid = false;
|
||||||
close(EFileStatus.FAILED);
|
close(EFileStatus.FAILED);
|
||||||
return;
|
return;
|
||||||
|
@ -212,6 +227,23 @@ public class NETCommunications extends Task<Void> { // todo: thows IOException?
|
||||||
}
|
}
|
||||||
isValid = true;
|
isValid = true;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Show possible variants to log area
|
||||||
|
* */
|
||||||
|
private void showAvalIpExamples(){
|
||||||
|
try {
|
||||||
|
Enumeration<NetworkInterface> enumeration = NetworkInterface.getNetworkInterfaces();
|
||||||
|
while (enumeration.hasMoreElements()) {
|
||||||
|
NetworkInterface n = enumeration.nextElement();
|
||||||
|
Enumeration<InetAddress> enumeration1 = n.getInetAddresses();
|
||||||
|
while (enumeration1.hasMoreElements())
|
||||||
|
logPrinter.print("Check for: " + enumeration1.nextElement().getHostAddress(), EMsgType.INFO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SocketException socketException) { // Good block.
|
||||||
|
logPrinter.print("Can't determine possible variants. Returned:\n\t"+socketException.getMessage(), EMsgType.FAIL);
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Override cancel block to close connection by ourselves
|
* Override cancel block to close connection by ourselves
|
||||||
* */
|
* */
|
||||||
|
|
|
@ -13,7 +13,7 @@ import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class NSLMain extends Application {
|
public class NSLMain extends Application {
|
||||||
|
|
||||||
public static final String appVersion = "v2.0";
|
public static final String appVersion = "v2.1";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) throws Exception{
|
public void start(Stage primaryStage) throws Exception{
|
||||||
|
|
Loading…
Reference in a new issue