fix STOP server
authorNiki Roo <niki@nikiroo.be>
Thu, 14 May 2020 15:37:05 +0000 (17:37 +0200)
committerNiki Roo <niki@nikiroo.be>
Thu, 14 May 2020 15:37:05 +0000 (17:37 +0200)
src/be/nikiroo/fanfix/Main.java

index c02abb387c0309ad79a8cba66d79733af22a775a..35365444682489d81adf7b25ed864416d6c47abe 100644 (file)
@@ -643,11 +643,25 @@ public class Main {
                                break;
                        case STOP_SERVER:
                                // Can be given via "--remote XX XX XX"
-                               if (key == null)
-                                       key = Instance.getInstance().getConfig().getString(Config.SERVER_KEY);
-                               if (port == null)
+                               if (key == null) {
+                                       key = Instance.getInstance().getConfig()
+                                                       .getString(Config.SERVER_KEY);
+                                       
+                                       // If a subkey in RW mode exists, use it
+                                       for (String subkey : Instance.getInstance().getConfig()
+                                                       .getList(Config.SERVER_ALLOWED_SUBKEYS,
+                                                                       new ArrayList<String>())) {
+                                               if ((subkey + "|").contains("|rw|")) {
+                                                       key = key + "|" + subkey;
+                                                       break;
+                                               }
+                                       }
+                               }
+                               
+                               if (port == null) {
                                        port = Instance.getInstance().getConfig().getInteger(Config.SERVER_PORT);
-
+                               }
+                               
                                if (host == null) {
                                        String mode = Instance.getInstance().getConfig()
                                                        .getString(Config.SERVER_MODE, "fanfix");