feat(core): support configurable port, clear collision error handling and discovery proposal
This commit is contained in:
+16
-3
@@ -510,21 +510,34 @@ public class CyberCoreDesktopApplication extends Application {
|
||||
}
|
||||
};
|
||||
|
||||
int targetPort = resolveConfiguredPort();
|
||||
try {
|
||||
this.ccspServer = new CcspServer(this.certificateManager, this.signingService, promptListener);
|
||||
this.ccspServer = new CcspServer(targetPort, this.certificateManager, this.signingService, ApplicationRegistry.getInstance(), promptListener);
|
||||
this.ccspServer.start();
|
||||
logger.info("Servidor local CCSP/1 inicializado na porta {}", this.ccspServer.getPort());
|
||||
} catch (java.net.BindException be) {
|
||||
logger.warn("Porta 21325 já está ocupada por outra instância do CyberCore Signer em execução. O agente continuará ativo na interface gráfica.");
|
||||
logger.warn("ALERTA DE COLISÃO DE PORTA: A porta {} já está ocupada por outra instância do CyberCore Signer ou outro serviço. Para usar outra porta, configure CYBERCORE_PORT ou use --port <porta>. O agente continuará ativo na interface gráfica.", targetPort);
|
||||
} catch (Exception e) {
|
||||
if (e.getCause() instanceof java.net.BindException || (e.getMessage() != null && e.getMessage().contains("Address already in use"))) {
|
||||
logger.warn("Porta 21325 já está ocupada por outra instância do CyberCore Signer em execução. O agente continuará ativo na interface gráfica.");
|
||||
logger.warn("ALERTA DE COLISÃO DE PORTA: A porta {} já está ocupada por outra instância do CyberCore Signer ou outro serviço. Para usar outra porta, configure CYBERCORE_PORT ou use --port <porta>. O agente continuará ativo na interface gráfica.", targetPort);
|
||||
} else {
|
||||
logger.error("Falha ao inicializar servidor local CCSP/1: {}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int resolveConfiguredPort() {
|
||||
String env = System.getenv("CYBERCORE_PORT");
|
||||
if (env != null && !env.isBlank()) {
|
||||
try { return Integer.parseInt(env.trim()); } catch (Exception ignored) {}
|
||||
}
|
||||
String prop = System.getProperty("cybercore.port");
|
||||
if (prop != null && !prop.isBlank()) {
|
||||
try { return Integer.parseInt(prop.trim()); } catch (Exception ignored) {}
|
||||
}
|
||||
return CcspServer.DEFAULT_PORT;
|
||||
}
|
||||
|
||||
private void initSmartCardWatcher() {
|
||||
if (Boolean.getBoolean("cybercore.diag.no-smartcard-watcher")) {
|
||||
logger.warn("Diagnóstico: Monitor dinâmico de smart cards DESATIVADO via -Dcybercore.diag.no-smartcard-watcher=true");
|
||||
|
||||
Reference in New Issue
Block a user