You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

85 lines
2.2 KiB

const os = require('os')
const path = require('path')
const mkdirp = require('mkdirp')
const config = {
background: '#ffffff',
margins: 0.005,
style: 'default',
nbPicture: 4,
cropSize: {
width: 900,
height: 1200
},
pictNames: [],
layout: [],
booths: {},
paths: {
final: '',
template: '',
prebuilt: '',
original: '',
toprint: ''
},
footer: 'm-30ansv2.jpg'
}
config.server = {
ipAddress: getIpAddress(),
port: 3111
}
config.killZone = {
top: 2,
bottom: 2,
left: 25,
right: 25
}
// Init PATH
config.paths.template = path.resolve(__dirname, './server/public/rsc/template')
config.footer = path.resolve(__dirname, './server/public/rsc/footer', config.footer)
config.paths.final = path.resolve(__dirname, './output/final')
config.paths.final_ld = path.resolve(__dirname, './output/final_ld')
config.paths.prebuilt = path.resolve(__dirname, './output/cache')
config.paths.original = path.resolve(__dirname, './output/original')
config.paths.toprint = path.resolve(__dirname, './output/toprint')
mkdirp.sync(config.paths.final)
mkdirp.sync(config.paths.final_ld)
mkdirp.sync(config.paths.prebuilt)
mkdirp.sync(config.paths.original)
mkdirp.sync(config.paths.toprint)
// Init pinctures names
for (let index = 0; index < config.nbPicture; index++) {
config.pictNames.push('pict_' + index + '.jpg')
}
module.exports = config
function getIpAddress () {
let ipAddress = 'localhost'
// Get local server ip address
let ifaces = os.networkInterfaces()
Object.keys(ifaces).forEach(function (ifname) {
let alias = 0
ifaces[ifname].forEach(function (iface) {
// skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
if (iface.family !== 'IPv4' || iface.internal !== false) return
if (/wlan/i.test(ifname)) ipAddress = iface.address
if (alias >= 1) {
// this single interface has multiple ipv4 addresses
// console.log(`[-] network: ${ifname} : ${alias} - ${iface.address}`)
} else {
// this interface has only one ipv4 adress
// console.log(`[-] network: ${ifname} - ${iface.address}`)
// console.log(ifname, iface.address)
}
})
})
return ipAddress
}