Merge branch 'upcoming' of https://github.com/ciderapp/Cider into upcoming
This commit is contained in:
commit
6570043ab0
2 changed files with 52 additions and 14 deletions
|
@ -37,6 +37,7 @@
|
||||||
"express": "^4.17.2",
|
"express": "^4.17.2",
|
||||||
"get-port": "^5.1.1",
|
"get-port": "^5.1.1",
|
||||||
"lastfmapi": "^0.1.1",
|
"lastfmapi": "^0.1.1",
|
||||||
|
"mdns-js": "github:bitfocus/node-mdns-js",
|
||||||
"mpris-service": "^2.1.2",
|
"mpris-service": "^2.1.2",
|
||||||
"music-metadata": "^7.11.4",
|
"music-metadata": "^7.11.4",
|
||||||
"qrcode": "^1.5.0",
|
"qrcode": "^1.5.0",
|
||||||
|
|
|
@ -103,6 +103,9 @@ export class Win {
|
||||||
// Register listeners on Window to track size and position of the Window.
|
// Register listeners on Window to track size and position of the Window.
|
||||||
windowState.manage(this.win);
|
windowState.manage(this.win);
|
||||||
|
|
||||||
|
// Start Remote Discovery
|
||||||
|
this.broadcastRemote()
|
||||||
|
|
||||||
return this.win;
|
return this.win;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,6 +201,8 @@ export class Win {
|
||||||
*/
|
*/
|
||||||
const remote = express();
|
const remote = express();
|
||||||
remote.use(express.static(path.join(this.paths.srcPath, "./web-remote/")))
|
remote.use(express.static(path.join(this.paths.srcPath, "./web-remote/")))
|
||||||
|
getPort({port: 6942}).then((port) => {
|
||||||
|
this.remotePort = port;
|
||||||
remote.listen(this.remotePort, () => {
|
remote.listen(this.remotePort, () => {
|
||||||
console.log(`Cider remote port: ${this.remotePort}`);
|
console.log(`Cider remote port: ${this.remotePort}`);
|
||||||
if (firstRequest) {
|
if (firstRequest) {
|
||||||
|
@ -213,6 +218,7 @@ export class Win {
|
||||||
}
|
}
|
||||||
firstRequest = false;
|
firstRequest = false;
|
||||||
})
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -477,4 +483,35 @@ export class Win {
|
||||||
return { action: "deny" };
|
return { action: "deny" };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async broadcastRemote() {
|
||||||
|
function getIp() {
|
||||||
|
let ip :any = false;
|
||||||
|
let alias = 0;
|
||||||
|
const ifaces: any = os.networkInterfaces() ;
|
||||||
|
for (var dev in ifaces) {
|
||||||
|
ifaces[dev].forEach( (details: any) => {
|
||||||
|
if (details.family === 'IPv4') {
|
||||||
|
if (!/(loopback|vmware|internal|hamachi|vboxnet|virtualbox)/gi.test(dev + (alias ? ':' + alias : ''))) {
|
||||||
|
if (details.address.substring(0, 8) === '192.168.' ||
|
||||||
|
details.address.substring(0, 7) === '172.16.' ||
|
||||||
|
details.address.substring(0, 3) === '10.'
|
||||||
|
) {
|
||||||
|
ip = details.address;
|
||||||
|
++alias;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}) ;
|
||||||
|
}
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
const myString = `http://${getIp()}:${this.remotePort}`;
|
||||||
|
var mdns = require('mdns-js');
|
||||||
|
const encoded = new Buffer(myString).toString('base64');
|
||||||
|
var x = mdns.tcp('cider-remote');
|
||||||
|
let server2 = mdns.createAdvertisement(x, `${await getPort({port: 3839})}`, { name: encoded });
|
||||||
|
server2.start();
|
||||||
|
console.log('remote broadcasted')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue