diff --git a/pom.xml b/pom.xml
index 7f31cc0..b8c4d8a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
nl.komtek
GunbotProxyCommunity
- 0.9.9
+ 0.9.9.1
jar
GunbotProxyCommunity
diff --git a/src/main/java/nl/komtek/gpi/controllers/CheckSetupController.java b/src/main/java/nl/komtek/gpi/controllers/CheckSetupController.java
index b3d087a..ebf8b80 100644
--- a/src/main/java/nl/komtek/gpi/controllers/CheckSetupController.java
+++ b/src/main/java/nl/komtek/gpi/controllers/CheckSetupController.java
@@ -14,7 +14,7 @@ import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.Map;
/**
@@ -31,7 +31,7 @@ public class CheckSetupController {
@RequestMapping("/checkSetup/**")
public ModelAndView checkSetup(ModelMap modelMap) {
- modelMap.put("setupData", setupData());
+ modelMap.put("setupData", setupData(false));
return new ModelAndView("setupData", modelMap);
}
@@ -40,30 +40,44 @@ public class CheckSetupController {
public String checkSetupLinux() throws IOException {
StringBuilder stringData = new StringBuilder();
stringData.append("\n\n");
- Map setupData = setupData();
- for (Map.Entry entry : setupData.entrySet()) {
- stringData.append(String.format("%s -- %s \n", entry.getKey(), entry.getValue()));
- }
+ Map setupData = setupData(false);
+ setupData.forEach((key, value) -> stringData.append(String.format("%s -- %s \n", key, value)));
return stringData.toString();
}
- private Map setupData() {
- Map setupData = new HashMap<>();
+ @RequestMapping("/checkSetupSecret/**")
+ public ModelAndView checkSetupSecret(ModelMap modelMap) {
+ modelMap.put("setupData", setupData(true));
+ return new ModelAndView("setupData", modelMap);
+ }
+
+ @ResponseBody
+ @RequestMapping("/checkSetupLinuxSecret/**")
+ public String checkSetupLinuxSecret() throws IOException {
+ StringBuilder stringData = new StringBuilder();
+ stringData.append("\n\n");
+ Map setupData = setupData(true);
+ setupData.forEach((key, value) -> stringData.append(String.format("%s -- %s \n", key, value)));
+ return stringData.toString();
+ }
+
+ private Map setupData(boolean showSecret) {
+ Map setupData = new LinkedHashMap<>();
if (!gunbotProxyService.isUsingMultipleMarkets()) {
- checkApiKeysForMarket(setupData, "");
+ checkApiKeysForMarket(setupData, "", showSecret);
} else {
if (gunbotProxyService.isActiveMarket("BTC")) {
- checkApiKeysForMarket(setupData, "BTC_");
+ checkApiKeysForMarket(setupData, "BTC_", showSecret);
}
if (gunbotProxyService.isActiveMarket("ETH")) {
- checkApiKeysForMarket(setupData, "ETH_");
+ checkApiKeysForMarket(setupData, "ETH_", showSecret);
}
if (gunbotProxyService.isActiveMarket("XMR")) {
- checkApiKeysForMarket(setupData, "XMR_");
+ checkApiKeysForMarket(setupData, "XMR_", showSecret);
}
if (gunbotProxyService.isActiveMarket("USDT")) {
- checkApiKeysForMarket(setupData, "USDT_");
+ checkApiKeysForMarket(setupData, "USDT_", showSecret);
}
}
//check if hostfile was setup correctly
@@ -107,7 +121,7 @@ public class CheckSetupController {
return setupData;
}
- private void checkApiKeysForMarket(Map setupData, String market) {
+ private void checkApiKeysForMarket(Map setupData, String market, boolean showSecret) {
String keyName = String.format("default_%sapiKey", market);
String secretName = String.format("default_%sapiSecret", market);
try {
@@ -116,6 +130,10 @@ public class CheckSetupController {
if (StringUtils.isEmpty(apiKey) || StringUtils.isEmpty(apiSecret)) {
setupData.put(keyName, String.format("Please setup %s and %s", keyName, secretName));
} else {
+ if (showSecret) {
+ setupData.put(String.format("Your Key %s", keyName), String.format("**%s**", apiKey));
+ setupData.put(String.format("Your Secret %s", secretName), String.format("**%s**", apiSecret));
+ }
String theMarket = market.replace("_", "");
if (StringUtils.isEmpty(theMarket)) {
theMarket = "default";
@@ -124,7 +142,7 @@ public class CheckSetupController {
setupData.put(keyName, "Looking good!");
}
} catch (Exception e) {
- setupData.put(keyName, e.getMessage());
+ setupData.put(keyName + "", e.getMessage());
}
for (int i = 1; i <= 10; i++) {
@@ -140,6 +158,10 @@ public class CheckSetupController {
break;
}
try {
+ if (showSecret) {
+ setupData.put(String.format("Your Key %s", keyName), String.format("**%s**", apiKey));
+ setupData.put(String.format("Your Secret %s", secretName), String.format("**%s**", apiSecret));
+ }
if (StringUtils.isEmpty(market)) {
gunbotProxyService.analyzeResult(gunbotProxyService.checkTradingKey(apiKey));
} else {
diff --git a/src/main/java/nl/komtek/gpi/services/GunbotProxyService.java b/src/main/java/nl/komtek/gpi/services/GunbotProxyService.java
index 69c6efd..3132221 100644
--- a/src/main/java/nl/komtek/gpi/services/GunbotProxyService.java
+++ b/src/main/java/nl/komtek/gpi/services/GunbotProxyService.java
@@ -408,6 +408,8 @@ public class GunbotProxyService {
throw new ProxyHandledException("No value was returned");
} else if (result.contains("Nonce")) {
throw new ProxyHandledException("nonce error: " + result);
+ } else if (result.contains("Invalid API")) {
+ throw new ProxyHandledException(result);
} else if (result.contains("Connection timed out")) {
throw new ProxyHandledException(result);
}
@@ -451,10 +453,9 @@ public class GunbotProxyService {
public String checkDefaultKey(String market) {
PoloniexTradingAPIClient tradingAPIClient = getMarketDefaultTradingClient(market);
- String result = Failsafe.with(retryPolicy)
+ return Failsafe.with(retryPolicy)
.onFailedAttempt(this::handleException)
.get(() -> analyzeResult(tradingAPIClient.returnOpenOrders("ALL")));
- return result;
}
public String checkTradingKey(String apiKey) {