roster-server 3.4.1 → 3.4.2

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 CHANGED
@@ -785,6 +785,12 @@ class Roster {
785
785
  }
786
786
  }
787
787
 
788
+ // Names the production site and the local URL that serves it, e.g. `example.com:3334 → tcp://localhost:6702`.
789
+ _describeLocalSite(domain, sitePort, localPort, scheme) {
790
+ const site = `${domain}${sitePort !== this.defaultPort ? ':' + sitePort : ''}`;
791
+ return `${site} → ${scheme}://${localHostForDomain(normalizeDomainForLocalHost(domain))}:${localPort}`;
792
+ }
793
+
788
794
  parseDomainWithPort(domainString) {
789
795
  const parts = domainString.split(':');
790
796
  if (parts.length === 2) {
@@ -1632,8 +1638,7 @@ class Roster {
1632
1638
  });
1633
1639
 
1634
1640
  await this._listen(httpServer, port, this.hostname);
1635
- const cleanDomain = normalizeDomainForLocalHost(domain);
1636
- log.info(`🌐 ${domain} → http://${localHostForDomain(cleanDomain)}:${port}`);
1641
+ log.info(`🌐 ${this._describeLocalSite(domain, Number(sitePort), port, 'http')}`);
1637
1642
  }
1638
1643
  }
1639
1644
 
@@ -56,15 +56,16 @@ class SiteWorkerRoster extends Roster {
56
56
  for (const key of this._site.keys) {
57
57
  if (key.startsWith('www.')) continue;
58
58
  const { domain, port } = this.parseDomainWithPort(key);
59
+ const localPort = this._site.localPorts[`${domain}:${port}`];
59
60
  const server = net.createServer({ pauseOnConnect: true });
60
- const listening = this._listen(server, this._site.localPorts[`${domain}:${port}`], this.hostname);
61
+ const listening = this._listen(server, localPort, this.hostname);
61
62
  server.on('connection', socket => {
62
63
  // The site owns the connection from here; it may pass it to another process.
63
64
  this._sockets.delete(socket);
64
65
  this._handOff(head, socket);
65
66
  });
66
67
  await listening;
67
- log.info(`🌐 ${domain} → tcp://localhost:${this._site.localPorts[`${domain}:${port}`]} (socket site)`);
68
+ log.info(`🌐 ${this._describeLocalSite(domain, port, localPort, 'tcp')} (socket site)`);
68
69
  }
69
70
  }
70
71
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roster-server",
3
- "version": "3.4.1",
3
+ "version": "3.4.2",
4
4
  "description": "👾 RosterServer - A domain host router to host multiple HTTPS.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -372,6 +372,14 @@ describe('Roster', () => {
372
372
  });
373
373
  });
374
374
 
375
+ describe('local site description', () => {
376
+ it('names the production port only when it differs from the default', () => {
377
+ const roster = new Roster({ local: true });
378
+ assert.strictEqual(roster._describeLocalSite('truco.example.com', 443, 6701, 'http'), 'truco.example.com → http://truco.localhost:6701');
379
+ assert.strictEqual(roster._describeLocalSite('truco.example.com', 3334, 6702, 'tcp'), 'truco.example.com:3334 → tcp://truco.localhost:6702');
380
+ });
381
+ });
382
+
375
383
  describe('getUrl (exact domain)', () => {
376
384
  it('returns http://localhost:PORT in local mode for registered domain', () => {
377
385
  const roster = new Roster({ local: true });