forked from iod/ControlProxy
feat: support cpnode
This commit is contained in:
parent
c29538179f
commit
6c923801d1
122
TODO.md
Normal file
122
TODO.md
Normal file
@ -0,0 +1,122 @@
|
||||
# Router初始化过程
|
||||
|
||||
```json
|
||||
{
|
||||
"action": "executeContract",
|
||||
"requestID": "1650331954565_7775",
|
||||
"contractID": "GlobalRouter",
|
||||
"operation": "setRootRouterInfo",
|
||||
"arg": "{\"routerInfo\":\"{\\\"date\\\":1650331954565,\\\"name\\\":\\\"macjw.ab\\\",\\\"doId\\\":\\\"macjw.ab\\\",\\\"version\\\":\\\"2.1\\\",\\\"address\\\":\\\"127.0.0.1\\\",\\\"port\\\":\\\"2042\\\",\\\"status\\\":\\\"offline\\\",\\\"protocol\\\":\\\"IRP\\\",\\\"pubKey\\\":\\\"04f9b9b8f324908464f78a6235e2dd93e4dfdaf045e9b1b5cfd57374516cc61a79a86fc2b42d3321a5b49a0f25381a7bed61901b40b729f72354e716673d551e98\\\"}\"}",
|
||||
"pubkey": "04f9b9b8f324908464f78a6235e2dd93e4dfdaf045e9b1b5cfd57374516cc61a79a86fc2b42d3321a5b49a0f25381a7bed61901b40b729f72354e716673d551e98",
|
||||
"signature": "3045022100943e6327bc6bb8cdf651f68f1edb586aee8835e6f94e0d5a236c44f9f3140e940220240af1b770856ba592d033ca5a8530950e7985ca89e5c3b4d6d103cb2e0e251c"
|
||||
}
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"needSeq": false,
|
||||
"seq": 0,
|
||||
"status": "Success",
|
||||
"result": {
|
||||
"result": "success"
|
||||
},
|
||||
"isInsnLimit": false,
|
||||
"totalGas": 0,
|
||||
"executionGas": 0,
|
||||
"extraGas": 0,
|
||||
"size": 0,
|
||||
"eventRelated": false,
|
||||
"responseID": "1650331954565_7775",
|
||||
"action": "onExecuteResult",
|
||||
"executeTime": "6"
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"action": "executeContract",
|
||||
"requestID": "1650331954629_8114",
|
||||
"contractID": "GlobalRouter",
|
||||
"operation": "setRouterBaseInfo",
|
||||
"arg": "{\"prefix\":\"macjw.ab\",\"port\":\"2042\"}",
|
||||
"pubkey": "04f9b9b8f324908464f78a6235e2dd93e4dfdaf045e9b1b5cfd57374516cc61a79a86fc2b42d3321a5b49a0f25381a7bed61901b40b729f72354e716673d551e98",
|
||||
"signature": "3045022100dc09a7938767aca9d7d3b15e4ec19c46c546863ef419298f44af84b660d6e2020220420207d4449d5a3747c2f6ce08308eeb4a9514d56b0a07ee3971f12e9b57f27c"
|
||||
}
|
||||
```
|
||||
|
||||
{"needSeq":false,"seq":0,"status":"Success","result":{"result":"success"},"isInsnLimit":false,"totalGas":0,"
|
||||
executionGas":0,"extraGas":0,"size":0,"eventRelated":false,"responseID":"1650331954629_8114","action":"onExecuteResult"
|
||||
,"executeTime":"16"}
|
||||
|
||||
CreateAuditProxy
|
||||
04f9b9b8f324908464f78a6235e2dd93e4dfdaf045e9b1b5cfd57374516cc61a79a86fc2b42d3321a5b49a0f25381a7bed61901b40b729f72354e716673d551e98
|
||||
|
||||
```json
|
||||
{
|
||||
"arg": "
|
||||
}
|
||||
|
||||
{
|
||||
"needSeq": false,
|
||||
"seq": 0,
|
||||
"status": "Success",
|
||||
"result": {
|
||||
"result": "success",
|
||||
"data": "macjw.ab/AuditProxy"
|
||||
},
|
||||
"isInsnLimit": false,
|
||||
"totalGas": 0,
|
||||
"executionGas": 0,
|
||||
"extraGas": 0,
|
||||
"size": 0,
|
||||
"eventRelated": false,
|
||||
"responseID": "1650332023912_5430",
|
||||
"
|
||||
action
|
||||
":"
|
||||
onExecuteResult
|
||||
","
|
||||
executeTime
|
||||
":"
|
||||
15
|
||||
"}
|
||||
```
|
||||
|
||||
# GetAuditRule
|
||||
|
||||
{"action":"executeContract","requestID":"1650332360055_6184","contractID":"ControlProxy","operation":"getDoAuditRule","
|
||||
arg":{"doId":"AuditProxy","offset":null},"pubkey":"
|
||||
04f9b9b8f324908464f78a6235e2dd93e4dfdaf045e9b1b5cfd57374516cc61a79a86fc2b42d3321a5b49a0f25381a7bed61901b40b729f72354e716673d551e98"
|
||||
,"signature":"
|
||||
3046022100c869e7fbd318084881fe0abd79e15271fca4981a45183526893b45e0356e670f022100afd927cf2f5f8acb56815b6b4d4a1783cbcd89a48b4bd6b1a91945fd7fba345a"
|
||||
} {"needSeq":false,"seq":0,"status":"Success","result":{"
|
||||
data":[{"doId":"abc.124/Repo","auditRule":{"type":0}},{"doId":"abc.125/Repo","auditRule":{"type":1}},{"doId":"abc.128/Repo","auditRule":{"type":1}}]
|
||||
,"total":3},"isInsnLimit":false,"totalGas":0,"executionGas":0,"extraGas":0,"size":0,"eventRelated":false,"responseID":"
|
||||
1650332360055_6184","action":"onExecuteResult","executeTime":"8"}
|
||||
|
||||
{"privateKey":"4616ff0e2a4f982364914f9be30b51c6bc6ccb6602114a9ee8792f2ccf67465b","publicKey":"
|
||||
04f9b9b8f324908464f78a6235e2dd93e4dfdaf045e9b1b5cfd57374516cc61a79a86fc2b42d3321a5b49a0f25381a7bed61901b40b729f72354e716673d551e98"
|
||||
}
|
||||
|
||||
# getDOList
|
||||
|
||||
{"needSeq":false,"seq":0,"status":"Success","result":{"
|
||||
data":[{"doId":"abc.124/Repo","auditRule":{"type":0}},{"doId":"abc.125/Repo","auditRule":{"type":1}},{"doId":"abc.128/Repo","auditRule":{"type":1}}]
|
||||
,"total":3},"isInsnLimit":false,"totalGas":0,"executionGas":0,"extraGas":0,"size":0,"eventRelated":false,"responseID":"
|
||||
1650332360055_6184","action":"onExecuteResult","executeTime":"8"} {"needSeq":false,"seq":0,"status":"Success","result":
|
||||
{"data":[{"doId":"bdware.ss/Repo1/abc0","originalData":{"doid":"bdware.ss/Repo1/abc0","info":"ddddd","
|
||||
tag":["aaa","bbb","ccc"]},"enableIndex":true},{"doId":"bdware.ss/Repo1/abc1","originalData":{"doid":"
|
||||
bdware.ss/Repo1/abc1","info":"ddddd","tag":["aaa","bbb","ccc"]},"enableIndex":true},{"doId":"bdware.ss/Repo1/abc2","
|
||||
originalData":{"doid":"bdware.ss/Repo1/abc2","info":"ddddd","tag":["aaa","bbb","ccc"]},"enableIndex":true},{"doId":"
|
||||
bdware.ss/Repo1/abc3","originalData":{"doid":"bdware.ss/Repo1/abc3","info":"ddddd","tag":["aaa","bbb","ccc"]},"
|
||||
enableIndex":true},{"doId":"bdware.ss/Repo1/abc4","originalData":{"doid":"bdware.ss/Repo1/abc4","info":"ddddd","
|
||||
tag":["aaa","bbb","ccc"]},"enableIndex":true},{"doId":"bdware.ss/Repo1/abc5","originalData":{"doid":"
|
||||
bdware.ss/Repo1/abc5","info":"ddddd","tag":["aaa","bbb","ccc"]},"enableIndex":true},{"doId":"bdware.ss/Repo1/abc6","
|
||||
originalData":{"doid":"bdware.ss/Repo1/abc6","info":"ddddd","tag":["aaa","bbb","ccc"]},"enableIndex":true},{"doId":"
|
||||
bdware.ss/Repo1/abc7","originalData":{"doid":"bdware.ss/Repo1/abc7","info":"ddddd","tag":["aaa","bbb","ccc"]},"
|
||||
enableIndex":true},{"doId":"bdware.ss/Repo1/abc8","originalData":{"doid":"bdware.ss/Repo1/abc8","info":"ddddd","
|
||||
tag":["aaa","bbb","ccc"]},"enableIndex":true},{"doId":"bdware.ss/Repo1/abc9","originalData":{"doid":"
|
||||
bdware.ss/Repo1/abc9","info":"ddddd","tag":["aaa","bbb","ccc"]},"enableIndex":true}],"total":100},"isInsnLimit":false,"
|
||||
totalGas":0,"executionGas":0,"extraGas":0,"size":0,"eventRelated":false,"responseID":"1650332431455_143","action":"
|
||||
onExecuteResult","executeTime":"14"}
|
@ -63,9 +63,9 @@ task copyAssets(type: Copy) {
|
||||
into "./build/output/assets/"
|
||||
}
|
||||
task copyJar(type: Copy, dependsOn: [":backend:jar", ":backend:copyLibs"]) {
|
||||
from "./build/libs/$project.name-${project.version}-all.jar"
|
||||
from "./build/libs/$project.name-${project.version}.jar"
|
||||
into "./build/output"
|
||||
rename { String fileName -> "sc-example.jar" }
|
||||
rename { String fileName -> "controlproxy-${project.version}.jar" }
|
||||
doFirst {
|
||||
println "copyJar start"
|
||||
}
|
||||
|
14
backend/debugconf.json
Normal file
14
backend/debugconf.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"agentHttpAddr": "127.0.0.1:18000",
|
||||
"createParam": {
|
||||
"privateKey": "4616ff0e2a4f982364914f9be30b51c6bc6ccb6602114a9ee8792f2ccf67465b",
|
||||
"publicKey": "04f9b9b8f324908464f78a6235e2dd93e4dfdaf045e9b1b5cfd57374516cc61a79a86fc2b42d3321a5b49a0f25381a7bed61901b40b729f72354e716673d551e98",
|
||||
"prefix": "macjw.ab",
|
||||
"router": "GlobalRouter",
|
||||
"routerURI": "tcp://localhost:2042",
|
||||
"auditType": "OnlyHash"
|
||||
},
|
||||
"script": "/Users/huaqiancai/BDWare/datanet/ControlProxy/backend/build/ControlProxy-0.8.7.ypk",
|
||||
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
|
||||
"privKey": "589d94ee5688358a1c5c18430dd9c75097ddddebf7repodetail.yjs69f139da36a807911d20f8"
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package org.bdware.sc.controlproxy;
|
||||
|
||||
import org.bdware.sc.debugger.DebugMain;
|
||||
|
||||
public class DebugRun {
|
||||
public static void main(String[] args){
|
||||
DebugMain.main(args);
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
package org.bdware.sc.controlproxy.Hello;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bdware.doip.audit.EndpointConfig;
|
||||
import org.bdware.doip.audit.client.AuditDoipClient;
|
||||
import org.bdware.doip.audit.client.AuditIrpClient;
|
||||
import org.bdware.doip.audit.config.TempConfigStorage;
|
||||
import org.bdware.doip.audit.writer.AuditConfig;
|
||||
import org.bdware.doip.audit.writer.AuditType;
|
||||
import org.bdware.doip.auditrepo.AutoAuditDO;
|
||||
import org.bdware.doip.codec.doipMessage.DoipMessage;
|
||||
import org.bdware.doip.endpoint.client.ClientConfig;
|
||||
import org.bdware.irp.exception.IrpClientException;
|
||||
import org.bdware.irp.stateinfo.StateInfoBase;
|
||||
import org.bdware.sc.engine.JSONTool;
|
||||
|
||||
|
||||
public class Hello {
|
||||
private static final Logger LOGGER = LogManager.getLogger(Hello.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
LOGGER.info("abc");
|
||||
}
|
||||
|
||||
static EndpointConfig endpointConfig;
|
||||
|
||||
public static void init(Object obj) {
|
||||
String defaultConfg= "{\"routerURI\":\"127.0.0.1:2041\"}";
|
||||
if (obj==null){
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj instanceof String) {
|
||||
if (!((String) obj).startsWith("{")){
|
||||
|
||||
}
|
||||
TempConfigStorage storage = new TempConfigStorage((String) obj);
|
||||
endpointConfig = storage.loadAsEndpointConfig();
|
||||
} else {
|
||||
JsonElement je = JSONTool.convertMirrorToJson(obj);
|
||||
TempConfigStorage storage = new TempConfigStorage(je.toString());
|
||||
endpointConfig = storage.loadAsEndpointConfig();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getConfig() {
|
||||
return new Gson().toJson(endpointConfig);
|
||||
}
|
||||
|
||||
public static String call() {
|
||||
return "hello..dafdskf";
|
||||
}
|
||||
|
||||
public static String getAuditType(String doid) {
|
||||
AuditIrpClient irpClient = new AuditIrpClient(endpointConfig);
|
||||
AuditConfig auditConfig = irpClient.getAuditConfig();
|
||||
AuditDoipClient client = new AuditDoipClient(auditConfig);
|
||||
ClientConfig config = null;
|
||||
try {
|
||||
StateInfoBase result = irpClient.resolve(doid);
|
||||
config = new ClientConfig(result.getValues("address"));
|
||||
} catch (IrpClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
client.connect(config);
|
||||
DoipMessage msg = client.sendMessageSync(AutoAuditDO.getRepoAuditType(doid));
|
||||
AuditType type = AutoAuditDO.getAuditTypeFromRespMessage(msg);
|
||||
LOGGER.info(type);
|
||||
return type.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package org.bdware.sc.controlproxy;
|
||||
|
||||
import com.google.gson.*;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bdware.doip.audit.EndpointConfig;
|
||||
import org.bdware.doip.audit.client.AuditDoipClient;
|
||||
import org.bdware.doip.audit.client.AuditIrpClient;
|
||||
import org.bdware.doip.audit.config.TempConfigStorage;
|
||||
import org.bdware.doip.audit.writer.AuditConfig;
|
||||
import org.bdware.doip.audit.writer.AuditType;
|
||||
import org.bdware.doip.auditrepo.AutoAuditDO;
|
||||
import org.bdware.doip.codec.doipMessage.DoipMessage;
|
||||
import org.bdware.doip.endpoint.client.ClientConfig;
|
||||
import org.bdware.irp.stateinfo.StateInfoBase;
|
||||
import org.bdware.sc.engine.JSONTool;
|
||||
|
||||
|
||||
public class RepoProxy {
|
||||
private static final Logger LOGGER = LogManager.getLogger(RepoProxy.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
LOGGER.info("abc");
|
||||
}
|
||||
|
||||
static String prefix;
|
||||
static EndpointConfig endpointConfig;
|
||||
|
||||
public static void init(Object obj) {
|
||||
if (obj == null) {
|
||||
return;
|
||||
}
|
||||
if (obj instanceof String) {
|
||||
if (!((String) obj).startsWith("{")) {
|
||||
|
||||
}
|
||||
TempConfigStorage storage = new TempConfigStorage((String) obj);
|
||||
endpointConfig = storage.loadAsEndpointConfig();
|
||||
prefix = storage.load().get("prefix").getAsString();
|
||||
} else {
|
||||
JsonElement je = JSONTool.convertMirrorToJson(obj);
|
||||
TempConfigStorage storage = new TempConfigStorage(je.toString());
|
||||
endpointConfig = storage.loadAsEndpointConfig();
|
||||
prefix = storage.load().get("prefix").getAsString();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getConfig() {
|
||||
return new Gson().toJson(endpointConfig);
|
||||
}
|
||||
|
||||
public static String call() {
|
||||
return "hello..dafdskf";
|
||||
}
|
||||
|
||||
public static JsonElement getDoAuditRule(Object obj) {
|
||||
JsonObject jo = JSONTool.convertMirrorToJson(obj).getAsJsonObject();
|
||||
String doId = jo.get("doId").getAsString();
|
||||
if (!doId.contains("/")) {
|
||||
doId = prefix + "/" + doId;
|
||||
}
|
||||
|
||||
ClientConfig config = null;
|
||||
AuditType type = null;
|
||||
try {
|
||||
AuditIrpClient irpClient = new AuditIrpClient(endpointConfig);
|
||||
AuditConfig auditConfig = irpClient.getAuditConfig();
|
||||
AuditDoipClient client = new AuditDoipClient(auditConfig);
|
||||
StateInfoBase result = irpClient.resolve(doId);
|
||||
config = new ClientConfig(result.getValues("address"));
|
||||
client.connect(config);
|
||||
DoipMessage msg = client.sendMessageSync(AutoAuditDO.getRepoAuditType(doId));
|
||||
type = AutoAuditDO.getAuditTypeFromRespMessage(msg);
|
||||
LOGGER.info(type);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
JsonObject ret = new JsonObject();
|
||||
ret.addProperty("total", 1);
|
||||
JsonArray jsonArray = new JsonArray();
|
||||
ret.add("data", jsonArray);
|
||||
String format = "{\"doId\":\"%s\",\"auditRule\":{\"type\":%d}}";
|
||||
if (type == null) {
|
||||
jsonArray.add(JsonParser.parseString(String.format(format, "不可配置:" + doId, 0)));
|
||||
} else
|
||||
jsonArray.add(JsonParser.parseString(String.format(format, doId, type.ordinal())));
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
@ -15,7 +15,7 @@ contract ControlProxy{
|
||||
return arg;
|
||||
}
|
||||
|
||||
export function onCreate(arg){
|
||||
function onCreate(arg){
|
||||
if (arg==null|| typeof(arg)=='string'){
|
||||
arg={"prefix":"test.ab.cd",
|
||||
"router":"GlobalRouter"
|
||||
@ -27,7 +27,7 @@ contract ControlProxy{
|
||||
Global.prefix = arg.prefix;
|
||||
Global.router = arg.router;
|
||||
initDAC(requester);
|
||||
org.bdware.sc.controlyproxy.Hello.init(arg);
|
||||
org.bdware.sc.controlproxy.RepoProxy.init(arg);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ module RepoDetail{
|
||||
|
||||
|
||||
export function getControlProxyConfig(){
|
||||
return org.bdware.sc.controlyproxy.Hello.getConfig();
|
||||
return org.bdware.sc.controlproxy.RepoProxy.getConfig();
|
||||
|
||||
}
|
||||
//@wyq 通过DOIP请求
|
||||
@ -17,20 +17,12 @@ module RepoDetail{
|
||||
//@wyq TODO TODO
|
||||
// 这个通过DOIPUtil,去调用
|
||||
// DOIP的接口。
|
||||
@Description("{\"doId\":\"macjw.ab/repofile\"}");
|
||||
export function getDoAuditRule(arg){
|
||||
//repo的doId
|
||||
//arg={"doId":"xxx","offset":xx,"count":xx}
|
||||
arg = convertArgToJson(arg);
|
||||
if(arg.count==undefined) arg.count=10;
|
||||
if(arg.offset==undefined) arg.offset=0;
|
||||
|
||||
var ret = {"data":[{"doId":"abc.124/Repo","auditRule":{"type":0}},
|
||||
{"doId":"abc.125/Repo","auditRule":{"type":1}},
|
||||
{"doId":"abc.128/Repo","auditRule":{"type":1}}],
|
||||
total:3};
|
||||
|
||||
return ret;
|
||||
//abc.124/Repo/67899-6789789dafd-8909
|
||||
return org.bdware.sc.controlproxy.RepoProxy.getDoAuditRule(arg);
|
||||
}
|
||||
//@wyq
|
||||
export function setDoAuditRule(arg){
|
||||
@ -46,6 +38,11 @@ module RepoDetail{
|
||||
//这是search engine的接口,为什么还没接上??
|
||||
//TODO TODO
|
||||
export function getDoList(arg){
|
||||
print("GetDOList===========");
|
||||
var ret = executeContract("SearchEngine","getDoList",arg);
|
||||
return ret.result;
|
||||
}
|
||||
export function getDoList2(arg){
|
||||
arg = convertArgToJson(arg);
|
||||
//if (arg.doId == null)
|
||||
// return {
|
||||
|
@ -2,7 +2,7 @@ plugins {
|
||||
id 'java'
|
||||
id 'idea'
|
||||
}
|
||||
def currVersion = "0.8.2"
|
||||
def currVersion = "0.8.8"
|
||||
ext.projectIds = ['group': 'org.bdware.sc.controlproxy', 'version': currVersion]
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
|
Loading…
Reference in New Issue
Block a user