Commit 880b873c authored by zeroleak's avatar zeroleak
Browse files

add ApiCliStateResponse.version

parent b4dd950e
......@@ -17,7 +17,7 @@
<dependency>
<groupId>io.samourai.code.whirlpool</groupId>
<artifactId>whirlpool-client</artifactId>
<version>0.23.19</version>
<version>develop-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
......@@ -126,6 +126,7 @@
<execution>
<goals>
<goal>repackage</goal>
<goal>build-info</goal>
</goals>
<configuration>
<classifier>run</classifier>
......
......@@ -39,13 +39,7 @@ public class CliController extends AbstractRestController {
public ApiCliStateResponse state(@RequestHeader HttpHeaders headers) throws Exception {
checkHeaders(headers);
ApiCliStateResponse response =
new ApiCliStateResponse(
cliWalletService.getCliState(),
cliConfig.getServer(),
cliConfig.computeServerUrl(),
cliConfig.getDojo().getUrl(),
cliConfig.getTor(),
cliConfig.isDojoEnabled());
new ApiCliStateResponse(cliWalletService.getCliState(), cliConfig);
return response;
}
......
......@@ -2,7 +2,7 @@ package com.samourai.whirlpool.cli.api.protocol.rest;
import com.samourai.whirlpool.cli.beans.CliState;
import com.samourai.whirlpool.cli.beans.CliStatus;
import com.samourai.whirlpool.client.wallet.beans.WhirlpoolServer;
import com.samourai.whirlpool.cli.config.CliConfig;
public class ApiCliStateResponse {
private CliStatus cliStatus;
......@@ -16,25 +16,20 @@ public class ApiCliStateResponse {
private String dojoUrl;
private boolean tor;
private boolean dojo;
private String version;
public ApiCliStateResponse(
CliState cliState,
WhirlpoolServer server,
String serverUrl,
String dojoUrl,
boolean tor,
boolean dojo) {
public ApiCliStateResponse(CliState cliState, CliConfig cliConfig) {
this.cliStatus = cliState.getCliStatus();
this.cliMessage = cliState.getCliMessage();
this.loggedIn = cliState.isLoggedIn();
this.torProgress = cliState.getTorProgress();
this.network = server.getParams().getPaymentProtocolId();
this.serverUrl = serverUrl;
this.serverName = server.name();
this.dojoUrl = dojoUrl;
this.tor = tor;
this.dojo = dojo;
this.network = cliConfig.getServer().getParams().getPaymentProtocolId();
this.serverUrl = cliConfig.computeServerUrl();
this.serverName = cliConfig.getServer().name();
this.dojoUrl = cliConfig.getDojo().getUrl();
this.tor = cliConfig.getTor();
this.dojo = cliConfig.isDojoEnabled();
this.version = cliConfig.getBuildVersion();
}
public CliStatus getCliStatus() {
......@@ -76,4 +71,8 @@ public class ApiCliStateResponse {
public boolean isDojo() {
return dojo;
}
public String getVersion() {
return version;
}
}
......@@ -18,7 +18,9 @@ import javax.validation.constraints.NotEmpty;
import org.apache.logging.log4j.util.Strings;
import org.bitcoinj.core.NetworkParameters;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.info.BuildProperties;
import org.springframework.context.annotation.Configuration;
@ConfigurationProperties(prefix = "cli")
......@@ -43,6 +45,8 @@ public abstract class CliConfigFile {
@NotEmpty private MixConfig mix;
@NotEmpty private ApiConfig api;
@Autowired BuildProperties buildProperties;
private static final String PUSHTX_AUTO = "auto";
private static final String PUSHTX_INTERACTIVE = "interactive";
......@@ -66,6 +70,7 @@ public abstract class CliConfigFile {
this.requestTimeout = copy.requestTimeout;
this.api = new ApiConfig(copy.api);
this.mix = new MixConfig(copy.mix);
this.buildProperties = copy.buildProperties;
}
public int getVersion() {
......@@ -544,6 +549,11 @@ public abstract class CliConfigFile {
configInfo.put("cli/proxy", proxy != null ? ClientUtils.maskString(proxy) : "null");
configInfo.putAll(mix.getConfigInfo());
configInfo.putAll(api.getConfigInfo());
configInfo.put("cli/buildVersion", getBuildVersion() != null ? getBuildVersion() : "null");
return configInfo;
}
public String getBuildVersion() {
return buildProperties != null ? buildProperties.getVersion() : null;
}
}
......@@ -92,7 +92,7 @@ public class CliService {
log.info("------------ whirlpool-client-cli starting ------------");
log.info(
"Running whirlpool-client-cli on java {}... {}",
"Running whirlpool-client-cli " + cliConfig.getBuildVersion() + " on java {}... {}",
System.getProperty("java.version"),
Arrays.toString(args));
......
......@@ -2,6 +2,7 @@
spring.main.banner-mode=off
logging.level.org.springframework=WARN
logging.level.org.apache=WARN
build.version=@project.version@
# https
server.ssl.key-store-type=PKCS12
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment