Skip to content

Commit

Permalink
Fix code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
RetGal committed Nov 3, 2023
1 parent 9af4d4f commit ff0c34b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/mpo/dayon/assistant/gui/Assistant.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void actionPerformed(ActionEvent ev) {
frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
publicIp = UPnP.getExternalIP();
if (publicIp == null || publicIp.startsWith("192.168") || publicIp.startsWith("10.")) {
if (isValidPublicIp()) {
final URL url = new URL(WHATSMYIP_SERVER_URL);
try (final BufferedReader lines = new BufferedReader(new InputStreamReader(url.openStream()))) {
publicIp = lines.readLine();
Expand Down Expand Up @@ -264,6 +264,10 @@ public void actionPerformed(ActionEvent ev) {

choices.setLocation(choicesLocation.x - xOffset, choicesLocation.y + yOffset);
}

private boolean isValidPublicIp() {
return ! (publicIp == null || publicIp.startsWith("192.168") || publicIp.startsWith("10."));
}
};
ip.putValue("DISPLAY_NAME", "127.0.0.1"); // always a selection
// ...
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/mpo/dayon/common/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ static File getOrCreateAppHomeDir() {
}

static void prepareKeystore(File appHomeDir) {
if (appHomeDir == null) {
Log.error("Skipping keystore creation, application directory is missing!");
}
Path keystore = Paths.get(format("%s%skeystore.jks", appHomeDir.getAbsolutePath(), File.separator));
if (!Files.exists(keystore)) {
Log.info(format("Creating new keystore [%s]", keystore));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ public X509Certificate[] getAcceptedIssuers() {

@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) {
// we want to trust our self-signed certificates
}

@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) {
// we want to trust our self-signed certificates
}

@java.lang.SuppressWarnings("squid:S6437") // pro forma password, without security relevance
Expand Down

0 comments on commit ff0c34b

Please sign in to comment.