res change example
This commit is contained in:
10
index.js
10
index.js
@@ -10,7 +10,8 @@ const express = require("express"); // could be good to replace with c
|
||||
// Get port or default to 8082
|
||||
const port = process.env.PORT || 8082;
|
||||
const protocol = process.env.PROTOCOL || 'https'
|
||||
const subclass = process.env.SUBCLASS || '192.168.4.'
|
||||
const subclass = process.env.SUBCLASS || '192.168.0.' // defaulting to IP used at home rather than RPi0. Could also change it there as it's not justified beside helping distinction.
|
||||
// Object.values(require("os").networkInterfaces()).flat().filter(({ family, internal }) => family === "IPv4" && !internal).map(({ address }) => address)[0].split('.').slice(0,3).join('.')+'.'
|
||||
|
||||
const publicKeyPath = path.resolve(process.env.HOME,'.ssh','id_rsa_offlineoctopus.pub')
|
||||
const publicKey = fs.readFileSync(publicKeyPath).toString().split(' ')[1]
|
||||
@@ -66,6 +67,10 @@ const utilsCmd = { // security risk but for now not accepting user input so safe
|
||||
'listprototypes': { cmd: 'ls', context: {cwd: propath},
|
||||
format: res => res.toString().split('\n')
|
||||
},
|
||||
// per device specific (until adjustable per user)
|
||||
'highresscreen' : { cmd: 'xrandr --output DP-4 --mode 3840x2160'},
|
||||
'lowresscreen' : { cmd: 'xrandr --output DP-4 --mode 1920x1080'},
|
||||
|
||||
//'npmfind' : { desc: 'package manager finder', cmd: 'find . -wholename "*node_modules/acorn"' },
|
||||
// security risk if relying on user provided name, e.g replacing acorn by user input
|
||||
// example that could be generalized to other package managers e.g .deb or opkg
|
||||
@@ -372,6 +377,9 @@ function getSshConfig(){
|
||||
easier to revoke if need be
|
||||
*/
|
||||
|
||||
app.get('/resolution/high', (req, res) => { res.json( execConfiguredCommand('highresscreen') ) })
|
||||
app.get('/resolution/low', (req, res) => { res.json( execConfiguredCommand('lowresscreen') ) })
|
||||
|
||||
app.get('/localprototypes', (req, res) => {
|
||||
// examples to disentangle own work for cloned existing repositories :
|
||||
// find Prototypes/ -iwholename */.git/config | xargs grep git.benetou.fr
|
||||
|
||||
Reference in New Issue
Block a user