only:whitelabel

This commit is contained in:
rusefillc 2024-06-12 22:59:09 -04:00
parent 9d13c565ce
commit af54091e55
4 changed files with 28 additions and 8 deletions

View File

@ -0,0 +1,2 @@
auto_update_root_url=https://rusefi.com/build_server
WHITELABEL=rusEFI

View File

@ -83,7 +83,7 @@ public class Autoupdate {
private static void doDownload(BundleUtil.BundleInfo bundleInfo, UpdateMode mode) {
if (bundleInfo.getBranchName().equals("snapshot")) {
System.out.println("Snapshot requested");
downloadAndUnzipAutoupdate(bundleInfo, mode, ConnectionAndMeta.getBaseUrl()+ ConnectionAndMeta.AUTOUPDATE);
downloadAndUnzipAutoupdate(bundleInfo, mode, ConnectionAndMeta.getBaseUrl() + ConnectionAndMeta.AUTOUPDATE);
} else {
downloadAndUnzipAutoupdate(bundleInfo, mode, ConnectionAndMeta.getBaseUrl() + "/lts/" + bundleInfo.getBranchName() + ConnectionAndMeta.AUTOUPDATE);
}

View File

@ -3,6 +3,7 @@ package com.rusefi.autodetect;
import com.devexperts.logging.Logging;
import com.rusefi.binaryprotocol.IncomingDataBuffer;
import com.rusefi.config.generated.Fields;
import com.rusefi.core.net.ConnectionAndMeta;
import com.rusefi.io.IoStream;
import com.rusefi.io.commands.HelloCommand;
import com.rusefi.io.serial.BufferedSerialIoStream;
@ -48,7 +49,7 @@ public class SerialAutoChecker {
if (!checkResponseCode(response))
return null;
String signature = new String(response, 1, response.length - 1);
if (!signature.startsWith(Fields.PROTOCOL_SIGNATURE_PREFIX)) {
if (!isSignatureWithValidPrefix(signature)) {
return null;
}
log.info("Got signature=" + signature + " from " + stream);
@ -61,6 +62,13 @@ public class SerialAutoChecker {
}
}
private static boolean isSignatureWithValidPrefix(String signature) {
if (signature.startsWith(Fields.PROTOCOL_SIGNATURE_PREFIX))
return true;
String whitelabel = ConnectionAndMeta.getWhitelabel();
return whitelabel != null && signature.startsWith(whitelabel + " ");
}
public void openAndCheckResponse(PortDetector.DetectorMode mode, AtomicReference<AutoDetectResult> result, Function<CallbackContext, Void> callback) {
String signature;
// java 101: just a reminder that try-with syntax would take care of closing stream and that's important here!
@ -128,9 +136,9 @@ public class SerialAutoChecker {
@Override
public String toString() {
return "AutoDetectResult{" +
"serialPort='" + serialPort + '\'' +
", signature='" + signature + '\'' +
'}';
"serialPort='" + serialPort + '\'' +
", signature='" + signature + '\'' +
'}';
}
}
}

View File

@ -28,17 +28,27 @@ public class ConnectionAndMeta {
}
public static String getBaseUrl() {
String result = getProperties().getProperty("auto_update_root_url");
System.out.println(ConnectionAndMeta.class + ": got [" + result + "]");
return result;
}
public static String getWhitelabel() {
String whitelabel = getProperties().getProperty("WHITELABEL");
whitelabel = whitelabel == null ? null : whitelabel.trim();
return whitelabel;
}
private static Properties getProperties() throws RuntimeException {
Properties props = new Properties();
try {
InputStream stream = ConnectionAndMeta.class.getResourceAsStream(IO_PROPERTIES);
Objects.requireNonNull(stream, "Error reading " + IO_PROPERTIES);
props.load(stream);
return props;
} catch (IOException e) {
throw new RuntimeException(e);
}
String result = props.getProperty("auto_update_root_url");
System.out.println(ConnectionAndMeta.class + ": got [" + result + "]");
return result;
}
public static String getDefaultAutoUpdateUrl() {