forked from iod/ControlProxy
410 lines
15 KiB
Plaintext
Executable File
410 lines
15 KiB
Plaintext
Executable File
//@范博
|
||
//以下接口都要给出示例参数
|
||
//类似于 @Descripton("参数为,{\"doId\":\"bdware.ss/Repox\"}")
|
||
module networking {
|
||
//前缀管理用到的接口 listLRS updateLRS createLRS deleteLRS
|
||
export function getRouterInfo(arg) {
|
||
if (!checkPermission(requester)) {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":"no permission", "code":1
|
||
});
|
||
}
|
||
var ret = executeContract(Global.router, "getRouterInfo", arg);
|
||
var obj = ret.result;
|
||
if (obj.result=="success" || obj.result == undefined) {
|
||
obj.result = undefined;
|
||
obj.code = 0;
|
||
} else {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":obj.data, "code":1
|
||
});
|
||
}
|
||
obj.data.status = "online";
|
||
obj.data.date-=1000*60*60*24*30*8;
|
||
obj.data.name = "山西广域数联网";
|
||
return obj;
|
||
}
|
||
export function listLRS(arg) {
|
||
if (!checkPermission(requester)) {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":"no permission", "code":1
|
||
});
|
||
}
|
||
var ret = executeContract(Global.router, "listLRS", "");
|
||
var obj = ret.result;
|
||
if (obj.result=="success" || obj.result == undefined) {
|
||
obj.result = undefined;
|
||
obj.code = 0;
|
||
} else {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":obj.data, "code":1
|
||
});
|
||
}
|
||
for (var i = 0;
|
||
i<obj.data.length;
|
||
i++){
|
||
obj.data[i].status = "online";
|
||
obj.data[i].date-=1000*60*60*24*30*8;
|
||
}
|
||
return obj;
|
||
}
|
||
|
||
@Descripton("参数为,{\"date\": 1642467459759,\"oldName\": \"路由器\",\"oldDoId\": \"bdwaretest.loccall.next0\",\"name\": \"next路由器\",\"doId\": \"bdwaretest.loccall.next1\",\"version\": \"2.1\",\"address\": \"127.0.0.1:2222\",\"status\": \"已审核\",\"protocol\": \"IRP\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
|
||
@ArgSchema({
|
||
"!date": "number", "!oldName": "string", "!oldDoId": "string", "!name": "string", "!doId": "string", "!version":"string", "!address": "string", "status": "string", "!protocol": "string", "!pubKey": "string"
|
||
})
|
||
export function updateLRS(arg) {
|
||
if (!checkPermission(requester)) {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":"no permission", "code":1
|
||
});
|
||
}
|
||
var ret = executeContract(Global.router, "updateLRS", arg);
|
||
var obj = ret.result;
|
||
if (obj.result=="success" || obj.result == undefined) {
|
||
obj.result = undefined;
|
||
obj.code = 0;
|
||
} else {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":obj.data, "code":1
|
||
});
|
||
}
|
||
return obj;
|
||
}
|
||
|
||
@Descripton("参数为,{\"date\": 1642467459759,\"name\": \"next路由器\",\"doId\": \"bdwaretest.loccall.next1\",\"version\": \"2.1\",\"address\": \"127.0.0.1:2222\",\"status\": \"已审核\",\"protocol\": \"IRP\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
|
||
@ArgSchema({
|
||
"!date": "number", "!name": "string", "!doId": "string", "!version":"string", "!address": "string", "status": "string", "!protocol": "string", "!pubKey": "string"
|
||
})
|
||
export function createLRS(arg) {
|
||
if (!checkPermission(requester)) {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":"no permission", "code":1
|
||
});
|
||
}
|
||
var ret = executeContract(Global.router, "createLRS", arg);
|
||
var obj = ret.result;
|
||
if (obj.result=="success" || obj.result == undefined) {
|
||
obj.result = undefined;
|
||
obj.code = 0;
|
||
} else {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":obj.data, "code":1
|
||
});
|
||
}
|
||
return obj;
|
||
}
|
||
|
||
@Descripton("参数为,{\"name\": \"next路由器\",\"doId\": \"bdwaretest.loccall.next1\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
|
||
@ArgSchema({
|
||
"!name": "string", "!doId": "string", "!pubKey": "string"
|
||
})
|
||
export function deleteLRS(arg) {
|
||
if (!checkPermission(requester)) {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":"no permission", "code":1
|
||
});
|
||
}
|
||
var ret = executeContract(Global.router, "deleteLRS", arg);
|
||
var obj = ret.result;
|
||
if (obj.result=="success" || obj.result == undefined) {
|
||
obj.result = undefined;
|
||
obj.code = 0;
|
||
} else {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":obj.data, "code":1
|
||
});
|
||
}
|
||
return obj;
|
||
}
|
||
//后缀管理用到的接口
|
||
export function listReposi(arg) {
|
||
if (!checkPermission(requester)) {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":"no permission", "code":1
|
||
});
|
||
}
|
||
var ret = executeContract(Global.router, "listRepo", "");
|
||
var obj = ret.result;
|
||
if (obj.result=="success" || obj.result == undefined) {
|
||
obj.result = undefined;
|
||
obj.code = 0;
|
||
} else {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":obj.data, "code":1
|
||
});
|
||
}
|
||
return obj;
|
||
}
|
||
|
||
@Descripton("参数为,{\"date\": 1642467459759,\"oldName\": \"Repo0\",\"oldDoId\": \"bdwaretest.loccall/Repo0\",\"name\": \"Repo1\",\"doId\": \"bdwaretest.loccall/Repo1\",\"version\": \"2.1\",\"address\": \"tcp://127.0.0.1:21042\",\"status\": \"已审核\",\"protocol\": \"DOIP\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
|
||
@ArgSchema({
|
||
"!date": "number", "!oldName": "string", "!oldDoId": "string", "!name": "string", "!doId": "string", "!version":"string", "!address": "string", "status": "string", "!protocol": "string", "!pubKey": "string"
|
||
})
|
||
export function updateReposi(arg) {
|
||
if (!checkPermission(requester)) {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":"no permission", "code":1
|
||
});
|
||
}
|
||
var ret = executeContract(Global.router, "updateRepo", arg);
|
||
var obj = ret.result;
|
||
if (obj.result=="success" || obj.result == undefined) {
|
||
obj.result = undefined;
|
||
obj.code = 0;
|
||
} else {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":obj.data, "code":1
|
||
});
|
||
}
|
||
return obj;
|
||
}
|
||
|
||
@Descripton("参数为,{\"date\": 1642467459759,\"name\": \"Repo1\",\"doId\": \"bdwaretest.loccall/Repo1\",\"version\": \"2.1\",\"address\": \"tcp://127.0.0.1:21042\",\"status\": \"已审核\",\"protocol\": \"DOIP\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
|
||
@ArgSchema({
|
||
"!date": "number", "!name": "string", "!doId": "string", "!version":"string", "!address": "string", "status": "string", "!protocol": "string", "!pubKey": "string"
|
||
})
|
||
export function createReposi(arg) {
|
||
if (!checkPermission(requester)) {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":"no permission", "code":1
|
||
});
|
||
}
|
||
var ret = executeContract(Global.router, "createRepo", arg);
|
||
var obj = ret.result;
|
||
if (obj.result=="success" || obj.result == undefined) {
|
||
obj.result = undefined;
|
||
obj.code = 0;
|
||
} else {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":obj.data, "code":1
|
||
});
|
||
}
|
||
return obj;
|
||
}
|
||
|
||
@Descripton("参数为,{\"name\": \"next路由器\",\"doId\": \"bdwaretest.loccall.next1\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
|
||
@ArgSchema({
|
||
"!name": "string", "!doId": "string", "!pubKey": "string"
|
||
})
|
||
export function deleteReposi(arg) {
|
||
if (!checkPermission(requester)) {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":"no permission", "code":1
|
||
});
|
||
}
|
||
var ret = executeContract(Global.router, "deleteRepo", arg);
|
||
var obj = ret.result;
|
||
if (obj.result=="success" || obj.result == undefined) {
|
||
obj.result = undefined;
|
||
obj.code = 0;
|
||
} else {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":obj.data, "code":1
|
||
});
|
||
}
|
||
return obj;
|
||
}
|
||
|
||
@Descripton("参数为,{\"date\": 1642467459759,\"name\": \"Repo1\",\"doId\": \"bdwaretest.loccall/Repo1\",\"version\": \"2.1\",\"address\": \"tcp://127.0.0.1:21042\",\"status\": \"已审核\",\"protocol\": \"DOIP\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
|
||
@ArgSchema({
|
||
"!date": "number", "!name": "string", "!doId": "string", "!version":"string", "!address": "string", "status": "string", "!protocol": "string", "!pubKey": "string"
|
||
})
|
||
export function setRootRouterInfo(arg) {
|
||
if (!checkPermission(requester)) {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":"no permission", "code":1
|
||
});
|
||
}
|
||
//if (Global.router == "Router") {
|
||
// return "failed";
|
||
//}
|
||
var ret = executeContract(Global.router, "setRootRouterInfo", arg);
|
||
var obj = ret.result;
|
||
if (obj.result=="success" || obj.result == undefined) {
|
||
obj.result = undefined;
|
||
obj.code = 0;
|
||
} else {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":obj.data, "code":1
|
||
});
|
||
}
|
||
return obj;
|
||
//return "success";
|
||
}
|
||
|
||
export function reInit(arg) {
|
||
if (!checkPermission(requester)) {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":"no permission", "code":1
|
||
});
|
||
}
|
||
if (Global.router == "GlobalRouter") {
|
||
return "failed";
|
||
}
|
||
var ret = executeContract(Global.router, "reInit", "");
|
||
var obj = ret.result;
|
||
if (obj.result=="verify and start server success" || obj.result == undefined) {
|
||
obj.code = 0;
|
||
} else {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":obj.result, "code":1
|
||
});
|
||
}
|
||
return obj;
|
||
}
|
||
@ArgSchema({
|
||
"!pubKey": "string"
|
||
})
|
||
export function setPubKey(arg) {
|
||
if (!checkPermission(requester)) {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":"no permission", "code":1
|
||
});
|
||
}
|
||
var ret = executeContract(Global.router, "setPubKey", arg);
|
||
var obj = ret.result;
|
||
if (obj.result=="success" || obj.result == undefined) {
|
||
obj.result = undefined;
|
||
obj.code = 0;
|
||
} else {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":obj.data, "code":1
|
||
});
|
||
}
|
||
return obj;
|
||
}
|
||
@ArgSchema({
|
||
"!upperIP": "string"
|
||
})
|
||
export function setUpperIP(arg) {
|
||
if (!checkPermission(requester)) {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":"no permission", "code":1
|
||
});
|
||
}
|
||
var ret = executeContract(Global.router, "setUpperIP", arg);
|
||
var obj = ret.result;
|
||
if (obj.result=="success" || obj.result == undefined) {
|
||
obj.result = undefined;
|
||
obj.code = 0;
|
||
} else {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":obj.data, "code":1
|
||
});
|
||
}
|
||
return obj;
|
||
}
|
||
@ArgSchema({
|
||
"!upperPort": "string"
|
||
})
|
||
export function setUpperPort(arg) {
|
||
if (!checkPermission(requester)) {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":"no permission", "code":1
|
||
});
|
||
}
|
||
var ret = executeContract(Global.router, "setUpperPort", arg);
|
||
var obj = ret.result;
|
||
if (obj.result=="success" || obj.result == undefined) {
|
||
obj.result = undefined;
|
||
obj.code = 0;
|
||
} else {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":obj.data, "code":1
|
||
});
|
||
}
|
||
return obj;
|
||
}
|
||
|
||
export function getUpperIP(arg) {
|
||
if (!checkPermission(requester)) {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":"no permission", "code":1
|
||
});
|
||
}
|
||
var ret = executeContract(Global.router, "getUpperIP", "");
|
||
var obj = ret.result;
|
||
if (obj.result=="success" || obj.result == undefined) {
|
||
obj.result = undefined;
|
||
obj.code = 0;
|
||
} else {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":obj.data, "code":1
|
||
});
|
||
}
|
||
return obj;
|
||
}
|
||
|
||
export function getUpperPort(arg) {
|
||
if (!checkPermission(requester)) {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":"no permission", "code":1
|
||
});
|
||
}
|
||
var ret = executeContract(Global.router, "getUpperPort", "");
|
||
return ret.result;
|
||
}
|
||
@ArgSchema({
|
||
"!signature": "string"
|
||
})
|
||
export function setSignature(arg) {
|
||
if (!checkPermission(requester)) {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":"no permission", "code":1
|
||
});
|
||
}
|
||
var ret = executeContract(Global.router, "setSignature", arg);
|
||
var obj = ret.result;
|
||
if (obj.result=="success" || obj.result == undefined) {
|
||
obj.result = undefined;
|
||
obj.code = 0;
|
||
} else {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":obj.data, "code":1
|
||
});
|
||
}
|
||
return obj;
|
||
}
|
||
@ArgSchema({
|
||
"!name": "string"
|
||
})
|
||
export function setName(arg) {
|
||
if (!checkPermission(requester)) {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":"no permission", "code":1
|
||
});
|
||
}
|
||
|
||
var ret = executeContract(Global.router, "setName", arg);
|
||
var obj = ret.result;
|
||
if (obj.result=="success" || obj.result == undefined) {
|
||
obj.result = undefined;
|
||
obj.code = 0;
|
||
} else {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":obj.data, "code":1
|
||
});
|
||
}
|
||
return obj;
|
||
}
|
||
@ArgSchema({
|
||
"!doId": "string", "!address":"string"
|
||
})
|
||
export function resolveDoId(arg) {
|
||
arg = convertArgToJson(arg);
|
||
var ret = executeContract(Global.router, "resolveTest", arg.doId);
|
||
var retObj = {
|
||
};
|
||
if (ret.status == "Success" && ret.result != undefined) {
|
||
retObj.data = ret.result;
|
||
retObj.code = 0;
|
||
} else {
|
||
YancloudUtil.exceptionReturn({
|
||
"msg":obj1, "code":1
|
||
});
|
||
}
|
||
return retObj;
|
||
}
|
||
}
|