Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var fs = require('fs');
var libc = require('../../lib/detect-libc.js');
var result = { };
result['libc.family'] = libc.family || 'unknown';
result['libc.version'] = libc.version || 'unknown';
result['detect.method'] = libc.method || 'unknown';
result['node.version'] = process.versions.node;
var osRelease =
(fs.existsSync('/etc/os-release')
? fs.readFileSync('/etc/os-release', 'utf8')
: ''
)
.split('\n')
.filter(function (item) { return item.indexOf('=') !== -1; })
.map(function (item) { return item.split('=', 2); })
.reduce(function (obj, item) {
obj[item[0].trim()] = item[1].trim().replace(/^"(.+)"$/, '$1');
return obj;
}, { });
result['dist.name'] = osRelease.PRETTY_NAME || 'unknown';
if (navigator.languages||navigator.userLanguage||navigator.browserLanguage||navigator.language) {
properties["user.locale"]=$_String((navigator.languages || [navigator.userLanguage||navigator.browserLanguage||navigator.language])[0]);
}
if (navigator.appVersion !== undefined) {
properties["browser.version"] = $_String(navigator.appVersion);
}
}
if (typeof process !== "undefined") {
if (process.platform !== undefined) {
properties["os.name"] = $_String(process.platform);
}
if (process.arch !== undefined) {
properties["os.arch"] = $_String(process.arch);
}
if (process.versions !== undefined && process.versions.node != undefined) {
properties["node.version"] = $_String(process.versions.node);
}
}
if (typeof document !== "undefined") {
if (document.defaultCharset !== undefined) {
properties["file.encoding"] = $_String(document.defaultCharset);
}
}
var linesep = '\n';
var filesep = '/';
var pathsep = ':';
var osname = properties["os.name"];
if ((osname !== undefined) && (osname.search(/win/i) >= 0 && osname.search(/darwin/i)<0)) {
linesep = "\r\n";
filesep = '\\';
pathsep = ';';
buildNodeCtrlPanel:function(nodeObj) {
if(UserFilterCache.nomapping){
return;//权限设置
}
var sb=new StringBuffer();
var nodeCtrlUrl=this.getNodeCtrlUrl(nodeObj);
var nodeObjStr=StringHelper.obj2str({id:nodeObj["id"],name:nodeObj["name"],url:nodeCtrlUrl,ip:nodeObj["ip"],pid:nodeObj["node.pid"],pname:nodeObj["name"],profile:nodeObj["node.profile"],
version:nodeObj["node.version"] == undefined ? "UNKNOW" : nodeObj["node.version"],nodeRoot:nodeObj["node.root"],
dockerContainer:nodeObj["node.docker.container"] == undefined ? "{}" : nodeObj["node.docker.container"]});
//权限设置
var groupName = nodeObj.group;
var ctrlAuthor = false;
if(UserFilterCache.ctrls[groupName]!=undefined && UserFilterCache.ctrls[groupName]["nodectrl"] !=undefined && UserFilterCache.ctrls[groupName]["nodectrl"]=="T"){
ctrlAuthor=true;
}
if(UserFilterCache.all || ctrlAuthor){
//设置系统属性
sb.append("<button class="\"btn">修改属性</button>");
//重启Node
sb.append(" <button class="\"btn">配置管理</button>");
sb.append(" <button class="\"btn">重启节点</button>");
sb.append(" <button class="\"btn">停止节点</button>");
" <span class="\"kvField\"">配置</span><span>:</span>"+jsonObj["node.profile"] +
" " +
" <div class="\"kv\"">" +
" <span class="\"kvField\"">能力</span><span>:</span>"+this.formatter.feature(jsonObj["node.feature"],jsonObj) +
" </div>" +
" <div class="\"kv\"">" +
" <span class="\"kvField\"">Http服务</span><span>:</span>"+this.formatter.services(jsonObj["node.services"]) +
" </div>" +
" <div class="\"kv\"">" +
" <span class="\"kvField\"">所属心跳地址</span><span>:</span>"+jsonObj["node.hbserver"] +
" </div>" +
" <div class="\"kv\"">" +
" <span class="\"kvField\"">路径</span><span>:</span>"+jsonObj["node.root"] +
" </div>" +
" <div class="\"kv\"">" +
" <span class="\"kvField\"">版本</span><span>:</span>"+jsonObj["node.version"] +
" </div>" +
" <div class="\"kv\"">" +
" <span class="\"kvField\"">端口</span><span>:</span>";
var macinfo=app.mdata("macinfo");
var procs=eval("("+macinfo[jsonObj["ip"]]["node.procs"]+")");
var pid=jsonObj["node.pid"];
for (var key in procs) {
if (pid==key) {
str+=procs[key]["ports"];
break;
}
}
str+="</div>";