mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-14 10:34:06 +02:00
desktop mobile QR fixes (#6069)
This commit is contained in:
@@ -1183,4 +1183,25 @@ public class GeneralUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLocalNetworkIp() {
|
||||||
|
try {
|
||||||
|
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
|
||||||
|
if (interfaces == null) return null;
|
||||||
|
while (interfaces.hasMoreElements()) {
|
||||||
|
NetworkInterface iface = interfaces.nextElement();
|
||||||
|
if (!iface.isUp() || iface.isLoopback() || iface.isVirtual()) continue;
|
||||||
|
Enumeration<InetAddress> addresses = iface.getInetAddresses();
|
||||||
|
while (addresses.hasMoreElements()) {
|
||||||
|
InetAddress addr = addresses.nextElement();
|
||||||
|
if (addr instanceof Inet4Address && addr.isSiteLocalAddress()) {
|
||||||
|
return addr.getHostAddress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Failed to detect local network IP", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-1
@@ -20,6 +20,7 @@ import stirling.software.SPDF.config.InitialSetup;
|
|||||||
import stirling.software.SPDF.controller.api.security.TimestampController;
|
import stirling.software.SPDF.controller.api.security.TimestampController;
|
||||||
import stirling.software.common.annotations.api.ConfigApi;
|
import stirling.software.common.annotations.api.ConfigApi;
|
||||||
import stirling.software.common.configuration.AppConfig;
|
import stirling.software.common.configuration.AppConfig;
|
||||||
|
import stirling.software.common.util.GeneralUtils;
|
||||||
import stirling.software.common.model.ApplicationProperties;
|
import stirling.software.common.model.ApplicationProperties;
|
||||||
import stirling.software.common.service.ServerCertificateServiceInterface;
|
import stirling.software.common.service.ServerCertificateServiceInterface;
|
||||||
import stirling.software.common.service.UserServiceInterface;
|
import stirling.software.common.service.UserServiceInterface;
|
||||||
@@ -122,8 +123,16 @@ public class ConfigController {
|
|||||||
configData.put("contextPath", appConfig.getContextPath());
|
configData.put("contextPath", appConfig.getContextPath());
|
||||||
configData.put("serverPort", appConfig.getServerPort());
|
configData.put("serverPort", appConfig.getServerPort());
|
||||||
|
|
||||||
// Add frontendUrl for mobile scanner QR codes
|
|
||||||
String frontendUrl = applicationProperties.getSystem().getFrontendUrl();
|
String frontendUrl = applicationProperties.getSystem().getFrontendUrl();
|
||||||
|
if ((frontendUrl == null || frontendUrl.isBlank())
|
||||||
|
&& Boolean.parseBoolean(
|
||||||
|
System.getProperty("STIRLING_PDF_TAURI_MODE", "false"))) {
|
||||||
|
String localIp = GeneralUtils.getLocalNetworkIp();
|
||||||
|
if (localIp != null) {
|
||||||
|
String scheme = appConfig.getBackendUrl().startsWith("https") ? "https" : "http";
|
||||||
|
frontendUrl = scheme + "://" + localIp + ":" + appConfig.getServerPort();
|
||||||
|
}
|
||||||
|
}
|
||||||
configData.put("frontendUrl", frontendUrl != null ? frontendUrl : "");
|
configData.put("frontendUrl", frontendUrl != null ? frontendUrl : "");
|
||||||
|
|
||||||
// Add mobile scanner settings
|
// Add mobile scanner settings
|
||||||
@@ -385,4 +394,5 @@ public class ConfigController {
|
|||||||
boolean enabled = endpointConfiguration.isGroupEnabled(group);
|
boolean enabled = endpointConfiguration.isGroupEnabled(group);
|
||||||
return ResponseEntity.ok(enabled);
|
return ResponseEntity.ok(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user