Compare commits

...

24 Commits

Author SHA1 Message Date
scq
482b39aba9 repo初步实现 2023-12-27 15:04:10 +08:00
scq
4599f31b49 repo初步实现 2023-12-27 14:32:53 +08:00
scq
ad72cc6030 Merge branch 'master' of gitea.internetapi.cn:songchunqiao/ControlProxy 2023-12-27 14:30:00 +08:00
scq
0e2f44aa44 repo初步实现 2023-12-27 14:27:30 +08:00
zhaozihao
9d90d4b17f Merge remote-tracking branch 'origin/master' 2023-12-04 12:12:22 +08:00
zhaozihao
35a2a310ea 初步完成 repo 和 sub registry 接口 2023-12-04 12:11:46 +08:00
f9bc24c358 feat: access control owner 2023-11-22 23:25:06 +08:00
8619858f05 feat: multi publicKey access control 2023-11-22 16:30:56 +08:00
CaiHQ
3fce2450fd add access control example 2023-11-20 15:38:43 +08:00
CaiHQ
5b0f97eedc add access control example 2023-11-20 15:38:39 +08:00
CaiHQ
b635aeab77 add registry todos 2023-11-20 11:58:54 +08:00
CaiHQ
65431ebcb2 update registry todo 2023-11-20 11:53:34 +08:00
CaiHQ
6a2a0bb573 merge submodules 2023-11-17 21:40:08 +08:00
CaiHQ
2333e71809 add submodules 2023-11-17 21:37:42 +08:00
CaiHQ
ac7ab72bad refactor moduleNames 2023-11-17 17:32:56 +08:00
zhaoweijie
b0b3274a53 feat: change seach arg 2023-08-28 18:16:09 +08:00
scq
635dcb0d48 mock interface modify 2023-08-19 06:56:58 +08:00
CaiHQ
64be380421 update shanxicontrolproxy 2023-08-17 18:42:36 +08:00
scq
76390119c5 add ShanxiControlProxy 2023-07-26 11:51:33 +08:00
scq
9a1d9ef793 ControlProxy To ShanxiControlProxy 2023-07-26 11:39:08 +08:00
scq
ef02d2201f interface modify 2023-07-24 02:05:09 +08:00
scq
a923bad5c8 all interface refactor 2023-07-12 00:55:14 +08:00
scq
cf47a41d85 Merge branch 'master' of https://gitea.internetapi.cn/iod/ControlProxy 2023-07-11 23:03:16 +08:00
scq
24b1b15ac0 all interface refactor 2023-07-11 22:57:57 +08:00
62 changed files with 1906 additions and 97 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
gradle.properties
ContractDB
/.DS_Store/
*~
gradlew

8
.gitmodules vendored Normal file
View File

@ -0,0 +1,8 @@
[submodule "datanet-search-engine-backend"]
path = datanet-search-engine-backend
url = git@gitea.internetapi.cn:iod/datanet-search-engine-backend.git
branch = main
[submodule "iod-repo-backend"]
path = iod-repo-backend
url = git@gitea.internetapi.cn:iod/iod-repo-backend.git
branch = main

View File

@ -1,32 +1,19 @@
# contract-java-example
# 初始化配置说明
1. clone之后使用`git submodule update --init `初始化子仓库。
#### 介绍
idea开发合约的示例。
# 测试环境搭建说明
测试环境中有一个bdtest/Repositorytcp://127.0.0.1:21035),和一个标识解析系统(tcp://127.0.0.1:21041)
## Repo测试
进行Repo测试时需要先在`http://127.0.0.1:21030/DOIP/GlobalRouter/assets/#/Suffix/suffixManage`中登录,
key填` { "publicKey": "04180354fdb6507f8ab98ccfbe165ce11da74ba733f81af86ad6d32216b32cf4f797c559d50ceeefbf4c760c3483840471c67471b90acdffb388cd7d496d9a1610",
"privateKey": "1d4196947f59532db6f8f4055e58474a48db8f30b476ae3edc66406464521b3b"}`由于该repo需要支持从本地的客户端发起调用
因此Address建议填`tcp://127.0.0.1:port`。注意IP与Registry填写的IP的不同。
添加一个`Repository2`其中address填写的port范围建议在18034-18039之内。
#### 软件架构
软件架构说明
#### 配置cp 的lib
做一个软链接将cp-bundle的build/output 软链接到
backend/cplibs。
#### 前端sdk说明
1. 如何使用javascript sdk
2. 如何使用typescript sdk
3. 示例使用vite/vue/...等框架
3. 如何配置成前后端独立连接的
4. 如何配置成前后端一体化
##### 模拟后端数据
#### 后端常用方法说明
##### 调用相同CP的yjs代码
参考:
Hello.callYJSInSameCP
##### 调用其他CP的yjs代码
参考:
Hello.callYJSInOtherCP
## Registry测试
进行Registry测试时需要先在`http://127.0.0.1:21030/DOIP/GlobalRouter/assets/#/Suffix/suffixManage` 之中
创建一个`Registry2`的标识。
key填` { "publicKey": "04180354fdb6507f8ab98ccfbe165ce11da74ba733f81af86ad6d32216b32cf4f797c559d50ceeefbf4c760c3483840471c67471b90acdffb388cd7d496d9a1610",
"privateKey": "1d4196947f59532db6f8f4055e58474a48db8f30b476ae3edc66406464521b3b"}`
由于Registry2需要支持从docker的repo去调用DOIP.publish因此address填写`tcp://host.docker.internal:port`port的范围
建议18034-18039之内。

View File

@ -0,0 +1,81 @@
# access-control-template
## 构建配置
1.在build.gradle中增加`copyAccessControl`
```gradle
task copyAccessControl(type: Copy) {
from "../access-control-template/yjs"
into "./build/output/"
}
```
2. 在`buildZip`任务中添加依赖:
```gradle
task buildZip(type: Zip, dependsOn: [...,"copyAccessControl"]) {
...
```
3. 在`main.yjs`中添加RocksDB权限。
`@Permission("RocksDB")`
## ABAC.yjs的使用方式
1.在main.yjs中增加`import`语句,并在`onCreate`方法中,添加初始化调用。
```javascript
import "actemplate/ABAC.yjs";
function onCreate(arg) {
...
initABAC(requester);
}
```
2.针对需要访问控制的函数,使用`@Access`注解
```javascript
@Access({"ACFunction":"accept"})
export function xxx
```
3.初始化权限。
初始状态下,仅`owner`(启动者) 拥有全部权限。
通过调用`addPermission`和`removePermission`可对相应公钥的用户作授权。
## RBAC.yjs的使用方式
1.配置角色-权限。在`main.yjs` 下创建 `role.json`
参考role.template.json。例如以下配置文件定义了两种角色`userAdmin`和`authorizedUser`。
启动者自动默认为超级管理员,有全部权限。
```json
{
"userAdmin": ["addRole","removeRole"],
"authorizedUser": ["hello"]
}
```
2.在main.yjs中增加`import`语句,并在`onCreate`方法中,添加初始化调用。
```javascript
import "actemplate/RBAC.yjs";
function onCreate(arg) {
...
initRBAC(requester, Global.Resources.loadAsString("/role.json"));
}
```
2.针对需要访问控制的函数,使用`@Access`注解
用法同ABAC。
```javascript
@Access({"ACFunction":"accept"})
export function xxx
```
3.初始化权限。
初始状态下,仅`owner`(启动者) 拥有全部权限。
通过调用`addRole`和`removeRole`可对相应公钥的用户作授权。

View File

@ -0,0 +1,74 @@
module ABAC {
function initABAC(req) {
Global.owner = req;
Global.acTable = RocksDBUtil.loadDB("./acTable", "false");
}
@Description("{\"!user\":\"string\",\"!permission\":\"string\"}")
@ArgSchema({
"!user":"string", "!permission":"string"
})
@Access({
"ACFunction":"accept"
})
export function addPermission(arg) {
var arr = getPermissionInternal(arg.user);
if (arr.indexOf(arg.permission)==-1){
arr.push(arg.permission);
flushPermission(arg.user, arr);
}
return arr;
}
@Access("verified")
@Description("use signed request")
export function isOwner(arg) {
return Global.owner==requester;
}
@Description("两个参数, {\"user\":\"xxxx\", \"permission\":\"\"}")
@ArgSchema({
"!user":"string", "!permission":"string"
})
@Access({
"ACFunction":"accept"
})
export function removePermission(arg) {
var arr = getPermissionInternal(arg.user);
var index = arr.indexOf(arg.permission);
if (index!=-1){
arr.splice(index, 1);
flushPermission(arg.user, arr);
}
return arr;
}
@Access("verified")
export function clearPermission(arg) {
Global.acTable.put(requester, "[]");
return [];
}
function flushPermission(user, data) {
Global.acTable.put(user, JSON.stringify(data));
}
@Description(" use signed request, no other arguments is required")
@Access("verified")
export function getMyPermission(arg) {
return getPermissionInternal(requester);
}
function getPermissionInternal(req) {
var ret = Global.acTable.get(req);
if (ret==undefined) return [];
return JSON.parse(ret);
}
//requester,action,arg
function accept(arg) {
if (arg.requester == Global.owner) return true;
var arr = getPermissionInternal(arg.requester);
if (arr.indexOf(arg.action)==-1)
YancloudUtil.exceptionReturn({
"code":401, "msg":"no permission: "+ arg.action
});
}
}

View File

@ -0,0 +1,146 @@
//访问控制规则:
//针对如果是DOIP请求的调用
//仅包括Repo.doipRetrive
//Registry的publish/subscribe不做访问控制
//如果是HTTP请求的调用
//管理员具有所有权限
//一些”写入接口“添加权限检查
module DOAuth {
function initDOAuth(req, createParam, doipFunctions) {
Global.owner = req;
Global.doipFunctions = doipFunctions;
Global.accessInfo = RocksDBUtil.loadDB("accessControl", "false");
Global.userInfo = RocksDBUtil.loadDB("authedUserInfo", "false");
Global.nodeInfo = RocksDBUtil.loadDB("authedNodeInfo", "false");
}
function isOwner(req) {
return req == Global.owner;
}
function doipAccessCheck(argPack) {
print("in doipAcceccCheck, requester:" + argPack.requester);
return hasDBSetItem(Global.accessInfo, argPack.arg.header.identifier, argPack.requester);
}
function checkByManager(action) {
return Global.doipFunctions.indexOf(action) == - 1;
}
@Description("针对某一DO添加用户的访问权限")
@ArgSchema({
"doId" : "string", "publicKey" : "string", "info": "string"
})
@Access({
"ACFunction":"acceptOwner"
})
export function addAuthedUser(arg) {
//把requester和 arg.doId放到accessInfo里即可。
addDBSetItem(Global.accessInfo, arg.doId, arg.publicKey);
if(arg.info != null) {
Global.userInfo.put(arg.publicKey, arg.info);
}
return {
"code" : 0
};
}
function acceptJudgementInternal(argPack) {
if (checkByManager(argPack.action)){
return isOwner(argPack.requester);
} else {
return doipAccessCheck(argPack);
}
}
function acceptJudgement(argPack) {
if (! acceptJudgementInternal(argPack)){
print("acceptJudgement, requester:" + argPack.requester + "false!!");
YancloudUtil.exceptionReturn({
"code" : 401, "msg" : "no permission: " + argPack.action
});
} else print("acceptJudgement, requester:" + argPack.requester + "true!!");
}
function acceptOwner(argPack) {
if (argPack.requester !== Global.owner) {
YancloudUtil.exceptionReturn({
"code" : 401, "msg" : "no permission: " + argPack.action
});
}
}
@Description("针对某一DO删除用户的访问权限")
@ArgSchema({
"doId" : "string", "publicKey" : "string"
})
@Access({
"ACFunction":"acceptOwner"
})
export function deleteAuthedUser(arg) {
deleteDBSetItem(Global.accessInfo, arg.doId, arg.publicKey);
return {
"code" : 0
};
}
@Description("针对某一DO添加节点的访问权限所有调用进带该节点授权的用户均可访问")
@ArgSchema({
"doId" : "string", "publicKey" : "string", "info" : "string"
})
@Access({
"ACFunction":"acceptOwner"
})
export function addAuthedNode(arg) {
addDBSetItem(Global.accessInfo, arg.doId, arg.publicKey);
if(arg.info != null) {
Global.nodeInfo.put(arg.publicKey, arg.info);
}
return {
"code" : 0
};
}
@Description("针对某一DO删除节点的访问权限")
@ArgSchema({
"doId" : "string", "publicKey" : "string"
})
@Access({
"ACFunction":"acceptOwner"
})
export function deleteAuthedNode(arg) {
deleteDBSetItem(Global.accessInfo, arg.doId, arg.publicKey);
return {
"code" : 0
};
}
function getDBSet(db, key) {
var saved = db.get(key);
if (saved == null) {
saved = "[]";
}
return JSON.parse(saved);
}
function addDBSetItem(db, key, value) {
var savedSet = getDBSet(db, key);
if (savedSet.indexOf(value) === -1) {
savedSet.push(value);
var saved = JSON.stringify(savedSet);
db.put(key, saved);
}
}
function deleteDBSetItem(db, key, value) {
var savedSet = getDBSet(db, key);
var index = savedSet.indexOf(value);
if (index !== -1) {
savedSet.splice(index, 1);
var saved = JSON.stringify(savedSet);
db.put(key, saved);
}
}
function hasDBSetItem(db, key, value) {
var savedSet = getDBSet(db, key);
return savedSet.indexOf(value) !== -1;
}
}

View File

@ -0,0 +1,79 @@
import "ABAC.yjs";
module RBAC {
function initRBAC(req, allRoles) {
Global.allRoles = JSON.parse(allRoles);
Global.roleTable = RocksDBUtil.loadDB("./roleTable", "false");
initABAC(req);
}
function calculatePermission(roles) {
var ret = [];
for (var i = 0;
i<roles.length;
i++){
var perms = Global.allRoles[roles[i]];
if (perms!=null)
ret = ret.concat(perms);
}
return ret;
}
@Description("{\"!user\":\"string\",\"!role\":\"string\"}")
@ArgSchema({
"!user":"string", "!role":"string"
})
@Access({
"ACFunction":"accept"
})
export function addRole(arg) {
if (Global.allRoles[arg.role]==undefined){
YancloudUtil.exception({
"code":500, "msg":"no such role"
});
}
var arr = getRoleInternal(arg.user);
if (arr.indexOf(arg.role)==-1){
arr.push(arg.role);
flushRole(arg.user, arr);
}
return arr;
}
@Description("两个参数, {\"user\":\"xxxx\", \"role\":\"\"}")
@ArgSchema({
"!user":"string", "!role":"string"
})
@Access({
"ACFunction":"accept"
})
export function removeRole(arg) {
if (Global.allRoles[arg.role]==undefined){
YancloudUtil.exception({
"code":500, "msg":"no such role"
});
}
var arr = getRoleInternal(arg.user);
var index = arr.indexOf(arg.role);
if (index!=-1){
arr.splice(index, 1);
}
flushRole(arg.user, arr);
return arr;
}
function flushRole(user, roles) {
Global.roleTable.put(user, JSON.stringify(roles));
var permissions = calculatePermission(roles);
flushPermission(arg.user, permissions);
}
@Description(" use signed request, no other arguments is required")
@Access("verified")
export function getMyRole(arg) {
return getRoleInternal(requester);
}
function getRoleInternal(req) {
var ret = Global.roleTable.get(req);
if (ret==undefined) return [];
return JSON.parse(ret);
}
}

View File

@ -0,0 +1,4 @@
{
"userAdmin": ["addRole","removeRole"],
"authorizedUser": ["hello"]
}

View File

@ -1 +0,0 @@
yjs.jar

View File

@ -12,7 +12,21 @@ repositories {
mavenCentral()
}
project(':backend') {
project(':control-proxy-backend') {
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://maven.aliyun.com/repository/public' }
}
}
project(':datanet-search-engine-backend') {
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://maven.aliyun.com/repository/public' }
}
}
project(':iod-repo-backend') {
repositories {
mavenLocal()
mavenCentral()

View File

@ -0,0 +1,127 @@
木兰宽松许可证, 第2版
木兰宽松许可证, 第2版
2020年1月 http://license.coscl.org.cn/MulanPSL2
您对“软件”的复制、使用、修改及分发受木兰宽松许可证第2版“本许可证”的如下条款的约束
0. 定义
“软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
“贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
“贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
“法人实体”是指提交贡献的机构及其“关联实体”。
“关联实体”是指对“本许可证”下的行为方而言控制、受控制或与其共同受控制的机构此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
1. 授予版权许可
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。
2. 授予专利许可
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。
3. 无商标许可
“本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可但您为满足第4条规定的声明义务而必须使用除外。
4. 分发限制
您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
5. 免责声明与责任限制
“软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。
6. 语言
“本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。
条款结束
如何将木兰宽松许可证第2版应用到您的软件
如果您希望将木兰宽松许可证第2版应用到您的新软件为了方便接收者查阅建议您完成如下三步
1 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字;
2 请您在软件包的一级目录下创建以“LICENSE”为名的文件将整个许可证文本放入该文件中
3 请将如下声明文本放入每个源文件的头部注释中。
Copyright (c) [Year] [name of copyright holder]
[Software Name] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
Mulan Permissive Software LicenseVersion 2
Mulan Permissive Software LicenseVersion 2 (Mulan PSL v2)
January 2020 http://license.coscl.org.cn/MulanPSL2
Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions:
0. Definition
Software means the program and related documents which are licensed under this License and comprise all Contribution(s).
Contribution means the copyrightable work licensed by a particular Contributor under this License.
Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License.
Legal Entity means the entity making a Contribution and all its Affiliates.
Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, control means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity.
1. Grant of Copyright License
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not.
2. Grant of Patent License
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken.
3. No Trademark License
No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4.
4. Distribution Restriction
You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software.
5. Disclaimer of Warranty and Limitation of Liability
THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW ITS CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
6. Language
THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL.
END OF THE TERMS AND CONDITIONS
How to Apply the Mulan Permissive Software LicenseVersion 2 (Mulan PSL v2) to Your Software
To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps:
i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner;
ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package;
iii Attach the statement to the appropriate annotated syntax at the beginning of each source file.
Copyright (c) [Year] [name of copyright holder]
[Software Name] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.

View File

@ -4,9 +4,8 @@ buildscript {
mavenLocal()
}
dependencies {
classpath "org.bdware.bdcontract:simple-ypk-packer:0.5.5"
classpath "org.bdware.bdcontract:ypk-deploy-tool:0.7.1"
classpath "org.bdware.bdcontract:simple-ypk-packer:${YPKPackerVersion}"
classpath "org.bdware.bdcontract:ypk-deploy-tool:${DeployToolVersion}"
}
}
@ -16,6 +15,8 @@ plugins {
}
version = "1.4.0"
group = 'org.bdware.sc.controlproxy'
var moduleName = "control-proxy-backend"
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:none'
@ -45,11 +46,11 @@ dependencies {
api 'org.apache.logging.log4j:log4j-core:2.17.2'
api 'org.apache.logging.log4j:log4j-api:2.17.2'
api 'com.google.code.gson:gson:2.8.8'
implementation 'org.bdware.sc:cp:1.6.8'
implementation 'org.bdware.doip:doip-audit-tool:1.1.3'
implementation "org.bdware.sc:cp:${CPVersion}"
implementation "org.bdware.doip:doip-audit-tool:${AuditToolVersion}"
implementation 'org.bdware.bdcontract:sdk-java:1.0.2'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.bdware.bdcontract:ypk-deploy-tool:0.7.1'
testImplementation "org.bdware.bdcontract:ypk-deploy-tool:${DeployToolVersion}"
}
task copyLibs(type: Copy) {
@ -71,10 +72,10 @@ task copyAssets(type: Copy) {
from "../front"
into "./build/output/assets/"
}
task copyJar(type: Copy, dependsOn: [":backend:jar", ":backend:copyLibs"]) {
task copyJar(type: Copy, dependsOn: [":${moduleName}:jar", ":${moduleName}:copyLibs"]) {
from "./build/libs/$project.name-${project.version}.jar"
into "./build/output"
rename { String fileName -> "controlproxy-${project.version}.jar" }
rename { String fileName -> "ControlProxy.jar" }
doFirst {
println "copyJar start"
}
@ -82,37 +83,37 @@ task copyJar(type: Copy, dependsOn: [":backend:jar", ":backend:copyLibs"]) {
}
tasks.processResources.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
tasks.processTestResources.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
task grepCP(dependsOn: [":backend:copyJar"]) {
task grepCP(dependsOn: [":${moduleName}:copyJar"]) {
doLast {
org.bdware.datanet.YPKPacker.grepJarByCPVersion("./backend/build/output/libs", org.bdware.datanet.CPVersion.cp_1_6_8)
// org.bdware.datanet.YPKPacker.grepCPLibWithFilter("./backend/cplibs/libs/", "./backend/build/output/libs", "./backend/grepcp.list")
org.bdware.datanet.YPKPacker.grepJarByCPVersion("./${moduleName}/build/output/libs", org.bdware.datanet.CPVersion.cp_1_6_8)
org.bdware.datanet.YPKPacker.grepJarByListFile("./${moduleName}/build/output/libs", "./grepcp.list")
}
}
task buildZip(type: Zip, dependsOn: ["copyAssets", "grepCP", "copyJar", "copyYJS"]) {
task buildControlProxyZip(type: Zip, dependsOn: ["copyAssets", "grepCP", "copyJar", "copyYJS"]) {
from './build/output/'
duplicatesStrategy = DuplicatesStrategy.INCLUDE
archiveFileName = 'ControlProxy.zip'
destinationDirectory = file('build/')
}
task buildYPK(dependsOn: ["buildZip", "grepCP"]) {
task buildControlProxyYPK(dependsOn: ["buildControlProxyZip", "grepCP"]) {
doLast {
org.bdware.datanet.YPKPacker.staticPack("./backend/build/ControlProxy.zip", "./backend/build/ControlProxy-${project.version}.ypk")
org.bdware.datanet.YPKPacker.staticPack("./${moduleName}/build/ControlProxy.zip", "./${moduleName}/build/ShanxiControlProxy-${project.version}.ypk")
}
}
task deploy(dependsOn: ["buildYPK"]) {
task deployControlProxy(dependsOn: ["buildControlProxyYPK"]) {
doLast {
org.bdware.ypkdeploy.HTTPTool.deployWithYpk("./backend/deployconfig.json","./backend/build/ControlProxy-${project.version}.ypk")
org.bdware.ypkdeploy.HTTPTool.deployWithYpk("./${moduleName}/deployconfig.json", "./${moduleName}/build/ShanxiControlProxy-${project.version}.ypk")
//org.bdware.ypkdeploy.HTTPTool.batchRun("./backend/deployconfig.json", true)
}
}
task putPackage(type: Exec, dependsOn: ["buildYPK"]) {
task putControlProxyPackage(type: Exec, dependsOn: ["buildControlProxyYPK"]) {
workingDir "./build"
commandLine "pwd"
commandLine "curl", "--user", "${REPO_USRNAME}:${REPO_PASSWORD}", "--upload-file", "./ControlProxy-${project.version}.ypk","${REPO_HOST}api/packages/iod/generic/ControlProxy/${project.version}/ControlProxy-${project.version}.ypk"
commandLine "curl", "--user", "${REPO_USRNAME}:${REPO_PASSWORD}", "--upload-file", "./ShanxiControlProxy-${project.version}.ypk", "${REPO_HOST}api/packages/iod/generic/ShanxiControlProxy/${project.version}/ShanxiControlProxy-${project.version}.ypk"
doLast {
println "Executed!"
}

View File

@ -8,7 +8,7 @@
"routerURI": "tcp://39.104.209.178:18041",
"auditType": "OnlyHash"
},
"killBeforeStart": "ControlProxy",
"killBeforeStart": "ShanxiControlProxy",
"ypkPath": "/Users/huaqiancai/BDWare/ControlProxy/backend/build/ControlProxy-1.3.9.ypk",
"publicKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"privateKey": "589d94ee5688358a1c5c18430dd9c75097ddddebf769f139da36a807911d20f8"

View File

@ -3,7 +3,7 @@
"privateKey": "d675782acf011dbc01a73c7967ccff9564486f7c3a9f5d5de151caffaa18936",
"publicKey": "04303718771b9323c204e607639f14469f9a94e55b0964a408ad3b3864b0493b645d7070da0d550f0c54b934275a8e88dedc3024467b0566db5c1108b1baeaae27",
"ypkPath": "/Users/huaqiancai/BDWare/datanet/ControlProxy/backend/build/ControlProxy-0.9.6.ypk",
"killBeforeStart": "ControlProxy",
"killBeforeStart": "ShanxiControlProxy",
"createParam": {
"privateKey": "4616ff0e2a4f982364914f9be30b51c6bc6ccb6602114a9ee8792f2ccf67465b",
"publicKey": "04f9b9b8f324908464f78a6235e2dd93e4dfdaf045e9b1b5cfd57374516cc61a79a86fc2b42d3321a5b49a0f25381a7bed61901b40b729f72354e716673d551e98",

View File

@ -15,6 +15,8 @@ import java.io.PrintStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class TopologyCollector {
@ -102,12 +104,12 @@ public class TopologyCollector {
}
graph.pruneEdges();
return graph.ret;
}catch ( Exception e){
} catch (Exception e) {
List<JsonObject> ret = new ArrayList<>();
JsonObject errorInfo = new JsonObject();
ByteArrayOutputStream bo = new ByteArrayOutputStream();
e.printStackTrace(new PrintStream(bo));
errorInfo.addProperty("stacktrace",bo.toString());
errorInfo.addProperty("stacktrace", bo.toString());
return ret;
}
}
@ -135,7 +137,8 @@ public class TopologyCollector {
static TopologyGraph cachedGraph;
public static boolean isCacheValid() {
if (System.currentTimeMillis() - lastUpdate < 10000) {
if (cachedGraph != null) return true;
if (System.currentTimeMillis() - lastUpdate < 30000) {
return true;
}
return false;
@ -152,18 +155,38 @@ public class TopologyCollector {
return "done";
}
public synchronized static List<JsonObject> getLevelTopology(int arg) {
public void reflushCache() {
}
public static List<JsonObject> getLevelTopology(int arg) {
if (isCacheValid()) {
LOGGER.info("getLevelTopology use Cache!");
reflushCacheAsync(arg);
return cachedGraph.ret;
}
reflushCacheSync(arg);
return cachedGraph.ret;
}
static ExecutorService pool = Executors.newFixedThreadPool(2);
private static void reflushCacheAsync(int arg) {
pool.execute(new Runnable() {
@Override
public void run() {
reflushCacheSync(2);
}
});
}
private synchronized static void reflushCacheSync(int arg) {
LOGGER.info("getLevelTopology refresh");
List<JsonObject> points = getCurrentTopology();
TopologyGraph graph = new TopologyGraph();
graph.addGraph(points);
if (arg > 0) {
ContractResult nextRouters = executeContract(RepoProxy.router, "listLRS", new JsonPrimitive("a"));
JsonArray routersArray = nextRouters.result.getAsJsonObject().get("data").getAsJsonArray();
for (JsonElement je : routersArray) {
if (!je.getAsJsonObject().get("doId").getAsString().startsWith(points.get(0).get("doId").getAsString())) {
@ -186,6 +209,7 @@ public class TopologyCollector {
}
lastUpdate = System.currentTimeMillis();
cachedGraph = graph;
return graph.ret;
}
}

View File

@ -1,14 +1,14 @@
import "repodetail.yjs";
import "search.yjs";
import "audit.yjs";
import "networking.yjs";
import "DAC.yjs";
import "union.yjs";
import "ShanxiAuditPRoxy.yjs";
import "ShanxiDataRepo.yjs";
import "ShanxiGlobalRouter.yjs";
import "ShanxiRegistry.yjs";
//网关为Gateway
//路由器改名为Resolver中文名为标识解析系统
//搜索引擎改名为为Registry中文名为注册表系统
//本文接口由李智负责对接。
contract ControlProxy {
contract ShanxiControlProxy {
function convertArgToJson(arg) {
if (typeof(arg)=='string' && !arg.startsWith("{")) return arg;
if (typeof(arg)=='string') return JSON.parse(arg);
@ -54,14 +54,14 @@ contract ControlProxy {
};
}
//网关需新增的接口
@Description("参数为,{\"doId\":\"bdware.ss/Repox\"}")
export function pingRepo(arg) {
arg = convertArgToJson(arg);
if (arg.doId ==undefined ){
return {
"msg":"missing arguments repoId ", "code":1
};
}
//@Description("参数为,{\"doId\":\"bdware.ss/Repox\"}")
//export function pingRepo(arg) {
//arg = convertArgToJson(arg);
//if (arg.doId ==undefined ){
// return {
// "msg":"missing arguments repoId ", "code":1
// };
//}
// var ret = executeContract("Gateway", "pingRepo", arg.doId);
// ret = ret.result;
// if (ret.rrt > 0)
@ -70,8 +70,8 @@ contract ControlProxy {
// }; else return {
// "msg":"repo is unconnected", "code":1
// };
return org.bdware.sc.controlproxy.RepoProxy.pingRepo(arg.doId);
}
//return org.bdware.sc.controlproxy.RepoProxy.pingRepo(arg.doId);
//}
@Description("shanxi/TestLocal shanxi/Repository")
export function testPingRepo(arg) {
@ -83,14 +83,14 @@ contract ControlProxy {
return org.bdware.sc.controlproxy.RepoProxy.getRepoStatistics(arg);
}
//网关的接口
@Description("无参数")
export function getRepoList(arg) {
//@Description("无参数")
//export function getRepoList(arg) {
//use configed arg.routerId;
ret = executeContract(Global.router, "listRepo", "");
// ret = executeContract(Global.router, "listRepo", "");
//ret=executeContract("Gateway","listLocalRepo","");
//var list = ret.result
return ret.result;
}
// return ret.result;
//}
//网关的接口
@Description("参数为 {\"doId\":\"bdware.ss/Repox\"}")
export function deleteRepo(arg) {
@ -106,17 +106,17 @@ contract ControlProxy {
};
}
//网关的接口 需新增
@Description("参数为 [{\"doId\":\"bdware.ss/Repox\"},{\"doId\":\"bdware.ss/Repoy\"}]")
export function deleteRepoList(arg) {
arg = convertArgToJson(arg);
var ret = [];
for (var i = 0;
i<arg.length;
i++){
ret.push(deleteRepo(arg[i]));
}
return ret;
}
//@Description("参数为 [{\"doId\":\"bdware.ss/Repox\"},{\"doId\":\"bdware.ss/Repoy\"}]")
//export function deleteRepoList(arg) {
// arg = convertArgToJson(arg);
// var ret = [];
// for (var i = 0;
// i<arg.length;
// i++){
// ret.push(deleteRepo(arg[i]));
// }
// return ret;
//}
//网关的接口
@Description("参数为 {\"doId\":..., \"address\":..., \"owner\":..., }")
export function updateRepo(arg) {
@ -137,9 +137,9 @@ contract ControlProxy {
}
export function getAllTopology(arg) {
if (arg==null|| arg.length==0) {
return org.bdware.sc.controlproxy.TopologyCollector.getLevelTopology(2);
} else return org.bdware.sc.controlproxy.TopologyCollector.getLevelTopology(arg/1.0);
if (arg==null|| arg.length==0) {
return org.bdware.sc.controlproxy.TopologyCollector.getLevelTopology(2);
} else return org.bdware.sc.controlproxy.TopologyCollector.getLevelTopology(arg/1.0);
}
//总体拓扑图
//@范博

View File

View File

View File

@ -0,0 +1,8 @@
module ShanxiAuditPRoxy{
export function countDOIPRecordByDate() {
return executeContract("AuditProxy","countDOIPRecordByDate",arg).result;
}
export function getDOIPStatistic() {
return executeContract("AuditProxy","getDOIPStatistic",arg).result;
}
}

View File

@ -0,0 +1,44 @@
module ShanxiDataRepo{
export function getDataDoList() {
return executeContract("ShanxiDataRepo","getDataDoList",arg).result;
}
export function deleteDataDo() {
return executeContract("ShanxiDataRepo","deleteDataDo",arg).result;
}
export function createDataDo() {
return executeContract("ShanxiDataRepo","createDataDo",arg).result;
}
export function retrieveDataDo() {
return executeContract("ShanxiDataRepo","retrieveDataDo",arg).result;
}
export function updateDataDo() {
return executeContract("ShanxiDataRepo","updateDataDo",arg).result;
}
export function createViewDo() {
return executeContract("ShanxiDataRepo","createViewDo",arg).result;
}
export function updateViewDo() {
return executeContract("ShanxiDataRepo","updateViewDo",arg).result;
}
export function getViewDoList() {
return executeContract("ShanxiDataRepo","getViewDoList",arg).result;
}
export function deleteViewDo() {
return executeContract("ShanxiDataRepo","deleteViewDo",arg).result;
}
export function retrieveViewDo() {
return executeContract("ShanxiDataRepo","retrieveViewDo",arg).result;
}
export function addAuthedUser() {
return executeContract("ShanxiDataRepo","addAuthedUser",arg).result;
}
export function deleteAuthedUser() {
return executeContract("ShanxiDataRepo","deleteAuthedUser",arg).result;
}
export function addAuthedNode() {
return executeContract("ShanxiDataRepo","addAuthedNode",arg).result;
}
export function deleteAuthedNode() {
return executeContract("ShanxiDataRepo","deleteAuthedNode",arg).result;
}
}

View File

@ -0,0 +1,260 @@
module ShanxiGlobalRouter {
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.code = 0;
} else {
YancloudUtil.exceptionReturn({
"msg" : obj.data, "code" : 1
});
}
obj.data.status = "online";
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";
}
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", JSON.stringify(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 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;
}
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 listRepository(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,\"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 createRepository(arg) {
if (! checkPermission(requester)) {
YancloudUtil.exceptionReturn({
"msg" : "no permission", "code" : 1
});
}
var ret = executeContract(Global.router, "createRepo", JSON.stringify(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,\"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 updateRepository(arg) {
if (! checkPermission(requester)) {
YancloudUtil.exceptionReturn({
"msg" : "no permission", "code" : 1
});
}
var ret = executeContract(Global.router, "updateRepo", JSON.stringify(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,\"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({
"!name" : "string", "!doId" : "string", "!pubKey" : "string"
})
export function deleteRepository(arg) {
if (! checkPermission(requester)) {
YancloudUtil.exceptionReturn({
"msg" : "no permission", "code" : 1
});
}
var ret = executeContract(Global.router, "deleteRepo", JSON.stringify(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 getUpperRouterInfo() {
return executeContract(Global.router, "getUpperRouterInfo", arg).result;
}
@ArgSchema({
"!upperIP" : "string", "!upperPort" : "string", "!pubKey" : "string", "!name" : "string", "!signature" : "string"
})
//待测试
export function setUpperInfo(arg) {
if (! checkPermission(requester)) {
YancloudUtil.exceptionReturn({
"msg" : "no permission", "code" : 1
});
}
var ret = executeContract(Global.router, "setUpperIP", JSON.stringify(arg));
var obj = ret.result;
if (obj.result == "success" || obj.result == undefined) {
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({
"msg" : obj.data, "extraMsg" : "error in setUpperIP", "code" : 1
});
}
ret = executeContract(Global.router, "setUpperPort", JSON.stringify(arg));
obj = ret.result;
if (obj.result == "success" || obj.result == undefined) {
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({
"msg" : obj.data, "extraMsg" : "error in setUpperPort", "code" : 1
});
}
ret = executeContract(Global.router, "setName", JSON.stringify(arg));
obj = ret.result;
if (obj.result == "success" || obj.result == undefined) {
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({
"msg" : obj.data, "extraMsg" : "error in setName", "code" : 1
});
}
ret = executeContract(Global.router, "setPubKey", JSON.stringify(arg));
obj = ret.result;
if (obj.result == "success" || obj.result == undefined) {
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({
"msg" : obj.data, "extraMsg" : "error in setPubKey", "code" : 1
});
}
ret = executeContract(Global.router, "setSignature", JSON.stringify(arg));
obj = ret.result;
if (obj.result == "success" || obj.result == undefined) {
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({
"msg" : obj.data, "extraMsg" : "error in setSignature", "code" : 1
});
}
ret = executeContract(Global.router, "reInit", JSON.stringify(arg));
obj = ret.result;
if (obj.result == "success" || obj.result == undefined) {
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({
"msg" : obj.data, "extraMsg" : "error in reInit", "code" : 1
});
}
return obj;
}
}

View File

@ -0,0 +1,86 @@
module ShanxiRegistry{
export function getAllRepoCount() {
return executeContract("ShanxiRegistry","getAllRepoCount","").result;
}
export function getAllDoCount() {
return executeContract("ShanxiRegistry","getAllDoCount","").result;
}
export function getAllSearchCount() {
return executeContract("ShanxiRegistry","getAllSearchCount","").result;
}
export function getIndexStatistics() {
return executeContract("ShanxiRegistry","getIndexStatistics","").result;
}
export function getRepoList() {
return executeContract("ShanxiRegistry","getRepoList","").result;
}
export function pingRepo(arg) {
return executeContract("ShanxiRegistry","pingRepo",arg).result;
}
export function addRepoToRegistry(arg) {
return executeContract("ShanxiRegistry","addRepoToRegistry",arg).result;
}
export function updateRepoInRegistry(arg) {
return executeContract("ShanxiRegistry","updateRepoInRegistry",arg).result;
}
export function deleteRepoList(arg) {
return executeContract("ShanxiRegistry","deleteRepoList",arg).result;
}
export function listDataRequirement() {
return executeContract("ShanxiRegistry","listDataRequirement",arg).result;
}
export function getDataRequirementIssueList() {
return executeContract("ShanxiRegistry","getDataRequirementIssueList",arg).result;
}
export function createDataRequirement() {
return executeContract("ShanxiRegistry","createDataRequirement",arg).result;
}
export function issueDataRequirement() {
return executeContract("ShanxiRegistry","issueDataRequirement",arg).result;
}
export function updateDataRequirement() {
return executeContract("ShanxiRegistry","updateDataRequirement",arg).result;
}
export function getDataRequirement(arg) {
return executeContract("ShanxiRegistry","getDataRequirement",arg).result;
}
export function deleteDataRequirement() {
return executeContract("ShanxiRegistry","deleteDataRequirement",arg).result;
}
export function getDoCount(arg) {
var ret = executeContract("ShanxiRegistry", "getDoCount", arg);
if (arg.indexOf("shanxi/Repository") != - 1)
ret.result.data.push({
"doId" : "shanxi/Repository", "count" : 3
});
return ret.result;
}
export function addSubRegistry() {
return executeContract("ShanxiRegistry","addSubRegistry",arg).result;
}
export function deleteSubRegistry() {
return executeContract("ShanxiRegistry","deleteSubRegistry",arg).result;
}
export function listSubRegistry() {
return executeContract("ShanxiRegistry","listSubRegistry",arg).result;
}
export function getRelationInfo() {
return executeContract("ShanxiRegistry","getRelationInfo",arg).result;
}
@ArgSchema({
"!searchCondition" : [{
"!type" : "string", "!value" : "integer"
}], "count" : "integer", "offset" : "integer"
})
export function search(arg) {
arg = convertArgToJson(arg);
var req = {"id":"","attributes":{},"body":""};
for (var i=0;i<arg.searchCondition.length;i++){
req.attributes[arg.searchCondition[i].type] = arg.searchCondition[i].value;
}
req.attributes["offset"] = arg.offset;
req.attributes["count"] = arg.count;
var res = executeContract("ShanxiRegistry", "search", arg);
return res.result;
}
}

View File

Before

Width:  |  Height:  |  Size: 352 B

After

Width:  |  Height:  |  Size: 352 B

View File

@ -1,7 +1,7 @@
module Audit{
export function getDoipAction(){
return [
{ value: 0, name: '0.DOIP/Op.Hello' },
{ value: 0, name: '0.DOIP/Op.Hello' },niz
{ value: 1, name: '0.DOIP/Op.ListOperations' },
{ value: 2, name: '0.DOIP/Op.Retrieve' },
{ value: 3, name: '0.DOIP/Op.Create' },

View File

View File

View File

@ -0,0 +1 @@
Subproject commit 44e44ea119b5b1fdf35be3a46b9db7d6a37b8d2b

View File

@ -1,3 +0,0 @@
REPO_USRNAME=caihuaqian@internetapi.cn
REPO_PASSWORD=527e259ef952a450d157fdb51ac4915154cea317
REPO_HOST=https://gitea.internetapi.cn/

18
grepcp.list Normal file
View File

@ -0,0 +1,18 @@
yjs.jar
checker-qual-3.31.0.jar
common-1.7.9.jar
cp-1.9.9.jar
delta-crdts-1.2.0.jar
doip-audit-tool-1.4.0.jar
doip-encrypt-tool-0.1.0.jar
doip-sdk-1.5.0.jar
gson-2.10.1.jar
irp-sdk-1.1.6.jar
mysql-connector-j-8.0.33.jar
netty-buffer-4.1.86.Final.jar
netty-codec-4.1.86.Final.jar
netty-common-4.1.86.Final.jar
netty-resolver-4.1.86.Final.jar
netty-transport-4.1.86.Final.jar
postgresql-42.6.0.jar
protobuf-java-3.21.9.jar

7
iod-docker-deploy/.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
.DS_Store
/bdcontract/BDWareProjectDir/
/bdcontract/ContractDB/
/bdcontract/ContractManagerDB/
/bdcontract/rocksdb/
/bdcontract/tls/
/.idea/

View File

@ -0,0 +1,42 @@
# 镜像准备
如果使用默认镜像则不用此步骤。
请提前熟悉docker常用命令主要包括`docker ps`、`docker image xx`、`docker kill`等。
1. 如果想使用最新的镜像,可以先下载或导入镜像:
```bash
#下载镜像
docker pull bdware/bdcontract:latest
#导入镜像bdcontract-x.x.x.tar为待导入镜像文件。
docker load -i bdcontract-x.x.x.tar
```
镜像备用下载链接:
```
链接:https://pan.baidu.com/s/1Mot0NKdCqqGkCACKo7sxvw?pwd=h3y4 提取码:h3y4
```
2. 检查是否有"bdware/bdcontract:xx"镜像。 该版本号`xx`需与docker-compose.yml中一致。
```bash
docker image ls | grep bdcontract
```
如果没有名为"bdware/bdcontract latest"的镜像,就将其中的最新版本打上。
docker image tag bdware/bdcontract:x.y.z bdware/bdcontract:latest
# 修改配置
如果不需自定义管理员密钥,则无需修改配置。
1. 生成管理员密钥对。 将公钥配置到manager.key中。 格式为单行130个字符。类似于
```
04dad765858...
```
也可利用cp目录下的jar包自己生成:
```bash
docker-compose up -d
docker ps
#查看bdcontract镜像的docker id
docker exec -it xxx /bin/bash
#本操作需要依赖java 1.8以上环境。
java -cp cp/libs:cp/yjs.jar org.bdware.sc.SM2Helper generateKeyToFile
```
生成的文件请妥善保存。
2. 修改配置文件cmconfig.json如果需要配置文件参数详见`bdcontract`目录下的`cmconfig.readme.md`配置说明。
3. 重启容器。

127
iod-docker-deploy/LICENSE Normal file
View File

@ -0,0 +1,127 @@
木兰宽松许可证, 第2版
木兰宽松许可证, 第2版
2020年1月 http://license.coscl.org.cn/MulanPSL2
您对“软件”的复制、使用、修改及分发受木兰宽松许可证第2版“本许可证”的如下条款的约束
0. 定义
“软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
“贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
“贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
“法人实体”是指提交贡献的机构及其“关联实体”。
“关联实体”是指对“本许可证”下的行为方而言控制、受控制或与其共同受控制的机构此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
1. 授予版权许可
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。
2. 授予专利许可
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。
3. 无商标许可
“本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可但您为满足第4条规定的声明义务而必须使用除外。
4. 分发限制
您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
5. 免责声明与责任限制
“软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。
6. 语言
“本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。
条款结束
如何将木兰宽松许可证第2版应用到您的软件
如果您希望将木兰宽松许可证第2版应用到您的新软件为了方便接收者查阅建议您完成如下三步
1 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字;
2 请您在软件包的一级目录下创建以“LICENSE”为名的文件将整个许可证文本放入该文件中
3 请将如下声明文本放入每个源文件的头部注释中。
Copyright (c) [Year] [name of copyright holder]
[Software Name] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
Mulan Permissive Software LicenseVersion 2
Mulan Permissive Software LicenseVersion 2 (Mulan PSL v2)
January 2020 http://license.coscl.org.cn/MulanPSL2
Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions:
0. Definition
Software means the program and related documents which are licensed under this License and comprise all Contribution(s).
Contribution means the copyrightable work licensed by a particular Contributor under this License.
Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License.
Legal Entity means the entity making a Contribution and all its Affiliates.
Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, control means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity.
1. Grant of Copyright License
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not.
2. Grant of Patent License
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken.
3. No Trademark License
No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4.
4. Distribution Restriction
You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software.
5. Disclaimer of Warranty and Limitation of Liability
THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW ITS CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
6. Language
THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL.
END OF THE TERMS AND CONDITIONS
How to Apply the Mulan Permissive Software LicenseVersion 2 (Mulan PSL v2) to Your Software
To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps:
i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner;
ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package;
iii Attach the statement to the appropriate annotated syntax at the beginning of each source file.
Copyright (c) [Year] [name of copyright holder]
[Software Name] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.

View File

@ -0,0 +1,44 @@
# 启动方式
当前默认参数已配置好安装完docker可直接启动。
如果需要对镜像版本、管理员密钥及其他参数进行配置,可参考[IMAGECONF.md](./IMAGECONF.md)。
1. 安装部署好docker及docker-compose。
2. 进行初始化
如果镜像下载不了,可使用[备用链接](https://pan.baidu.com/s/1Mot0NKdCqqGkCACKo7sxvw?pwd=h3y4)下载后,使用`docker load -i xxx.tar` 来导入镜像。
```bash
sh init.sh
```
3. 启动
```bash
docker-compose up -d
```
4. 使用
```
标识解析系统地址:`http://127.0.0.1:21030/DOIP/GlobalRouter/assets/`
标识解析系统在右上角输入默认的密钥对,密钥文本在`./bdcontract/manager.keypair`中。
仓库的doip地址`tcp://127.0.0.1:21035`可通过测试用例发起doip请求。
仓库的http地址`http://127.0.0.1:21030/client/bdwareclient.html?self=true&contract=RepositoryExample`。
注册表地址:`http://127.0.0.1:21030/DOIP/Registry/assets/`
数字对象浏览器url应该为http://ip:port/SCIDE同时还需要相应权限的key-pair可以成功登陆DOBrowser
```
# 配置文件说明
配置文件在deploy/bdcontract/cmconfig.json。
本镜像包含了标识解析系统和数字对象仓库两个模块。
cmconfig.json的详细配置参数见
标识解析系统的启动参数说明见标识解析系统的源码仓库。
各构件的启动参数详见三个代码仓库。
[数字对象仓库示例](https://gitee.com/BDWare/datanet-repo-bundle)
[数字对象注册表](https://gitee.com/BDWare/datanet-search-engine-bundle)
[标识解析系统](https://gitee.com/BDWare/datanet-router-bundle)
# Docker常见问题
在linux环境下以普通用户启动docker可能会遇到权限的问题。可搜索`linux docker.sock权限被拒绝`。
```bash
sudo chmod 777 /var/run/docker.sock
```

View File

@ -0,0 +1,54 @@
{
"cmi": "_1650424170416",
"debug": "",
"disableDoRepo": false,
"disableLocalLhs": false,
"doipCertPath": "",
"doipLhsAddress": "",
"doipPort": 21032,
"doipUserHandle": "",
"enableEventPersistence": false,
"enableSsl": "./ssl/chained.pem:./ssl/domain.pem",
"ip": "127.0.0.1",
"isLAN": true,
"overwrite": false,
"servicePort": 21030,
"textFileSuffixes": ".yjs,.json,.txt,.css,.js,.html,.md,.conf,.csv",
"withBdledgerClient": "./runnable/bdledger_mac",
"withBdledgerServer": false,
"consistencyPlugins": "/bdcontract/nosuchlib/custom-plugin.jar",
"startContract": [
{
"path": "./BDWareProjectDir/defaultYpk/GlobalRouter-1.7.7.ypk",
"killBeforeStart": "GlobalRouter",
"createParam": {
"auditProxyAddress": "tcp://127.0.0.1:21051",
"controlProxyAddress": "ws://127.0.0.1:21030",
"repositoryAddress": "tcp://127.0.0.1:21035",
"registryAddress": "tcp://127.0.0.1:21036",
"name": "数瑞测试网",
"publicKey": "04180354fdb6507f8ab98ccfbe165ce11da74ba733f81af86ad6d32216b32cf4f797c559d50ceeefbf4c760c3483840471c67471b90acdffb388cd7d496d9a1610",
"privateKey": "1d4196947f59532db6f8f4055e58474a48db8f30b476ae3edc66406464521b3b",
"doId": "bdtest",
"routerAddress": "tcp://127.0.0.1:21041",
"scheme": "irp",
"nodeID": "_NODEID_",
"isRoot": true,
"enableBindRepo": true,
"enableFlex": true
}
},
{
"path": "./BDWareProjectDir/defaultYpk/Repository-1.2.5.ypk",
"killBeforeStart": "RepositoryExample",
"createParam": {
"prefix": "bdtest",
"repoName": "Repository",
"routerURI": "tcp://127.0.0.1:21041",
"publicKey": "04180354fdb6507f8ab98ccfbe165ce11da74ba733f81af86ad6d32216b32cf4f797c559d50ceeefbf4c760c3483840471c67471b90acdffb388cd7d496d9a1610",
"privateKey": "1d4196947f59532db6f8f4055e58474a48db8f30b476ae3edc66406464521b3b"
}
}
],
"datachainConf": "127.0.0.1:21010"
}

View File

@ -0,0 +1,84 @@
{
"cmi": "_1650424170416",
"debug": "",
"disableDoRepo": false,
"disableLocalLhs": false,
"doipCertPath": "",
"doipLhsAddress": "",
"doipPort": 21032,
"doipUserHandle": "",
"enableEventPersistence": false,
"enableSsl": "./ssl/chained.pem:./ssl/domain.pem",
"ip": "127.0.0.1",
"isLAN": true,
"overwrite": false,
"servicePort": 21030,
"textFileSuffixes": ".yjs,.json,.txt,.css,.js,.html,.md,.conf,.csv",
"withBdledgerClient": "./runnable/bdledger_mac",
"withBdledgerServer": false,
"consistencyPlugins": "/bdcontract/nosuchlib/custom-plugin.jar",
"startContract": [
{
"path": "./BDWareProjectDir/publicCompiled/GlobalRouter-1.7.7.ypk",
"killBeforeStart": "GlobalRouter",
"createParam": {
"auditProxyAddress": "tcp://127.0.0.1:21051",
"controlProxyAddress": "ws://127.0.0.1:21030",
"repositoryAddress": "tcp://127.0.0.1:21035",
"registryAddress": "tcp://127.0.0.1:21036",
"name": "数瑞测试网",
"publicKey": "04180354fdb6507f8ab98ccfbe165ce11da74ba733f81af86ad6d32216b32cf4f797c559d50ceeefbf4c760c3483840471c67471b90acdffb388cd7d496d9a1610",
"privateKey": "1d4196947f59532db6f8f4055e58474a48db8f30b476ae3edc66406464521b3b",
"doId": "bdtest",
"routerAddress": "tcp://127.0.0.1:21041",
"scheme": "irp",
"nodeID": "_NODEID_",
"isRoot": true,
"enableBindRepo": true,
"enableFlex": true
}
},
{
"path": "./BDWareProjectDir/publicCompiled/Repository-1.1.8.ypk",
"killBeforeStart": "RepositoryExample",
"createParam": {
"prefix": "bdtest",
"repoName": "Repository",
"routerURI": "tcp://127.0.0.1:21041",
"publicKey": "04180354fdb6507f8ab98ccfbe165ce11da74ba733f81af86ad6d32216b32cf4f797c559d50ceeefbf4c760c3483840471c67471b90acdffb388cd7d496d9a1610",
"privateKey": "1d4196947f59532db6f8f4055e58474a48db8f30b476ae3edc66406464521b3b"
}
},
{
"path": "./BDWareProjectDir/publicCompiled/Registry-1.3.5.ypk",
"killBeforeStart": "Registry",
"createParam": {
"prefix": "bdtest",
"publicKey": "04180354fdb6507f8ab98ccfbe165ce11da74ba733f81af86ad6d32216b32cf4f797c559d50ceeefbf4c760c3483840471c67471b90acdffb388cd7d496d9a1610",
"privateKey": "1d4196947f59532db6f8f4055e58474a48db8f30b476ae3edc66406464521b3b",
"repoName": "Registry",
"routerURI": "tcp://127.0.0.1:21041",
"doMetaName": "SearchEngineDoMetaIndex",
"initalIndexKeys": [
{
"key": "doId",
"description": "数字对象的标识"
},
{
"key": "owner",
"description": "数字对象的所有者"
},
{
"key": "type",
"description": "数据源类型"
},
{
"key": "description",
"description": "有关此数字对象的描述"
}
]
}
}
],
"datachainConf": "127.0.0.1:21010"
}

View File

@ -0,0 +1,80 @@
# 配置项
## 示例格式
```json
{
"cmi": "",
"debug": "",
"disableDoRepo": false,
"disableLocalLhs": false,
"doipCertPath": "",
"doipLhsAddress": "",
"doipPort": -1,
"doipUserHandle": "",
"enableEventPersistence": false,
"enableSsl": "./ssl/chained.pem:./ssl/domain.pem",
"ip": "127.0.0.1",
"isLAN": true,
"overwrite": false,
"servicePort": 21030,
"textFileSuffixes": ".yjs,.json,.txt,.css,.js,.html,.md,.conf,.csv",
"withBdledgerClient": "./runnable/bdledger_mac",
"withBdledgerServer": false,
"consistencyPlugins": "./libs/custom-plugin.jar",
"startContract": [],
"datachainConf": "021.node.internetapi.cn:21121"
}
```
## consistencyPlugins 配置
下述四项插件使用字符串分割如需添加多项以逗号分隔在cmconfig.json里修改如:
``````
"consistencyPlugins": "xxx/xxx.jar,xxx/xxx.jar"
``````
## 通讯插件配置
下述四项插件使用字符串分割如需添加多项在cmconfig.json里修改如:
``````
"wsPluginActions": "org.bdware.metering.MeteringAction"
``````
1. wsPluginActions: WS端,包括contractManagerFrameHandler和CMHttpHandler
2. clientToAgentPlugins: client -> cluster 包括MasterClientFrameHandler
3. clientToClusterPlugins:[], client -> NodeCenterClientHandler
4. tcpPlugins:tcp 包括TcpserverFrameHandler
## startContract配置说明
其中startConfig.json为json数组结构格式如下
```json
[
{
"path": "./BDWareProjectDir/publicCompiled/xxx.ypk",
"owner": "",
"killBeforeStart": "",
"createParam": {}
},
{
}
]
```
path为必填配置项。表示启动的ypk的路径。
owner为可选配置不填时使用NodeManger的key作为Owner。
killBeforeStart为可选配置填写kill的合约名称。
createParam为可选配置。表示合约的启动参数。
## datachainConf 配置说明
1.针对Window Docker/Mac Docker
可使用`"datachainConf":"host.docker.internal:2401"`进行配置。
2.针对Linux Docker可通过查看`docker 0`的网卡IP进行设置。
如:`"datachainConf":"172.16.10.1:2401"`。
3.如果是在同一dockercompose.yml下启动可以使用
`"datachainConf":"bdledger:2401"`进行配置。

View File

@ -0,0 +1 @@
04180354fdb6507f8ab98ccfbe165ce11da74ba733f81af86ad6d32216b32cf4f797c559d50ceeefbf4c760c3483840471c67471b90acdffb388cd7d496d9a1610

View File

@ -0,0 +1,2 @@
{ "publicKey": "04180354fdb6507f8ab98ccfbe165ce11da74ba733f81af86ad6d32216b32cf4f797c559d50ceeefbf4c760c3483840471c67471b90acdffb388cd7d496d9a1610",
"privateKey": "1d4196947f59532db6f8f4055e58474a48db8f30b476ae3edc66406464521b3b"}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -0,0 +1,312 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Cache-Control" content="no-cache"/>
<title>数瑞数联网系统</title>
<script src="./jqueryui1.12/jquery-2.1.4.js"></script>
<script src="./js/createWS.js"></script>
<script src="./js/cryptico.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/commonutil.js"></script>
<script src="./js/vue.js"></script>
<script src="./client/js/bdwareclient.js"></script>
<script src="./js/sm2.js"></script>
<link href="./css/common.css" rel="stylesheet">
<link href="./css/bootstrap.min.css" rel="stylesheet">
</head>
<body style="background: #2E324C; color: white;">
<div class="modal fade" id="pubkeyDialog" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle" style="color:black;">用户信息</h5>
</div>
<div class="modal-body">
<div class="row" style="padding-left: 16px; padding-right: 16px">
<div class="input-group mb-3">
<div class="input-group-prepend">
<label class="input-group-text" for="localKeyList">本地密钥</label>
</div>
<select class="custom-select"
aria-label="Example select with button addon"
style="appearance: none" v-model="selectedSM2Key"
@change="changeSM2Key($event)">
<option v-for="(item,index) in sm2KeyList" :key="index"
:value='item.id'>{{item.title}}
</option>
</select>
<div class="input-group-append">
<button class="btn btn-outline-primary" for="localKeyList"
v-on:click="exportPubkey">导出密钥
</button>
<button type="button" class="btn btn-outline-primary"
id="generatePubkeyBtn" v-on:click="generatePubkey">生成新密钥
</button>
<button class="btn btn-outline-danger" for="localKeyList"
v-on:click="deletePubkey">删除密钥
</button>
</div>
</div>
<textarea class="form-control mb-3" title="复制密钥,并妥善保存"
id="sm2KeyTextarea" v-model="sm2KeyStr"
style="width: 100%; min-height: 150px; resize:none" rows="" cols="">
</textarea>
<div class="row" style="padding-left: 16px; padding-right: 16px">
<div class="input-group mb-1">
<div class="input-group-prepend">
<label class="input-group-text" for="localKeyList">以上为当前SM2密钥请复制或导出密钥并妥善保存</label>
</div>
<div class="input-group-append">
<button type="button" class="btn btn-primary"
data-dismiss="modal" id="importPubkeyBtn"
v-on:click="importPubkey">确认
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div style="width: 90%; height:10px; max-width: 1000px; min-width: 850px; margin: 3% auto 0px;">
<header class="" style="float:right">
<div class=" nav navbar-right userName" data-toggle="modal" id="user"
data-target="#pubkeyDialog">当前用户: {{shortName}}
</div>
</header>
</div>
<style>
.halfDiv {
float: left;
width: 100%;
height: 100%;
}
.projectTreeDiv {
height: auto;
padding: 0;
}
.halfDivRight {
float: left;
width: 100%;
height: 100%;
}
.ui-tabs {
padding: 0;
}
.ui-accordion .ui-accordion-content {
padding: 0;
}
#tabs-1 {
display: none;
}
.ui-tabs .ui-tabs-panel {
padding: 0;
}
.context-menu-root {
z-index: 10;
}
#projectDiv {
height: 83%;
width: 20%;
border: 0px solid grey;
float: left;
}
.CodeMirror {
height: auto
}
.logoimg {
width: auto;
height: auto;
max-width: 100%;
max-height: 100%;
}
input {
height: 32px;
}
.sendTransInput {
background-color: #f0e4e4;
border-radius: 5px;
margin: 5px;
width: 15%;
margin-left: 4%;
border: 0px;
}
.normalDiv {
float: left;
text-align: center;
border-radius: 5px;
margin: 2%;
padding: 5px;
padding-top: 30px;
padding-bottom: 30px;
width: 29%;
cursor: hand;
background: #2E324C;
color: white;
}
.iconimg {
width: auto;
height: auto;
max-width: 48px;
max-height: 48px;
vertical-align: middle;
filter: invert(100%);
}
</style>
<div id="main" style="background: #2E324C; color: white;">
<input id="urlInput" style="display:none"/>
<input id="selectContract" style="display:none"/>
<div style="width: 90%; max-width: 1000px; min-width: 850px; margin: 0 auto; margin-top: 3%;">
<div style="width: 20%; float: right; margin-right: 0%;">
<img src="./images/logo.png" class="logoimg"></img>
</div>
<div style="width: fit-content; margin: 0; font-size: 200%; background-color: white; color: black; border-radius: 10px; float: left; padding: 10px;">
&nbsp;&nbsp;导航&nbsp;&nbsp;
</div>
<div style="width: 100%; margin-top: 2%; float: left; background-color: white; border-radius: 10px; display: flex;">
<div class="normalDiv" onclick="jumpTo('./DOIP/GlobalRouter/assets/#')" style="flex: 1;">
<img src="./images/datanet/identifier.png" class="iconimg"></img><br/>
<span style="vertical-align: middle">标识解析系统</span>
</div>
<div class="normalDiv" onclick="jumpTo('./DOIP/Registry/assets/#')" style="flex: 1;">
<img src="./images/datanet/search.png" class="iconimg"></img><br/>
<span style="vertical-align: middle">数字对象注册表</span>
</div>
<div class="normalDiv" onclick="jumpTo('./client/bdwareclient.html?self=true&contract=RepositoryExample')" style="flex: 1;">
<img src="./images/datanet/repo.png" class="iconimg"></img><br/>
<span style="vertical-align: middle">数字对象仓库</span>
</div>
<div class="normalDiv" onclick="jumpTo('./DOIP/BDBrowser/assets/#')" style="flex: 1;">
<img src="./images/datanet/browser.png" class="iconimg"></img><br/>
<span style="vertical-align: middle">数字对象浏览器</span>
</div>
</div>
<br/>
<div style="width: fit-content; margin-top: 2%; float: right; border-radius: 10px; font-size: 50%;">
Icons made by
<a href="https://www.flaticon.com/authors/monkik" title="monkik" style="color: white;">monkik</a>
from
<a href="https://www.flaticon.com/" title="Flaticon" style="color: white;">www.flaticon.com</a>
</div>
</div>
</div>
<script>
jumpTo = function (addr) {
document.location.href = addr;
};
const isBaaS = false
const h = document.body.clientHeight
- $("header").css("height").replace("px", "")
$("#main").css("height", h + "px");
function init() {
const urlParams = getRequestParameters();
initVue();
initGlobal(urlParams);
if (global.urlparam["noRender"] === "true") {
switchRenderBtn.innerHTML = "加载界面";
}
global.cbs = {};
const urlInput = $("#urlInput");
if (global.urlparam["self"] === "true") {
if (document.location.href.startsWith("http")) {
let path = document.location.origin + document.location.pathname;
path = path.replace("/client/bdwareclient.html", "");
urlInput[0].value = path.replace("http",
"ws");
if (global.urlparam["withNodeCenterWS"] === "true") {
urlInput[0].value += "/NodeCenterWS";
}
connectNode();
}
} else if (global.urlparam["nodeAddr"]) {
urlInput[0].value = global.urlparam["nodeAddr"];
connectNode();
} else {
const lastNode = localStorage.getItem("lastNode");
if (lastNode) {
urlInput[0].value = lastNode;
connectNode();
}
}
}
init();
$(document).ready(function(){
if(localStorage.getItem("PrivKeyList") == null || localStorage.getItem("agent") == null){
$('#pubkeyDialog').modal();
}else{
var div = document.getElementById("user");
// div.setAttribute("style","display:none");
}
})
$('#pubkeyDialog').on('hide.bs.modal', function () {
var div = document.getElementById("user");
var lst = JSON.parse(localStorage.getItem("PrivKeyList"));
lst.pop();
localStorage.setItem("PrivKeyList",JSON.stringify(lst));
});
</script>
</body>
</html>
<!--
============ NodeCenter的一些链接其中39.106.6.6监听的是1817端口。 查看节点是否启动
http://39.106.6.6:18001/SCIDE/NodeCenter?action=ping 查看NodeCenter当前连接的节点
http://39.106.6.6:18001/SCIDE/NodeCenter?action=listCMInfo
刷新NodeCenter已连接节点的合约数据
http://39.106.6.6:18001/SCIDE/NodeCenter?action=updateContract
检查节点是否已连接,删除断开连接的节点
http://39.106.6.6:18001/SCIDE/NodeCenter?action=checkAlive
获取某个合约的日志数量
http://39.106.6.6:18001/SCIDE/NodeCenter?action=getLogSize&contractID=BDCoin
获取某个合约的日志从第offset条取count条
http://39.106.6.6:18001/SCIDE/NodeCenter?action=requestLog&contractID=BDCoin&offset=16&count=10
获取某个合约的日志取最新的count条
http://39.106.6.6:18001/SCIDE/NodeCenter?action=requestLastLog&contractID=BDCoin&count=10
-->

View File

@ -0,0 +1,42 @@
node:
id: acb1cc2a7013ec8a7ea7eee0ec6f835851dd8e91
api:
grpc:
addr: :18021
http:
enabled: true
datastore:
source: /data/block
p2p:
identity:
peerId: QmeG9PE8NQ7q8M6xiovVp9u1UjZZWc8Wom1K5MomJgLuWs
privKey: CAASqQkwggSlAgEAAoIBAQDAb0X3U2HjgoUniXH8EMs6L8FHGU63BahbY+/7GjnVFXe0bSuPlpaUC2Twmhulvad/1nSCuF178UYoYQ6Qz1AwBl4IiZmQxhSXdZPEXrN3WnC70rrkMMQxz7sjevyEXm9EIUo4Hepxlvd6PlTHUaYOW4TXSsv5JqoZW4+itxane/tOCCpFM/ppftpz3N5RxO181mczm6cljHcShZXkHSxo0nn3sHSqixqbzv+c0x/c5YP+aue3MJX2IjODGEY1a3x3HwCmwK3IgUSKWyZk480codWeO/5JFLNKzlXzWAu2GG7v2MF1h3Fa4lwEGdCLILY2Ux9d+M3wRvoz7ZWYn0CTAgMBAAECggEALLgvLEDGWNa2FvAL+yXz9HuwkNNCxamc7FAXLuVzVx98CAPuwZmfOJxFQtytXCDs0fqGbPJnVyxEv5F+jwx+eAqiw50mgMxncKM0ScgwMKZl2GAqamkizuiVdrNYB3LirJSH6O6a0vbgYBooHYHN8zw1bMrHCAmCMg5jHM8rhpQTp22VIa4YxlQDUAQdvuN4ilIXxwiyxTpbQobH4hVmwwoeU65sbFSZQ219d/KXPkK1l9c3OGf9KTPWzG3uq2lx2BKrJ3TMZYdiGBDKc89m6TnOidVB5jC5VKT8S4idKUQocMcg8eMYEWtR/0YgS0YC0FBhmpHfiam/kJ0mc+L6YQKBgQD2CBwi8kwBqJISM9kOAu7k2vDTB6eb83YWaSq4aQ/AYKvtfUHLz9Ekx+EjPmtMIfvxvJ86NEuCK64Ag4I943dCEyZYE00xBL/Zwark0LxgIuR8tSkxlPoErUmFdLELqIsUJS4Izu8lkPXE6PSxDZMe2Klq0Nd7wVglgjHxpcotOwKBgQDIOz6NEW54F0amGATtVj7DUN36wSQwE2AX5cyWZeKcvJixKKCdLSPln6QFW7+vI7vR4umUcFFEUKO8HwGojcq4+EjiOn/CppQ1GwD2xNXKFiJ5Sl3wpnqARFNHj3rH8l3kI3V5qt0c0OSzKr3bMGUdKNREUaKlqg20e3YznSZkiQKBgQCEnPh1ib6YQkGB2DqNx9z2tGCMjxqz/7XN/J/PSKn52uGxIAvgDMNBnQ9oTNPO9J51vWLiH5/3qQ2gL0J7k2kLz4CihrzbyCCVAkPYE/8Fnqkj4w4yMIfXD4SKj8yCaTWWBThb/RaAXDNtENgbuyJqxQQElE8h4KRfi17aTq+8UwKBgQCONyYSZBMmUMHpLp4xRFSHvWQsugnN67UQxDMvj2YJFRsOmWCawnkAmwaQl73p02OPi6+DstLFxtDEyPEQmsUl45NAu3QK+O3DWk6w9tUyF86cf2mBh3zypZTQ+uOmKErvww+pPuaVlPkbGHyItjLbJyi87Y6sQ8BANICb4D5ooQKBgQDHC6rQTaGIaOgAQzBzFPdi2foFEXTr9zpp0iVYdTFJr68OhROEkzQetHdk5MYR6SWjf3wQk34GDUqtVXNzoIhUkD6P83QCZKmsrkvYiQH0aXjAmjLpcDvSgUFCxS8NcaHKeDNLHw3SH8zh0zDFE1vlXdYzittDjmnYPGEEJzrUlg==
addresses:
swarm:
- /ip4/0.0.0.0/tcp/18026
- /ip4/0.0.0.0/udp/18026/quic
bootstrap:
- /ip4/127.0.0.1/tcp/18026/p2p/QmeG9PE8NQ7q8M6xiovVp9u1UjZZWc8Wom1K5MomJgLuWs
pubsub:
router: gossipsub
heartbeatInterval: 10000
query:
maxDuration: 3600 # seconds
maxRequestLifetime: 3.0 # seconds
waitReservedTime: 1.0 # seconds
nrw:
numWitness: 0
numBackup: 0
txsPerBlock: 1000
blockGenCycle: 30000
requestTimeout: 16
messageTimeout: 5
log:
format: text
level: INFO

View File

@ -0,0 +1,35 @@
version: "3"
services:
# bdledger:
# image: bdware/bdledger:dev-210909.874f034d
# command: "-c /etc/bdledger/config.yml"
# restart: unless-stopped
# volumes:
# - ./bdledger/config.yml:/etc/bdledger/config.yml:ro
# - ./bdledger/data:/data
# ports:
# - "2416:2416" # P2P
# - "2401:2401" # API
bdcontract:
image: bdware/bdcontract:2.0.8
command: "-Dfile.encoding=UTF-8 -Djava.library.path='./dynamicLibrary' -Dlog4j.configurationFile=./log4j2.properties -cp ./libs/*:bdagent.jar org.bdware.server.CMHttpServer"
restart: unless-stopped
# depends_on:
# - bdledger
volumes:
- ./bdcontract/rocksdb:/bdcontract/rocksdb
- ./bdcontract/ContractDB:/bdcontract/ContractDB
- ./bdcontract/ContractManagerDB:/bdcontract/ContractManagerDB
- ./bdcontract/BDWareProjectDir:/bdcontract/BDWareProjectDir
- ./bdcontract/cmconfig.json:/bdcontract/cmconfig.json:ro
- ./bdcontract/web/index_datanet.html:/bdcontract/WebContent/ide/index.html:ro
- ./bdcontract/web/datanet:/bdcontract/WebContent/ide/images/datanet
# - ./bdcontract/cp:/bdcontract/cp
- ./bdcontract/tls:/bdcontract/tls:ro
- ./bdcontract/manager.key:/bdcontract/manager.key
- ./bdcontract/manager.keypair:/bdcontract/manager.keypair
ports:
- "21000-21100:21000-21100"
- "1615:1615"

17
iod-docker-deploy/init.sh Normal file
View File

@ -0,0 +1,17 @@
#!/bin/bash
docker-compose up -d
echo "Wait for 10 seconds to initialize dirs"
sleep 10
docker-compose down
echo "use command 'docker-compose up' to start!"
#export CURDIR=`pwd`/data
#
#docker run -p 21030-21033:21030-21033 -p 2641:2641 -p 2041:2041 -v $CURDIR/BDWareProjectDir:/bdcontract/BDWareProjectDir \
# -v $CURDIR/ContractDB:/bdcontract/ContractDB \
# -v $CURDIR/ContractManagerDB:/bdcontract/ContractManagerDB \
# -v $CURDIR/cmconfig.json:/bdcontract/cmconfig.json \
# -v $CURDIR/log:/bdcontract/log \
# -v $CURDIR/manager.key:/bdcontract/manager.key: \
# bdware/bdcontract:1.7.9
# -v $CURDIR/cp:/bdcontract/cp: \
# -v $CURDIR/keys:/bdcontract/keys: \

1
iod-repo-backend Submodule

@ -0,0 +1 @@
Subproject commit 5187ff51c158a27c151654d368a7072cce78657b

View File

@ -1,2 +1,4 @@
rootProject.name = 'ControlProxy'
include 'backend'
include 'control-proxy-backend'
include 'iod-repo-backend'
include 'datanet-search-engine-backend'