roster-server 2.1.10 → 2.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +10 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -5,6 +5,7 @@ const https = require('https');
|
|
|
5
5
|
const tls = require('tls');
|
|
6
6
|
const { EventEmitter } = require('events');
|
|
7
7
|
const Greenlock = require('./vendor/greenlock-express/greenlock-express.js');
|
|
8
|
+
const GreenlockShim = require('./vendor/greenlock-express/greenlock-shim.js');
|
|
8
9
|
const log = require('lemonlog')('roster');
|
|
9
10
|
|
|
10
11
|
// CRC32 implementation for deterministic port assignment
|
|
@@ -707,7 +708,7 @@ class Roster {
|
|
|
707
708
|
return this.startLocalMode();
|
|
708
709
|
}
|
|
709
710
|
|
|
710
|
-
const
|
|
711
|
+
const greenlockOptions = {
|
|
711
712
|
packageRoot: __dirname,
|
|
712
713
|
configDir: this.greenlockStorePath,
|
|
713
714
|
maintainerEmail: this.email,
|
|
@@ -724,6 +725,13 @@ class Roster {
|
|
|
724
725
|
else if (event === 'warning') log.warn(msg);
|
|
725
726
|
else log.info(msg);
|
|
726
727
|
}
|
|
728
|
+
};
|
|
729
|
+
// Keep a direct greenlock runtime handle so we can call get() explicitly under Bun
|
|
730
|
+
// before binding :443, avoiding invalid non-TLS responses on startup.
|
|
731
|
+
const greenlockRuntime = GreenlockShim.create(greenlockOptions);
|
|
732
|
+
const greenlock = Greenlock.init({
|
|
733
|
+
...greenlockOptions,
|
|
734
|
+
greenlock: greenlockRuntime
|
|
727
735
|
});
|
|
728
736
|
|
|
729
737
|
return greenlock.ready(async glx => {
|
|
@@ -852,7 +860,7 @@ class Roster {
|
|
|
852
860
|
const certSubject = primaryDomain.startsWith('*.') ? wildcardRoot(primaryDomain) : primaryDomain;
|
|
853
861
|
log.warn(`⚠️ Bun runtime detected and cert files missing for ${primaryDomain}; requesting certificate via Greenlock before HTTPS bind`);
|
|
854
862
|
try {
|
|
855
|
-
await
|
|
863
|
+
await greenlockRuntime.get({ servername: certSubject });
|
|
856
864
|
} catch (error) {
|
|
857
865
|
log.error(`❌ Failed to obtain certificate for ${certSubject} under Bun:`, error?.message || error);
|
|
858
866
|
}
|