Skip to content

Commit

Permalink
🐛 Fix ytmdesktop#296
Browse files Browse the repository at this point in the history
  • Loading branch information
adlerluiz committed Aug 8, 2020
1 parent 083cb2c commit faf5d4c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
4 changes: 4 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1612,13 +1612,17 @@ if (!gotTheLock) {
})

app.on('before-quit', function (e) {
mainWindow = null
view = null
if (isMac()) {
app.exit()
}
tray.quit()
})

app.on('quit', function () {
mainWindow = null
view = null
tray.quit()
})
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"start": "electron .",
"rebuild": "electron-rebuild -f",
"postinstall": "npx electron-builder install-app-deps",
"deploy:win": "npx electron-builder --win --config electron-builder-deploy64.yml",
"deploy:mac": "npx electron-builder --mac --config electron-builder-deploy64.yml",
"deploy:lin": "npx electron-builder --linux --config electron-builder-deploy64.yml",
"build:win": "npx electron-builder --win --config electron-builder-deploy64.yml",
"build:mac": "npx electron-builder --mac --config electron-builder-deploy64.yml",
"build:lin": "npx electron-builder --linux --config electron-builder-deploy64.yml",
"publish:win": "npx electron-builder --win -p always --config electron-builder64.yml",
"publish:mac": "npx electron-builder --mac -p always --config electron-builder64.yml",
"publish:lin": "npx electron-builder --linux -p always --config electron-builder64.yml"
Expand Down
27 changes: 20 additions & 7 deletions src/providers/companionServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ const networkInterfaces = os.networkInterfaces()
const qrcode = require('qrcode-generator')
const infoPlayerProvider = require('../providers/infoPlayerProvider')
const settingsProvider = require('../providers/settingsProvider')
const { deprecate } = require('util')

const ip = '0.0.0.0'
const port = 9863
const hostname = os.hostname()

const pattIgnoreInterface = /(virtual|wsl|vEthernet|Default Switch|VMware|Adapter)\w*/gim
const pattIgnoreInterface = /(Loopback|virtual|wsl|vEthernet|Default Switch|VMware|Adapter|Hamachi)\w*/gim

let totalConnections = 0
let timerTotalConections
Expand All @@ -34,7 +33,20 @@ function infoServer() {
}

function fetchNetworkInterfaces() {
Object.keys(networkInterfaces).forEach((v, k) => {
serverInterfaces = Object.entries(networkInterfaces)
.filter(([interfaces]) => !pattIgnoreInterface.test(interfaces))
.map(([name, value]) => {
value = value.filter((data) => {
return data.family == 'IPv4' && data.internal == false
})
return {
name: name,
ip: value[0].address,
isProtected: infoServer().isProtected,
}
})

/*Object.keys(networkInterfaces).forEach((v, k) => {
if (!pattIgnoreInterface.test(v)) {
networkInterfaces[v].forEach((vv, kk) => {
if (vv.family == 'IPv4' && vv.internal == false) {
Expand All @@ -47,15 +59,17 @@ function fetchNetworkInterfaces() {
}
})
}
})
})*/
}

var serverFunction = function (req, res) {
if (req.url === '/') {
var collection = ''
let collection = ''
let isProtected = infoServer().isProtected

serverInterfaces.forEach((value) => {
let qr = qrcode(6, 'H')
let qr = qrcode(0, 'H')
value['hostname'] = hostname
qr.addData(JSON.stringify(value))
qr.make()

Expand Down Expand Up @@ -88,7 +102,6 @@ var serverFunction = function (req, res) {
res.setHeader('Access-Control-Allow-Origin', '*')
res.writeHead(200)

let isProtected = infoServer().isProtected
res.write(`<html>
<head>
<title>YTMDesktop Remote Control</title>
Expand Down

0 comments on commit faf5d4c

Please sign in to comment.