Skip to content

Commit 9d5d738

Browse files
committed
Add local domain - fixes #2
1 parent 715d1fd commit 9d5d738

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
},
2121
"dependencies": {
2222
"dbus": "^1.0.7",
23+
"dnssd": "^0.4.1",
2324
"dompurify": "^2.0.12",
2425
"express": "^4.17.1",
2526
"jsonwebtoken": "^8.5.1",

services/broadcast.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use strict';
2+
3+
const dnssd = require('dnssd');
4+
5+
/**
6+
* The broadcast service advertises a .local domain for the kiosk's web server
7+
* using DNS-SD, which resolves to its local IP address using mDNS.
8+
*/
9+
class Broadcast {
10+
11+
/**
12+
* Start the broadcast service.
13+
*
14+
* @param {number} port Port number of HTTP server to broadcast.
15+
*/
16+
start(port) {
17+
const broadcast = new dnssd.Advertisement(
18+
dnssd.tcp('http'),
19+
port,
20+
{
21+
'name': 'Krellian Kiosk',
22+
'host': 'kiosk'
23+
}
24+
);
25+
broadcast.on('error', (e) => {
26+
console.error('Error broadcasting local domain ' + e);
27+
});
28+
broadcast.start();
29+
console.log('Broadcasting local domain kiosk.local...');
30+
}
31+
}
32+
33+
module.exports = new Broadcast();

services/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const express = require('express');
22
const router = require('./router');
33
const database = require('./database');
4+
const broadcast = require('./broadcast');
45
const credentials = require('./models/credentials');
56
const network = require('./models/network');
67
const userAgent = require('./models/user-agent');
@@ -43,6 +44,10 @@ var Services = {
4344

4445
// Start user agent
4546
userAgent.start();
47+
48+
// Start DNS-SD broadcast
49+
broadcast.start(port);
50+
4651
},
4752

4853
setChrome: function(chrome) {

0 commit comments

Comments
 (0)