Add hostname of user machine (because sometimes the cpu is the same of multiple machines)

This commit is contained in:
Laurent Clouet
2015-03-09 16:55:15 +00:00
parent 640926110b
commit a4ccc19349
2 changed files with 4 additions and 1 deletions

View File

@@ -13,6 +13,7 @@ Parameters as GET:
* cpu_cores: Number of core (or thread) available. * cpu_cores: Number of core (or thread) available.
* ram: Memory available in bytes. * ram: Memory available in bytes.
* extras (optional): Extra data use for the configuration. * extras (optional): Extra data use for the configuration.
* hostname (optional): Hostname of the machine, it's useful when the user have multiple machines with same hardware configuration. It's only used for display for server website.
Answer in case of error: Answer in case of error:
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>

View File

@@ -33,6 +33,7 @@ import java.io.StringWriter;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.ConnectException; import java.net.ConnectException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.NoRouteToHostException; import java.net.NoRouteToHostException;
import java.net.URL; import java.net.URL;
@@ -163,7 +164,7 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
OS os = OS.getOS(); OS os = OS.getOS();
HttpURLConnection connection = null; HttpURLConnection connection = null;
try { try {
String url_contents = String.format("%s%s?login=%s&password=%s&cpu_family=%s&cpu_model=%s&cpu_model_name=%s&cpu_cores=%s&os=%s&ram=%s&bits=%s&version=%s&extras=%s", String url_contents = String.format("%s%s?login=%s&password=%s&cpu_family=%s&cpu_model=%s&cpu_model_name=%s&cpu_cores=%s&os=%s&ram=%s&bits=%s&version=%s&hostname=%s&extras=%s",
this.base_url, this.base_url,
"/server/config.php", "/server/config.php",
URLEncoder.encode(this.user_config.login(), "UTF-8"), URLEncoder.encode(this.user_config.login(), "UTF-8"),
@@ -176,6 +177,7 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
os.getMemory(), os.getMemory(),
os.getCPU().arch(), os.getCPU().arch(),
this.user_config.getJarVersion(), this.user_config.getJarVersion(),
URLEncoder.encode(InetAddress.getLocalHost().getHostName(), "UTF-8"),
this.user_config.getExtras()); this.user_config.getExtras());
this.log.debug("Server::getConfiguration url " + url_contents); this.log.debug("Server::getConfiguration url " + url_contents);