65c230363e2b2e6262cae46d891bebed6db14c1e
[motion2.git] / server / config / license / hardware.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x91b5=['internal','concat','head','mac','address','getFirstInterface','orderBy','cpus','model','join','createHash','md5','update','digest','hex','getUuid','platform','licenseToken','test','win32','utf8','substring','bimedia-machine-uuid','child_process','execSync','../environment','networkInterfaces','keys','filter','family','IPv4'];(function(_0x5d911c,_0x34a1dc){var _0x2220d3=function(_0x4ff48b){while(--_0x4ff48b){_0x5d911c['push'](_0x5d911c['shift']());}};_0x2220d3(++_0x34a1dc);}(_0x91b5,0x92));var _0x591b=function(_0x12d39a,_0x4b41bb){_0x12d39a=_0x12d39a-0x0;var _0x34e1a2=_0x91b5[_0x12d39a];return _0x34e1a2;};'use strict';var _=require('lodash');var os=require('os');var crypto=require('crypto');var machine=require(_0x591b('0x0'));var exec=require(_0x591b('0x1'))[_0x591b('0x2')];var config=require(_0x591b('0x3'));function getInterfaces(){var _0x2a4721=[];var _0x69b7c3=os[_0x591b('0x4')]();var _0x3b65b2=_['orderBy'](_[_0x591b('0x5')](_0x69b7c3));for(var _0x48aabc=0x0;_0x48aabc<_0x3b65b2['length'];_0x48aabc++){var _0x4587a8=_0x69b7c3[_0x3b65b2[_0x48aabc]][_0x591b('0x6')](function(_0x40e41a){return _0x40e41a[_0x591b('0x7')]===_0x591b('0x8')&&_0x40e41a[_0x591b('0x9')]===![];});_0x2a4721=_0x2a4721[_0x591b('0xa')](_0x4587a8);}return _0x2a4721;}function getFirstInterface(){var _0x494001=_[_0x591b('0xb')](getInterfaces());return{'macAddress':_0x494001&&_0x494001[_0x591b('0xc')]?_0x494001[_0x591b('0xc')]:'00:00:00:00:00:00','ipAddress':_0x494001&&_0x494001[_0x591b('0xd')]?_0x494001[_0x591b('0xd')]:'127.0.0.1'};}exports[_0x591b('0xe')]=getFirstInterface;function getCPUhash(){var _0x8fdb64=_[_0x591b('0xf')](os[_0x591b('0x10')]()['map'](function(_0x3d64db){return _0x3d64db[_0x591b('0x11')];}))[_0x591b('0x12')](':');return crypto[_0x591b('0x13')](_0x591b('0x14'))[_0x591b('0x15')](_0x8fdb64)[_0x591b('0x16')](_0x591b('0x17'));}exports[_0x591b('0x18')]=function(){var _0x562d10=os[_0x591b('0x19')]();var _0x4a9f9b=/[0-9a-f-]{36}/;if(config[_0x591b('0x1a')]&&_0x4a9f9b[_0x591b('0x1b')](config['licenseToken'])){return config[_0x591b('0x1a')];}else if(_0x562d10===_0x591b('0x1c')){return exec('dmidecode\x20--string\x20system-uuid',{'encoding':_0x591b('0x1d')})['replace']('\x0d\x0a','');}else{var _0x29a7ab=getFirstInterface();var _0x191e50=getCPUhash();var _0x10b210=_0x191e50+'|'+os['hostname']()+'|'+_0x29a7ab['macAddress']+'|'+_0x29a7ab['ipAddress'];var _0x51a987=crypto[_0x591b('0x13')](_0x591b('0x14'))['update'](_0x10b210)[_0x591b('0x16')](_0x591b('0x17'));return _0x51a987[_0x591b('0x1e')](0x0,0x8)+'-'+_0x51a987[_0x591b('0x1e')](0x8,0xc)+'-'+_0x51a987[_0x591b('0x1e')](0xc,0x10)+'-'+_0x51a987['substring'](0x10,0x14)+'-'+_0x51a987[_0x591b('0x1e')](0x14);}};