├── provider ├── blank ├── .gitignore ├── pkg │ ├── pconst │ │ └── pconst.go │ ├── util │ │ ├── func.go │ │ ├── structure │ │ │ └── structure.go │ │ ├── trace │ │ │ └── trace.go │ │ ├── uuid │ │ │ └── uuid.go │ │ └── json │ │ │ └── json.go │ ├── errors │ │ └── errors.go │ ├── web3 │ │ └── eth │ │ │ └── eth.go │ ├── logger │ │ └── hook │ │ │ └── redis │ │ │ └── redis.go │ └── certificate │ │ └── verify.go ├── Dockerfile ├── internal │ ├── bll │ │ └── bll.go │ ├── schema │ │ ├── schema.go │ │ └── s_resource.go │ ├── contextx │ │ └── contextx.go │ ├── dao │ │ └── provider │ │ │ ├── service │ │ │ └── provider.go │ │ │ └── model │ │ │ └── provider.go │ ├── server │ │ ├── eth.go │ │ └── node.go │ └── logger.go ├── cmd │ └── main.go ├── Makefile ├── README.md └── configs │ └── config.toml ├── portal ├── .env.production ├── .browserslistrc ├── src │ ├── styles │ │ ├── index.scss │ │ └── variables.scss │ ├── utils │ │ ├── event-bus.js │ │ ├── cache.js │ │ ├── request.js │ │ └── request-helper.js │ ├── assets │ │ ├── bg.png │ │ ├── logo.png │ │ ├── logo2.png │ │ └── logo.svg │ ├── api │ │ ├── user.js │ │ ├── index.js │ │ ├── nodes.js │ │ ├── servers.js │ │ ├── relay.js │ │ ├── resource.js │ │ └── clients.js │ ├── plugins │ │ └── vuetify.js │ ├── permission.js │ ├── main.js │ ├── store │ │ └── index.js │ ├── router │ │ └── index.js │ ├── App.vue │ ├── views │ │ ├── login.vue │ │ └── HomeView.vue │ └── components │ │ └── pem-dialog.vue ├── .env.test ├── cypress.json ├── jest.config.js ├── .env.development ├── public │ ├── favicon.ico │ ├── favicon.png │ └── index.html ├── babel.config.js ├── Dockerfile ├── tests │ ├── e2e │ │ ├── .eslintrc.js │ │ ├── specs │ │ │ └── test.js │ │ ├── support │ │ │ ├── index.js │ │ │ └── commands.js │ │ └── plugins │ │ │ └── index.js │ └── unit │ │ └── example.spec.js ├── jsconfig.json ├── vue.config.js ├── .gitignore ├── docs │ └── docker.md ├── README.md └── package.json ├── fullnode ├── app │ ├── v1 │ │ ├── user │ │ │ ├── dao │ │ │ │ └── api │ │ │ │ │ ├── facebook.go │ │ │ │ │ ├── google.go │ │ │ │ │ └── github.go │ │ │ ├── model │ │ │ │ ├── mparam │ │ │ │ │ └── user.go │ │ │ │ ├── mmysql │ │ │ │ │ └── user.go │ │ │ │ └── mapi │ │ │ │ │ └── github.go │ │ │ └── controller │ │ │ │ └── user.go │ │ ├── controlplane │ │ │ ├── model │ │ │ │ └── mparam │ │ │ │ │ └── machine.go │ │ │ └── controller │ │ │ │ └── machine.go │ │ ├── node │ │ │ └── model │ │ │ │ ├── mapi │ │ │ │ └── node.go │ │ │ │ ├── mparam │ │ │ │ └── node.go │ │ │ │ └── mmysql │ │ │ │ └── node.go │ │ └── access │ │ │ └── model │ │ │ ├── mapi │ │ │ ├── resource.go │ │ │ └── client.go │ │ │ ├── mmysql │ │ │ ├── resource.go │ │ │ └── client.go │ │ │ └── mparam │ │ │ ├── resource.go │ │ │ └── client.go │ └── base │ │ ├── mapi │ │ └── base.go │ │ ├── controller │ │ ├── home.go │ │ └── controller.go │ │ └── mdb │ │ └── paginate.go ├── work.jpg ├── .gitignore ├── examples │ └── helm │ │ ├── Chart.yaml │ │ ├── templates │ │ ├── service.yaml │ │ ├── ingress.yaml │ │ └── deployment-portal.yaml │ │ └── values.yaml ├── test │ ├── base64_test.go │ ├── key_test.go │ └── json_test.go ├── pkg │ ├── curl │ │ └── curl.go │ ├── logger │ │ └── config.go │ ├── middle │ │ ├── cors.go │ │ ├── session.go │ │ └── oauth2.go │ ├── redis │ │ └── redis.go │ ├── oauth2 │ │ └── option.go │ ├── util │ │ └── json │ │ │ └── json.go │ ├── schema │ │ └── s_server.go │ ├── p2p │ │ └── server.go │ └── confer │ │ ├── config_app.go │ │ └── viper.go ├── Dockerfile ├── route │ ├── node │ │ └── node.go │ ├── controlplane │ │ └── controlplane.go │ ├── user │ │ └── user.go │ ├── route.go │ └── access │ │ └── access.go ├── server │ ├── http.go │ └── init.go ├── main.go ├── config.yaml ├── config_nervos.yaml ├── config_eth.yaml ├── agent │ ├── user.go │ └── client.go ├── pconst │ ├── api.go │ └── code.go ├── Makefile └── config_dev.yaml ├── deploy ├── provider │ ├── db │ │ └── sqlite.db │ ├── sqlite_config.yaml │ └── docker-compose.yaml └── fullnode │ └── docker-compose │ ├── db │ └── sqlite.db │ ├── ca_config.json │ └── nginx.conf ├── client ├── .gitignore ├── configs │ ├── embed.go │ └── config.toml ├── pkg │ ├── pconst │ │ └── pconst.go │ ├── util │ │ ├── structure │ │ │ └── structure.go │ │ ├── trace │ │ │ └── trace.go │ │ ├── func.go │ │ ├── uuid │ │ │ └── uuid.go │ │ └── json │ │ │ └── json.go │ ├── errors │ │ └── errors.go │ ├── logger │ │ └── hook │ │ │ └── redis │ │ │ └── redis.go │ └── certificate │ │ └── verify.go ├── internal │ ├── bll │ │ └── bll.go │ ├── machine.go │ ├── contextx │ │ └── contextx.go │ ├── schema │ │ ├── schema.go │ │ ├── s_server.go │ │ └── s_resource.go │ └── logger.go ├── go.mod ├── cmd │ └── main.go └── README.md ├── verifier ├── app │ ├── v1 │ │ └── node │ │ │ ├── model │ │ │ └── mparam │ │ │ │ └── health.go │ │ │ ├── service │ │ │ └── health.go │ │ │ └── controller │ │ │ └── health.go │ └── base │ │ ├── mapi │ │ └── base.go │ │ ├── controller │ │ ├── home.go │ │ └── controller.go │ │ └── mdb │ │ └── paginate.go ├── verify │ ├── options.go │ ├── record.go │ └── provider.go ├── route │ ├── health │ │ └── health.go │ └── route.go ├── pkg │ ├── logger │ │ └── config.go │ ├── middle │ │ └── cors.go │ ├── confer │ │ ├── config_code.go │ │ └── config_app.go │ ├── gin │ │ └── gin.go │ └── mysql │ │ └── mysql.go ├── Dockerfile ├── config.yaml ├── config_dev.yaml ├── server │ ├── http.go │ └── init.go ├── main.go └── pconst │ ├── api.go │ └── code.go ├── contract ├── artifacts │ ├── contracts │ │ └── CloudSlitDao.sol │ │ │ └── CloudSlitDao.dbg.json │ └── @openzeppelin │ │ ├── contracts │ │ ├── utils │ │ │ └── Context.sol │ │ │ │ ├── Context.dbg.json │ │ │ │ └── Context.json │ │ └── token │ │ │ └── ERC20 │ │ │ ├── ERC20.sol │ │ │ └── ERC20.dbg.json │ │ │ ├── IERC20.sol │ │ │ └── IERC20.dbg.json │ │ │ └── extensions │ │ │ └── IERC20Metadata.sol │ │ │ └── IERC20Metadata.dbg.json │ │ └── contracts-upgradeable │ │ ├── proxy │ │ └── utils │ │ │ └── Initializable.sol │ │ │ ├── Initializable.dbg.json │ │ │ └── Initializable.json │ │ ├── utils │ │ ├── AddressUpgradeable.sol │ │ │ ├── AddressUpgradeable.dbg.json │ │ │ └── AddressUpgradeable.json │ │ └── ContextUpgradeable.sol │ │ │ ├── ContextUpgradeable.dbg.json │ │ │ └── ContextUpgradeable.json │ │ ├── access │ │ └── OwnableUpgradeable.sol │ │ │ ├── OwnableUpgradeable.dbg.json │ │ │ └── OwnableUpgradeable.json │ │ ├── security │ │ └── PausableUpgradeable.sol │ │ │ ├── PausableUpgradeable.dbg.json │ │ │ └── PausableUpgradeable.json │ │ └── token │ │ └── ERC20 │ │ ├── ERC20Upgradeable.sol │ │ └── ERC20Upgradeable.dbg.json │ │ ├── IERC20Upgradeable.sol │ │ └── IERC20Upgradeable.dbg.json │ │ └── extensions │ │ ├── ERC20BurnableUpgradeable.sol │ │ └── ERC20BurnableUpgradeable.dbg.json │ │ └── IERC20MetadataUpgradeable.sol │ │ └── IERC20MetadataUpgradeable.dbg.json ├── .gitignore ├── scripts │ ├── upgrade.js │ └── deploy.js ├── package.json └── hardhat.config.js ├── ca ├── conf.yml ├── util │ ├── cert.go │ ├── ip_addr.go │ └── cache.go ├── ca │ └── singleca │ │ └── err.go ├── .gitignore ├── Dockerfile ├── pkg │ ├── spiffe │ │ ├── idg_test.go │ │ └── idg.go │ ├── logger │ │ ├── redis_hook │ │ │ ├── loggers.go │ │ │ └── redis_hook.go │ │ ├── logger_test.go │ │ └── example │ │ │ └── single_test.go │ ├── signature │ │ ├── signer_test.go │ │ ├── signer.go │ │ └── util.go │ ├── keyprovider │ │ └── xkey_provider_test.go │ └── pkiutil │ │ └── dual_use.go ├── core │ ├── state.go │ └── config │ │ └── types.go ├── Makefile ├── initer │ ├── initer.go │ └── logger.go ├── main.go └── config.json ├── .gitignore ├── .github ├── dependabot.yml └── workflows │ └── build.yml └── LICENSE /provider/blank: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /portal/.env.production: -------------------------------------------------------------------------------- 1 | VUE_APP_BASE_URL="/api/v1" 2 | -------------------------------------------------------------------------------- /fullnode/app/v1/user/dao/api/facebook.go: -------------------------------------------------------------------------------- 1 | package api 2 | -------------------------------------------------------------------------------- /fullnode/app/v1/user/dao/api/google.go: -------------------------------------------------------------------------------- 1 | package api 2 | -------------------------------------------------------------------------------- /portal/.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not dead 4 | -------------------------------------------------------------------------------- /portal/src/styles/index.scss: -------------------------------------------------------------------------------- 1 | .cur-p { 2 | cursor: pointer; 3 | } 4 | -------------------------------------------------------------------------------- /portal/.env.test: -------------------------------------------------------------------------------- 1 | VUE_APP_BASE_URL="https://www.cloudslit.xyz/test/api" 2 | -------------------------------------------------------------------------------- /portal/cypress.json: -------------------------------------------------------------------------------- 1 | { 2 | "pluginsFile": "tests/e2e/plugins/index.js" 3 | } 4 | -------------------------------------------------------------------------------- /fullnode/work.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlowShield/flowshield/HEAD/fullnode/work.jpg -------------------------------------------------------------------------------- /portal/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: '@vue/cli-plugin-unit-jest' 3 | } 4 | -------------------------------------------------------------------------------- /portal/src/styles/variables.scss: -------------------------------------------------------------------------------- 1 | // 用于覆盖原有的 variable 2 | //$btn-text-transform: unset; 3 | -------------------------------------------------------------------------------- /portal/.env.development: -------------------------------------------------------------------------------- 1 | # use mock api 2 | VUE_APP_BASE_URL="https://dev.cloudslit.xyz/api/v1" 3 | -------------------------------------------------------------------------------- /portal/src/utils/event-bus.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | export const EventBus = new Vue() 4 | -------------------------------------------------------------------------------- /portal/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlowShield/flowshield/HEAD/portal/public/favicon.ico -------------------------------------------------------------------------------- /portal/public/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlowShield/flowshield/HEAD/portal/public/favicon.png -------------------------------------------------------------------------------- /portal/src/assets/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlowShield/flowshield/HEAD/portal/src/assets/bg.png -------------------------------------------------------------------------------- /provider/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | cert 3 | .vscode 4 | bin 5 | .DS_store 6 | .history 7 | vendor 8 | machine.lock -------------------------------------------------------------------------------- /deploy/provider/db/sqlite.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlowShield/flowshield/HEAD/deploy/provider/db/sqlite.db -------------------------------------------------------------------------------- /portal/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlowShield/flowshield/HEAD/portal/src/assets/logo.png -------------------------------------------------------------------------------- /portal/src/assets/logo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlowShield/flowshield/HEAD/portal/src/assets/logo2.png -------------------------------------------------------------------------------- /portal/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /client/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | cert 3 | .vscode 4 | bin 5 | .DS_store 6 | .history 7 | vendor 8 | machine.lock 9 | config.toml -------------------------------------------------------------------------------- /client/configs/embed.go: -------------------------------------------------------------------------------- 1 | package configs 2 | 3 | import _ "embed" 4 | 5 | //go:embed config.toml 6 | var ConfigFileData []byte 7 | -------------------------------------------------------------------------------- /deploy/fullnode/docker-compose/db/sqlite.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlowShield/flowshield/HEAD/deploy/fullnode/docker-compose/db/sqlite.db -------------------------------------------------------------------------------- /client/pkg/pconst/pconst.go: -------------------------------------------------------------------------------- 1 | package pconst 2 | 3 | const ( 4 | OperatorClient = "Client" 5 | OperatorRelay = "Relay" 6 | OperatorServer = "Server" 7 | ) 8 | -------------------------------------------------------------------------------- /portal/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM fholzer/nginx-brotli 2 | 3 | COPY ./dist /usr/share/nginx/html 4 | 5 | COPY ./nginx.conf /etc/nginx/nginx.conf 6 | 7 | EXPOSE 9080 8 | -------------------------------------------------------------------------------- /provider/pkg/pconst/pconst.go: -------------------------------------------------------------------------------- 1 | package pconst 2 | 3 | const ( 4 | OperatorClient = "Client" 5 | OperatorRelay = "Relay" 6 | OperatorServer = "Server" 7 | ) 8 | -------------------------------------------------------------------------------- /verifier/app/v1/node/model/mparam/health.go: -------------------------------------------------------------------------------- 1 | package mparam 2 | 3 | type ProviderHealth struct { 4 | OrderID []string `json:"order_id" form:"order_id"` 5 | } 6 | -------------------------------------------------------------------------------- /fullnode/app/v1/user/model/mparam/user.go: -------------------------------------------------------------------------------- 1 | package mparam 2 | 3 | type BindWallet struct { 4 | Wallet string `json:"wallet" form:"wallet" binding:"required"` 5 | } 6 | -------------------------------------------------------------------------------- /contract/artifacts/contracts/CloudSlitDao.sol/CloudSlitDao.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../build-info/e03a705d3196490f8f037dbd0328df0e.json" 4 | } 5 | -------------------------------------------------------------------------------- /portal/src/api/user.js: -------------------------------------------------------------------------------- 1 | import request from '@/utils/request' 2 | 3 | export function fetchUser() { 4 | return request({ 5 | url: '/user/detail', 6 | method: 'get' 7 | }) 8 | } 9 | -------------------------------------------------------------------------------- /ca/conf.yml: -------------------------------------------------------------------------------- 1 | singleca: 2 | config-path: "./config.json" 3 | 4 | http: 5 | ca-listen: 0.0.0.0:8081 6 | 7 | log: 8 | log-proxy: 9 | host: "" 10 | port: 6379 11 | key: ca_log -------------------------------------------------------------------------------- /portal/src/api/index.js: -------------------------------------------------------------------------------- 1 | export * from './clients' 2 | export * from './servers' 3 | export * from './resource' 4 | export * from './relay' 5 | export * from './user' 6 | export * from './nodes' 7 | -------------------------------------------------------------------------------- /contract/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../../../build-info/2cca8ef7664ce8b047a55650f0f82c39.json" 4 | } 5 | -------------------------------------------------------------------------------- /contract/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../../../../build-info/2cca8ef7664ce8b047a55650f0f82c39.json" 4 | } 5 | -------------------------------------------------------------------------------- /contract/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../../../../build-info/2cca8ef7664ce8b047a55650f0f82c39.json" 4 | } 5 | -------------------------------------------------------------------------------- /fullnode/.gitignore: -------------------------------------------------------------------------------- 1 | # ---> Go 2 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 3 | .idea 4 | .DS_Store 5 | .vscode 6 | .docs 7 | 8 | fullnode 9 | logs 10 | release_bin 11 | bin 12 | -------------------------------------------------------------------------------- /ca/util/cert.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import "crypto/x509" 4 | 5 | func GetSanURI(cert *x509.Certificate) string { 6 | if len(cert.URIs) > 0 { 7 | return cert.URIs[0].String() 8 | } 9 | return "" 10 | } 11 | -------------------------------------------------------------------------------- /fullnode/examples/helm/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | description: FlowShield 3 | kubeVersion: '>=1.16.0-0' 4 | maintainers: 5 | - email: taosheng205054@gmail.com 6 | name: TS 7 | name: FlowShield 8 | version: 0.0.1 9 | -------------------------------------------------------------------------------- /provider/pkg/util/func.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | func InArray(in string, array []string) bool { 4 | for k := range array { 5 | if in == array[k] { 6 | return true 7 | } 8 | } 9 | return false 10 | } 11 | -------------------------------------------------------------------------------- /contract/artifacts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../../../../build-info/f2001471b28c74cc8927dc6a797533a1.json" 4 | } 5 | -------------------------------------------------------------------------------- /contract/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../../../build-info/f2001471b28c74cc8927dc6a797533a1.json" 4 | } 5 | -------------------------------------------------------------------------------- /contract/artifacts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../../../build-info/f2001471b28c74cc8927dc6a797533a1.json" 4 | } 5 | -------------------------------------------------------------------------------- /portal/tests/e2e/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | 'cypress' 4 | ], 5 | env: { 6 | mocha: true, 7 | 'cypress/globals': true 8 | }, 9 | rules: { 10 | strict: 'off' 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /verifier/verify/options.go: -------------------------------------------------------------------------------- 1 | package verify 2 | 3 | import "time" 4 | 5 | type Options struct { 6 | Often time.Duration 7 | } 8 | 9 | func (o *Options) init() { 10 | if o.Often < 10 { 11 | o.Often = 10 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /client/pkg/util/structure/structure.go: -------------------------------------------------------------------------------- 1 | package structure 2 | 3 | import ( 4 | "github.com/jinzhu/copier" 5 | ) 6 | 7 | // Copy structure mapping 8 | func Copy(s, ts interface{}) error { 9 | return copier.Copy(ts, s) 10 | } 11 | -------------------------------------------------------------------------------- /contract/artifacts/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol/OwnableUpgradeable.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../../../build-info/f2001471b28c74cc8927dc6a797533a1.json" 4 | } 5 | -------------------------------------------------------------------------------- /contract/artifacts/@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol/PausableUpgradeable.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../../../build-info/4c809e0b4d7bbe7b2f57732f884ce614.json" 4 | } 5 | -------------------------------------------------------------------------------- /contract/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol/ERC20Upgradeable.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../../../../build-info/f2001471b28c74cc8927dc6a797533a1.json" 4 | } 5 | -------------------------------------------------------------------------------- /contract/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../../../../../build-info/2cca8ef7664ce8b047a55650f0f82c39.json" 4 | } 5 | -------------------------------------------------------------------------------- /provider/pkg/util/structure/structure.go: -------------------------------------------------------------------------------- 1 | package structure 2 | 3 | import ( 4 | "github.com/jinzhu/copier" 5 | ) 6 | 7 | // Copy structure mapping 8 | func Copy(s, ts interface{}) error { 9 | return copier.Copy(ts, s) 10 | } 11 | -------------------------------------------------------------------------------- /contract/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol/IERC20Upgradeable.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../../../../build-info/f2001471b28c74cc8927dc6a797533a1.json" 4 | } 5 | -------------------------------------------------------------------------------- /ca/ca/singleca/err.go: -------------------------------------------------------------------------------- 1 | package singleca 2 | 3 | import "github.com/pkg/errors" 4 | 5 | var errBadSigner = errors.New("signer not initialized") 6 | var errNoCertDBConfigured = errors.New("cert database not configured (missing -database-config)") 7 | -------------------------------------------------------------------------------- /portal/src/api/nodes.js: -------------------------------------------------------------------------------- 1 | import request from '@/utils/request' 2 | 3 | // 获取node列表 4 | export function fetchZeroAccessNodes(params = {}) { 5 | return request({ 6 | url: '/node', 7 | method: 'get', 8 | params 9 | }) 10 | } 11 | -------------------------------------------------------------------------------- /fullnode/examples/helm/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | app: zaportal 6 | name: zaportal 7 | spec: 8 | ports: 9 | - port: 80 10 | targetPort: 80 11 | selector: 12 | app: zaportal 13 | -------------------------------------------------------------------------------- /portal/tests/e2e/specs/test.js: -------------------------------------------------------------------------------- 1 | // https://docs.cypress.io/api/table-of-contents 2 | 3 | describe('My First Test', () => { 4 | it('Visits the app root url', () => { 5 | cy.visit('/') 6 | cy.contains('h1', 'Welcome to Your Vue.js App') 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /contract/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol/ERC20BurnableUpgradeable.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../../../../../build-info/f2001471b28c74cc8927dc6a797533a1.json" 4 | } 5 | -------------------------------------------------------------------------------- /fullnode/test/base64_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "encoding/base64" 5 | "fmt" 6 | "testing" 7 | ) 8 | 9 | func TestBase64Encode(t *testing.T) { 10 | data := base64.StdEncoding.EncodeToString([]byte("asdasd")) 11 | fmt.Println(data) 12 | } 13 | -------------------------------------------------------------------------------- /contract/artifacts/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol/IERC20MetadataUpgradeable.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../../../../../build-info/f2001471b28c74cc8927dc6a797533a1.json" 4 | } 5 | -------------------------------------------------------------------------------- /fullnode/pkg/curl/curl.go: -------------------------------------------------------------------------------- 1 | package curl 2 | 3 | import ( 4 | "os" 5 | "time" 6 | 7 | "github.com/go-resty/resty/v2" 8 | ) 9 | 10 | var Client = resty.New() 11 | 12 | func init() { 13 | if os.Getenv("IDG_RUNTIME") != "production" { 14 | Client.SetDebug(true) 15 | } 16 | Client.SetTimeout(time.Second * 5) 17 | } 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ---> Go 2 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 3 | .idea 4 | 5 | fullnode/.idea 6 | fullnode/.DS_Store 7 | fullnode/.vscode 8 | fullnode/.docs 9 | 10 | fullnode/fullnode 11 | fullnode/logs 12 | fullnode/release_bin 13 | fullnode/bin 14 | 15 | verifier/verifier 16 | verifier/logs 17 | -------------------------------------------------------------------------------- /fullnode/app/v1/controlplane/model/mparam/machine.go: -------------------------------------------------------------------------------- 1 | package mparam 2 | 3 | type MachineOauth struct { 4 | Machine string `json:"machine"` 5 | } 6 | 7 | type MachineLongPoll struct { 8 | Category string `json:"category" form:"category" binding:"required"` 9 | Timeout int `json:"timeout" form:"timeout" binding:"required"` 10 | } 11 | -------------------------------------------------------------------------------- /fullnode/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.17.8-alpine AS builder 2 | 3 | WORKDIR /build 4 | 5 | COPY . . 6 | 7 | RUN CGO_ENABLED=0 go build -o flowshield . 8 | 9 | 10 | FROM alpine AS final 11 | WORKDIR /app 12 | COPY --from=builder /build/flowshield /app/ 13 | COPY --from=builder /build/config.yaml /app/ 14 | 15 | ENTRYPOINT ["/app/flowshield"] 16 | -------------------------------------------------------------------------------- /contract/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "Context", 4 | "sourceName": "@openzeppelin/contracts/utils/Context.sol", 5 | "abi": [], 6 | "bytecode": "0x", 7 | "deployedBytecode": "0x", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /fullnode/app/v1/node/model/mapi/node.go: -------------------------------------------------------------------------------- 1 | package mapi 2 | 3 | import ( 4 | "github.com/flowshield/flowshield/fullnode/app/base/mapi" 5 | "github.com/flowshield/flowshield/fullnode/app/v1/node/model/mmysql" 6 | ) 7 | 8 | type NodeList struct { 9 | List []mmysql.Node `json:"list"` 10 | Paginate mapi.AdminPaginate `json:"paginate"` 11 | } 12 | -------------------------------------------------------------------------------- /verifier/route/health/health.go: -------------------------------------------------------------------------------- 1 | package health 2 | 3 | import ( 4 | v1 "github.com/flowshield/flowshield/verifier/app/v1/node/controller" 5 | "github.com/gin-gonic/gin" 6 | ) 7 | 8 | func APIHealth(parentRoute gin.IRouter) { 9 | node := parentRoute.Group("verifier/provider/health") 10 | { 11 | node.POST("", v1.ProviderHealth) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /fullnode/app/v1/access/model/mapi/resource.go: -------------------------------------------------------------------------------- 1 | package mapi 2 | 3 | import ( 4 | "github.com/flowshield/flowshield/fullnode/app/base/mapi" 5 | "github.com/flowshield/flowshield/fullnode/app/v1/access/model/mmysql" 6 | ) 7 | 8 | type ResourceList struct { 9 | List []mmysql.Resource `json:"list"` 10 | Paginate mapi.AdminPaginate `json:"paginate"` 11 | } 12 | -------------------------------------------------------------------------------- /ca/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | .env.rootca 3 | 4 | # Binaries for programs and plugins 5 | *.exe 6 | *.exe~ 7 | *.dll 8 | *.so 9 | *.dylib 10 | 11 | # Test binary, build with `go test -c` 12 | *.test 13 | 14 | # Output of the go coverage tool, specifically when used with LiteIDE 15 | *.out 16 | 17 | *.DS_Store 18 | 19 | # IDE configs 20 | .idea 21 | .vscode 22 | bin 23 | -------------------------------------------------------------------------------- /fullnode/pkg/logger/config.go: -------------------------------------------------------------------------------- 1 | package logger 2 | 3 | func LogLevel() string { 4 | return "debug" 5 | } 6 | 7 | func LogFile() string { 8 | return LogPath() + LogName() 9 | } 10 | 11 | func SendLogToFile() bool { 12 | return true 13 | } 14 | 15 | func LogPath() string { 16 | return "logs/" 17 | } 18 | 19 | func LogName() string { 20 | return "fullnode.log" 21 | } 22 | -------------------------------------------------------------------------------- /verifier/pkg/logger/config.go: -------------------------------------------------------------------------------- 1 | package logger 2 | 3 | func LogLevel() string { 4 | return "debug" 5 | } 6 | 7 | func LogFile() string { 8 | return LogPath() + LogName() 9 | } 10 | 11 | func SendLogToFile() bool { 12 | return true 13 | } 14 | 15 | func LogPath() string { 16 | return "logs/" 17 | } 18 | 19 | func LogName() string { 20 | return "verifier.log" 21 | } 22 | -------------------------------------------------------------------------------- /portal/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "esnext", 5 | "baseUrl": "./", 6 | "moduleResolution": "node", 7 | "paths": { 8 | "@/*": [ 9 | "src/*" 10 | ] 11 | }, 12 | "lib": [ 13 | "esnext", 14 | "dom", 15 | "dom.iterable", 16 | "scripthost" 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /fullnode/route/node/node.go: -------------------------------------------------------------------------------- 1 | package node 2 | 3 | import ( 4 | v1 "github.com/flowshield/flowshield/fullnode/app/v1/node/controller" 5 | "github.com/flowshield/flowshield/fullnode/pkg/middle" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | func APINode(parentRoute gin.IRouter) { 10 | node := parentRoute.Group("node", middle.Oauth2()) 11 | { 12 | node.GET("", v1.ListNode) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /fullnode/app/base/mapi/base.go: -------------------------------------------------------------------------------- 1 | package mapi 2 | 3 | type Paginate struct { 4 | Total int `json:"total"` 5 | TotalPage int `json:"total_page"` 6 | CurrentPage int `json:"current_page"` 7 | PrePage int `json:"pre_page"` 8 | } 9 | 10 | type AdminPaginate struct { 11 | Total int64 `json:"total"` 12 | Current int `json:"current"` 13 | PageSize int `json:"pageSize"` 14 | } 15 | -------------------------------------------------------------------------------- /verifier/app/base/mapi/base.go: -------------------------------------------------------------------------------- 1 | package mapi 2 | 3 | type Paginate struct { 4 | Total int `json:"total"` 5 | TotalPage int `json:"total_page"` 6 | CurrentPage int `json:"current_page"` 7 | PrePage int `json:"pre_page"` 8 | } 9 | 10 | type AdminPaginate struct { 11 | Total int64 `json:"total"` 12 | Current int `json:"current"` 13 | PageSize int `json:"pageSize"` 14 | } 15 | -------------------------------------------------------------------------------- /ca/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.17.8-alpine AS builder 2 | 3 | ENV GO111MODULE=on 4 | WORKDIR /build 5 | 6 | COPY . . 7 | RUN CGO_ENABLED=0 go build -o ca . 8 | 9 | FROM ubuntu:20.04 10 | 11 | WORKDIR /root 12 | 13 | COPY --from=builder /build/ca . 14 | COPY --from=builder /build/conf.yml . 15 | COPY --from=builder /build/config.json . 16 | RUN chmod +x ca 17 | 18 | # TLS service 19 | CMD ["./ca", "tls"] -------------------------------------------------------------------------------- /fullnode/pkg/middle/cors.go: -------------------------------------------------------------------------------- 1 | package middle 2 | 3 | import ( 4 | "github.com/gin-contrib/cors" 5 | "github.com/gin-gonic/gin" 6 | ) 7 | 8 | // 用于跨域头维护 9 | var corsHeader = []string{""} 10 | 11 | // CorsV2 跨域 12 | func CorsV2() gin.HandlerFunc { 13 | config := cors.DefaultConfig() 14 | config.AllowAllOrigins = true 15 | config.AddAllowHeaders(corsHeader...) 16 | return cors.New(config) 17 | } 18 | -------------------------------------------------------------------------------- /provider/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.17.8-alpine AS builder 2 | 3 | WORKDIR /build 4 | 5 | COPY . . 6 | RUN CGO_ENABLED=0 go build -o provider ./cmd 7 | 8 | FROM alpine AS final 9 | 10 | WORKDIR /root 11 | 12 | #RUN apt update && apt install -y curl 13 | 14 | COPY --from=builder /build/provider . 15 | COPY --from=builder /build/configs ./configs 16 | RUN chmod +x provider 17 | 18 | CMD ["./provider"] -------------------------------------------------------------------------------- /verifier/pkg/middle/cors.go: -------------------------------------------------------------------------------- 1 | package middle 2 | 3 | import ( 4 | "github.com/gin-contrib/cors" 5 | "github.com/gin-gonic/gin" 6 | ) 7 | 8 | // 用于跨域头维护 9 | var corsHeader = []string{""} 10 | 11 | // CorsV2 跨域 12 | func CorsV2() gin.HandlerFunc { 13 | config := cors.DefaultConfig() 14 | config.AllowAllOrigins = true 15 | config.AddAllowHeaders(corsHeader...) 16 | return cors.New(config) 17 | } 18 | -------------------------------------------------------------------------------- /verifier/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.17.8-alpine AS builder 2 | 3 | ENV GO111MODULE=on \ 4 | GOPROXY=https://goproxy.cn,direct 5 | 6 | WORKDIR /build 7 | 8 | COPY . . 9 | 10 | RUN CGO_ENABLED=0 go build -o verifier . 11 | 12 | 13 | FROM alpine AS final 14 | WORKDIR /app 15 | COPY --from=builder /build/verifier /app/ 16 | COPY --from=builder /build/config.yaml /app/ 17 | 18 | ENTRYPOINT ["/app/verifier"] 19 | -------------------------------------------------------------------------------- /ca/pkg/spiffe/idg_test.go: -------------------------------------------------------------------------------- 1 | package spiffe 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestParseIDGIdentity(t *testing.T) { 9 | cases := []string{ 10 | "spiffe://siteid/clusterid/appid", 11 | "spiffe://test/test/test", 12 | } 13 | for _, a := range cases { 14 | id, err := ParseIDGIdentity(a) 15 | if err != nil { 16 | t.Error(err) 17 | } 18 | fmt.Println(id.String()) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /portal/tests/unit/example.spec.js: -------------------------------------------------------------------------------- 1 | import { shallowMount } from '@vue/test-utils' 2 | import HelloWorld from '@/components/HelloWorld.vue' 3 | 4 | describe('HelloWorld.vue', () => { 5 | it('renders props.msg when passed', () => { 6 | const msg = 'new message' 7 | const wrapper = shallowMount(HelloWorld, { 8 | propsData: { msg } 9 | }) 10 | expect(wrapper.text()).toMatch(msg) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /ca/util/ip_addr.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "net" 5 | ) 6 | 7 | func GetLocalIPs() []string { 8 | addrs, err := net.InterfaceAddrs() 9 | if err != nil { 10 | return nil 11 | } 12 | m := []string{} 13 | for _, addr := range addrs { 14 | if ipnet, ok := addr.(*net.IPNet); ok { 15 | if ip4 := ipnet.IP.To4(); ip4 != nil { 16 | m = append(m, ip4.String()) 17 | } 18 | } 19 | } 20 | return m 21 | } 22 | -------------------------------------------------------------------------------- /portal/vue.config.js: -------------------------------------------------------------------------------- 1 | const { defineConfig } = require('@vue/cli-service') 2 | module.exports = defineConfig({ 3 | transpileDependencies: [ 4 | 'vuetify' 5 | ] 6 | }) 7 | const NodePolyfillPlugin = require("node-polyfill-webpack-plugin") 8 | module.exports = defineConfig({ 9 | transpileDependencies: true, 10 | configureWebpack: { 11 | plugins: [ 12 | new NodePolyfillPlugin() 13 | ] 14 | } 15 | 16 | }) -------------------------------------------------------------------------------- /client/internal/bll/bll.go: -------------------------------------------------------------------------------- 1 | package bll 2 | 3 | import ( 4 | "io" 5 | "net" 6 | ) 7 | 8 | func TransparentProxy(clientConn, serverConn net.Conn) { 9 | errChan := make(chan error, 2) 10 | copyConn := func(a, b net.Conn) { 11 | _, err := io.Copy(a, b) 12 | errChan <- err 13 | } 14 | go copyConn(clientConn, serverConn) 15 | go copyConn(serverConn, clientConn) 16 | select { 17 | case <-errChan: 18 | return 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /portal/src/plugins/vuetify.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuetify from 'vuetify/lib/framework' 3 | 4 | import colors from 'vuetify/lib/util/colors' 5 | 6 | Vue.use(Vuetify) 7 | 8 | export default new Vuetify({ 9 | theme: { 10 | dark: true, 11 | themes: { 12 | light: { 13 | primary: colors.purple 14 | }, 15 | dark: { 16 | primary: colors.purple 17 | } 18 | } 19 | } 20 | }) 21 | -------------------------------------------------------------------------------- /provider/internal/bll/bll.go: -------------------------------------------------------------------------------- 1 | package bll 2 | 3 | import ( 4 | "io" 5 | "net" 6 | ) 7 | 8 | func TransparentProxy(clientConn, serverConn net.Conn) { 9 | errChan := make(chan error, 2) 10 | copyConn := func(a, b net.Conn) { 11 | _, err := io.Copy(a, b) 12 | errChan <- err 13 | } 14 | go copyConn(clientConn, serverConn) 15 | go copyConn(serverConn, clientConn) 16 | select { 17 | case <-errChan: 18 | return 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /verifier/app/v1/node/service/health.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "github.com/flowshield/flowshield/verifier/app/v1/node/model/mparam" 5 | "github.com/flowshield/flowshield/verifier/verify" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | func ProviderHealth(c *gin.Context, param *mparam.ProviderHealth) (code int, data map[string]*verify.Record) { 10 | data = verify.VerObj.ProviderHealth(param.OrderID) 11 | return 12 | } 13 | -------------------------------------------------------------------------------- /contract/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | /tests/e2e/videos/ 6 | /tests/e2e/screenshots/ 7 | 8 | 9 | # local env files 10 | .env.local 11 | .env.*.local 12 | 13 | # Log files 14 | npm-debug.log* 15 | yarn-debug.log* 16 | yarn-error.log* 17 | pnpm-debug.log* 18 | 19 | # Editor directories and files 20 | .idea 21 | .vscode 22 | *.suo 23 | *.ntvs* 24 | *.njsproj 25 | *.sln 26 | *.sw? 27 | 28 | #env 29 | .env.development -------------------------------------------------------------------------------- /fullnode/test/key_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/ethereum/go-ethereum/crypto" 8 | ) 9 | 10 | func TestKey(t *testing.T) { 11 | privateKey, err := crypto.HexToECDSA("8828b5d74cdfa86ae17b11d2df83f627a888fab3b86a139c6d442ef7d0e9dd76") 12 | if err != nil { 13 | t.Fatal(err) 14 | } 15 | address := crypto.PubkeyToAddress(privateKey.PublicKey) 16 | fmt.Println(address.String()) 17 | } 18 | -------------------------------------------------------------------------------- /client/pkg/util/trace/trace.go: -------------------------------------------------------------------------------- 1 | package trace 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "sync/atomic" 7 | "time" 8 | ) 9 | 10 | var ( 11 | version string 12 | incrNum uint64 13 | pid = os.Getpid() 14 | ) 15 | 16 | // NewTraceID New trace id 17 | func NewTraceID() string { 18 | return fmt.Sprintf("trace-id-%d-%s-%d", 19 | os.Getpid(), 20 | time.Now().Format("2006.01.02.15.04.05.999"), 21 | atomic.AddUint64(&incrNum, 1)) 22 | } 23 | -------------------------------------------------------------------------------- /portal/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | /tests/e2e/videos/ 6 | /tests/e2e/screenshots/ 7 | 8 | 9 | # local env files 10 | .env.local 11 | .env.*.local 12 | 13 | # Log files 14 | npm-debug.log* 15 | yarn-debug.log* 16 | yarn-error.log* 17 | pnpm-debug.log* 18 | 19 | # Editor directories and files 20 | .idea 21 | .vscode 22 | *.suo 23 | *.ntvs* 24 | *.njsproj 25 | *.sln 26 | *.sw? 27 | 28 | #env 29 | .env.development 30 | -------------------------------------------------------------------------------- /provider/pkg/util/trace/trace.go: -------------------------------------------------------------------------------- 1 | package trace 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "sync/atomic" 7 | "time" 8 | ) 9 | 10 | var ( 11 | version string 12 | incrNum uint64 13 | pid = os.Getpid() 14 | ) 15 | 16 | // NewTraceID New trace id 17 | func NewTraceID() string { 18 | return fmt.Sprintf("trace-id-%d-%s-%d", 19 | os.Getpid(), 20 | time.Now().Format("2006.01.02.15.04.05.999"), 21 | atomic.AddUint64(&incrNum, 1)) 22 | } 23 | -------------------------------------------------------------------------------- /client/pkg/errors/errors.go: -------------------------------------------------------------------------------- 1 | package errors 2 | 3 | import ( 4 | "github.com/pkg/errors" 5 | ) 6 | 7 | // alias 8 | var ( 9 | New = errors.New 10 | Wrap = errors.Wrap 11 | Wrapf = errors.Wrapf 12 | WithStack = errors.WithStack 13 | WithMessage = errors.WithMessage 14 | WithMessagef = errors.WithMessagef 15 | ) 16 | 17 | var NewWithStack = func(msg string) error { 18 | return errors.WithStack(errors.New(msg)) 19 | } 20 | -------------------------------------------------------------------------------- /provider/pkg/errors/errors.go: -------------------------------------------------------------------------------- 1 | package errors 2 | 3 | import ( 4 | "github.com/pkg/errors" 5 | ) 6 | 7 | // alias 8 | var ( 9 | New = errors.New 10 | Wrap = errors.Wrap 11 | Wrapf = errors.Wrapf 12 | WithStack = errors.WithStack 13 | WithMessage = errors.WithMessage 14 | WithMessagef = errors.WithMessagef 15 | ) 16 | 17 | var NewWithStack = func(msg string) error { 18 | return errors.WithStack(errors.New(msg)) 19 | } 20 | -------------------------------------------------------------------------------- /client/pkg/util/func.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import "os" 4 | 5 | func InArray(in string, array []string) bool { 6 | for k := range array { 7 | if in == array[k] { 8 | return true 9 | } 10 | } 11 | return false 12 | } 13 | 14 | func PathExists(path string) (bool, error) { 15 | _, err := os.Stat(path) 16 | if err == nil { 17 | return true, nil 18 | } 19 | if os.IsNotExist(err) { 20 | return false, nil 21 | } 22 | return false, err 23 | } 24 | -------------------------------------------------------------------------------- /fullnode/pkg/redis/redis.go: -------------------------------------------------------------------------------- 1 | package redis 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/go-redis/redis/v8" 7 | "github.com/flowshield/flowshield/fullnode/pkg/confer" 8 | ) 9 | 10 | var Client *redis.Client 11 | 12 | func Init(cfg *confer.Redis) (err error) { 13 | Client = redis.NewClient(&redis.Options{ 14 | Addr: cfg.Addr, 15 | }) 16 | if err = Client.Ping(context.Background()).Err(); err != nil { 17 | return 18 | } 19 | return 20 | } 21 | -------------------------------------------------------------------------------- /fullnode/route/controlplane/controlplane.go: -------------------------------------------------------------------------------- 1 | package controlplane 2 | 3 | import ( 4 | "github.com/gin-gonic/gin" 5 | v1 "github.com/flowshield/flowshield/fullnode/app/v1/controlplane/controller" 6 | ) 7 | 8 | func APIControlPlane(parentRoute gin.IRouter) { 9 | controlplane := parentRoute.Group("controlplane") 10 | { 11 | controlplane.GET("/machine/:machine_id", v1.LoginUrl) 12 | controlplane.GET("/machine/auth/poll", v1.MachineLongPoll) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /fullnode/app/base/controller/home.go: -------------------------------------------------------------------------------- 1 | package controller 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "time" 7 | 8 | "github.com/flowshield/flowshield/fullnode/pkg/confer" 9 | "github.com/gin-gonic/gin" 10 | ) 11 | 12 | func Welcome(c *gin.Context) { 13 | now := time.Now().String() 14 | sysName := confer.ConfigAppGetString("sysname", "default service") 15 | content := fmt.Sprintf("Welcome to %s@%s", sysName, now) 16 | c.String(http.StatusOK, content) 17 | } 18 | -------------------------------------------------------------------------------- /verifier/app/base/controller/home.go: -------------------------------------------------------------------------------- 1 | package controller 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "time" 7 | 8 | "github.com/flowshield/flowshield/verifier/pkg/confer" 9 | "github.com/gin-gonic/gin" 10 | ) 11 | 12 | func Welcome(c *gin.Context) { 13 | now := time.Now().String() 14 | sysName := confer.ConfigAppGetString("sysname", "default service") 15 | content := fmt.Sprintf("Welcome to %s@%s", sysName, now) 16 | c.String(http.StatusOK, content) 17 | } 18 | -------------------------------------------------------------------------------- /fullnode/app/v1/node/model/mparam/node.go: -------------------------------------------------------------------------------- 1 | package mparam 2 | 3 | import ( 4 | "github.com/flowshield/flowshield/fullnode/app/base/mdb" 5 | ) 6 | 7 | type ListNode struct { 8 | mdb.Paginate 9 | PeerId string `json:"peer_id" form:"peer_id"` 10 | IP string `json:"ip" form:"ip"` 11 | Loc []string `json:"loc" form:"loc"` 12 | Colo string `json:"colo" form:"colo"` 13 | Price int `json:"price" form:"price"` 14 | Type string `json:"type" form:"type"` 15 | } 16 | -------------------------------------------------------------------------------- /portal/src/utils/cache.js: -------------------------------------------------------------------------------- 1 | export function setCache(k, v) { 2 | const content = JSON.stringify({ 3 | type: typeof v, 4 | value: v 5 | }) 6 | window.localStorage.setItem(k, content) 7 | } 8 | 9 | export function getCache(k, defaultValue) { 10 | const content = window.localStorage.getItem(k) 11 | try { 12 | const obj = JSON.parse(content) 13 | return obj.value 14 | } catch (e) { 15 | return defaultValue === undefined ? content : defaultValue 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /fullnode/pkg/middle/session.go: -------------------------------------------------------------------------------- 1 | package middle 2 | 3 | import ( 4 | "github.com/flowshield/flowshield/fullnode/pkg/confer" 5 | "github.com/gin-gonic/contrib/sessions" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | func Session(name string, cfg *confer.Redis) gin.HandlerFunc { 10 | //return sessions.Sessions(name, sessions.NewCookieStore([]byte("secret"))) 11 | store, _ := sessions.NewRedisStore(10, "tcp", cfg.Addr, "", []byte("secret")) 12 | return sessions.Sessions(name, store) 13 | } 14 | -------------------------------------------------------------------------------- /verifier/config.yaml: -------------------------------------------------------------------------------- 1 | #APP ENV 2 | app: 3 | env: "release" # dev,release 4 | sysname: "FlowShield" 5 | port: 8088 6 | 7 | #Mysql 8 | mysql: 9 | dbname: "zta" 10 | prefix: "zta_" 11 | pool: 12 | pool-min-cap: 10 13 | pool-ex-cap: 5 14 | pool-max-cap: 40 15 | pool-idle-timeout: 3600 16 | pool-wait-count: 1000 17 | pool-wai-timeout: 30 18 | write: 19 | host: "CS_MYSQL_HOST" 20 | port: 23306 21 | user: "CS_MYSQL_USER" 22 | password: "CS_MYSQL_PASSWORD" 23 | -------------------------------------------------------------------------------- /fullnode/pkg/oauth2/option.go: -------------------------------------------------------------------------------- 1 | package oauth2 2 | 3 | import ( 4 | "github.com/gin-gonic/contrib/sessions" 5 | "github.com/gin-gonic/gin" 6 | "github.com/rs/xid" 7 | "golang.org/x/oauth2" 8 | ) 9 | 10 | func GetOauth2RedirectURL(c *gin.Context, config *oauth2.Config) (redirectURL string, err error) { 11 | state := xid.New().String() 12 | redirectURL = config.AuthCodeURL(state, oauth2.ApprovalForce) 13 | session := sessions.Default(c) 14 | session.Set("state", state) 15 | err = session.Save() 16 | return 17 | } 18 | -------------------------------------------------------------------------------- /contract/scripts/upgrade.js: -------------------------------------------------------------------------------- 1 | async function main() { 2 | const proxyAddress = '0x3A35207918FEE0F59a32a1a36B58A758B4F222de'; 3 | 4 | const CloudSlitDaoV2 = await ethers.getContractFactory("CloudSlitDaoV2"); 5 | console.log("Preparing upgrade..."); 6 | 7 | await upgrades.upgradeProxy(proxyAddress, CloudSlitDaoV2); 8 | console.log("Upgraded Successfully"); 9 | } 10 | 11 | main() 12 | .then(() => process.exit(0)) 13 | .catch(error => { 14 | console.error(error); 15 | process.exit(1); 16 | }); -------------------------------------------------------------------------------- /verifier/pkg/confer/config_code.go: -------------------------------------------------------------------------------- 1 | package confer 2 | 3 | import ( 4 | "strconv" 5 | "sync" 6 | ) 7 | 8 | var ( 9 | codeConfig sync.Map 10 | ) 11 | 12 | type ConfigCodeList struct { 13 | Codes map[string]string 14 | } 15 | 16 | func ConfigCodeInit() { 17 | for k, v := range globalConfig.Code { 18 | codeConfig.Store(k, v) 19 | } 20 | } 21 | 22 | func ConfigCodeGetMessage(code int) string { 23 | msg, exists := codeConfig.Load(strconv.Itoa(code)) 24 | if !exists { 25 | return "system error" 26 | } 27 | return msg.(string) 28 | } 29 | -------------------------------------------------------------------------------- /deploy/provider/sqlite_config.yaml: -------------------------------------------------------------------------------- 1 | server: 2 | addr: ":23306" # Network listening address, support MySQL protocol 3 | 4 | sqlite: 5 | filename: "db/sqlite.db" 6 | 7 | debug: # Control to open pprof 8 | enable: false 9 | port: 17878 10 | 11 | # p2p config 12 | p2p: 13 | enable: false 14 | service_discovery_id: "p2p_sqlite_service" 15 | service_command_topic: "p2p_sqlite_service_topic" 16 | service_discover_mode: "advertise" # advertise or announce 17 | 18 | # Tenant list 19 | userlist: 20 | - user: root 21 | password: 123456 22 | -------------------------------------------------------------------------------- /fullnode/route/user/user.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | v1 "github.com/flowshield/flowshield/fullnode/app/v1/user/controller" 5 | "github.com/flowshield/flowshield/fullnode/pkg/middle" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | func APIUser(parentRoute gin.IRouter) { 10 | user := parentRoute.Group("user") 11 | { 12 | user.GET("/login", v1.Login) 13 | user.GET("/oauth2/callback", v1.Oauth2Callback) 14 | user.GET("/detail", middle.Oauth2(), v1.UserDetail) 15 | user.POST("/refresh", middle.Oauth2(), v1.UserRefresh) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /portal/src/assets/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /client/pkg/util/uuid/uuid.go: -------------------------------------------------------------------------------- 1 | package uuid 2 | 3 | import ( 4 | "github.com/google/uuid" 5 | ) 6 | 7 | // UUID Define alias 8 | type UUID = uuid.UUID 9 | 10 | // NewUUID Create uuid 11 | func NewUUID() (UUID, error) { 12 | return uuid.NewRandom() 13 | } 14 | 15 | // MustUUID Create uuid(Throw panic if something goes wrong) 16 | func MustUUID() UUID { 17 | v, err := NewUUID() 18 | if err != nil { 19 | panic(err) 20 | } 21 | return v 22 | } 23 | 24 | // MustString Create uuid 25 | func MustString() string { 26 | return MustUUID().String() 27 | } 28 | -------------------------------------------------------------------------------- /provider/pkg/util/uuid/uuid.go: -------------------------------------------------------------------------------- 1 | package uuid 2 | 3 | import ( 4 | "github.com/google/uuid" 5 | ) 6 | 7 | // UUID Define alias 8 | type UUID = uuid.UUID 9 | 10 | // NewUUID Create uuid 11 | func NewUUID() (UUID, error) { 12 | return uuid.NewRandom() 13 | } 14 | 15 | // MustUUID Create uuid(Throw panic if something goes wrong) 16 | func MustUUID() UUID { 17 | v, err := NewUUID() 18 | if err != nil { 19 | panic(err) 20 | } 21 | return v 22 | } 23 | 24 | // MustString Create uuid 25 | func MustString() string { 26 | return MustUUID().String() 27 | } 28 | -------------------------------------------------------------------------------- /contract/scripts/deploy.js: -------------------------------------------------------------------------------- 1 | async function main() { 2 | const CloudSlitDao = await ethers.getContractFactory("CloudSlitDao"); 3 | console.log("Deploying CloudSlitDao..."); 4 | 5 | const contract = await upgrades.deployProxy(CloudSlitDao, { initializer: 'initialize', kind: "transparent",}); 6 | await contract.deployed(); 7 | console.log("CloudSlitDao deployed to:", contract.address); 8 | } 9 | 10 | main() 11 | .then(() => process.exit(0)) 12 | .catch(error => { 13 | console.error(error); 14 | process.exit(1); 15 | }); -------------------------------------------------------------------------------- /client/internal/machine.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "github.com/flowshield/flowshield/client/internal/config" 5 | "github.com/flowshield/flowshield/client/pkg/util/uuid" 6 | ) 7 | 8 | // InitMachine initialize the machine id 9 | func InitMachine() error { 10 | machine := config.C.Machine 11 | mac, err := machine.Read() 12 | if err != nil { 13 | machine.SetMachineId(uuid.MustString()) 14 | err = machine.Write() 15 | if err != nil { 16 | return err 17 | } 18 | } else { 19 | machine.SetMachineId(mac.MachineId) 20 | machine.SetCookie(mac.Cookie) 21 | } 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /verifier/config_dev.yaml: -------------------------------------------------------------------------------- 1 | #APP ENV 2 | app: 3 | env: "release" # dev,release 4 | sysname: "FlowShield" 5 | port: 80 6 | 7 | #Mysql 8 | mysql: 9 | dbname: "zta" 10 | prefix: "zta_" 11 | pool: 12 | pool-min-cap: 10 13 | pool-ex-cap: 5 14 | pool-max-cap: 40 15 | pool-idle-timeout: 3600 16 | pool-wait-count: 1000 17 | pool-wai-timeout: 30 18 | write: 19 | host: "38.96.139.114:33306" 20 | port: 33306 21 | user: "root" 22 | password: "123456" 23 | # write: 24 | # host: "192.168.2.80:3306" 25 | # port: 3306 26 | # user: "root" 27 | # password: "123456" 28 | -------------------------------------------------------------------------------- /client/internal/contextx/contextx.go: -------------------------------------------------------------------------------- 1 | package contextx 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | type ( 8 | traceIDCtx struct{} 9 | ) 10 | 11 | // NewTraceID Create a context to trace the ID 12 | func NewTraceID(ctx context.Context, traceID string) context.Context { 13 | return context.WithValue(ctx, traceIDCtx{}, traceID) 14 | } 15 | 16 | // FromTraceID gets the trace id from the context 17 | func FromTraceID(ctx context.Context) (string, bool) { 18 | v := ctx.Value(traceIDCtx{}) 19 | if v != nil { 20 | if s, ok := v.(string); ok { 21 | return s, s != "" 22 | } 23 | } 24 | return "", false 25 | } 26 | -------------------------------------------------------------------------------- /client/internal/schema/schema.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | // StatusText Define status text 4 | type StatusText string 5 | 6 | func (t StatusText) String() string { 7 | return string(t) 8 | } 9 | 10 | // NextServer 11 | type NextServer struct { 12 | Host string 13 | Port string 14 | } 15 | 16 | // ControlCommonResult 17 | type ControlCommonResult struct { 18 | Code int `json:"code"` 19 | Message string `json:"message"` 20 | } 21 | 22 | // ControlPaginate 23 | type ControlPaginate struct { 24 | Total int `json:"total"` 25 | Current int `json:"current"` 26 | PageSize int `json:"pageSize"` 27 | } 28 | -------------------------------------------------------------------------------- /provider/internal/schema/schema.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | // StatusText Define status text 4 | type StatusText string 5 | 6 | func (t StatusText) String() string { 7 | return string(t) 8 | } 9 | 10 | // NextServer 11 | type NextServer struct { 12 | Host string 13 | Port string 14 | } 15 | 16 | // ControlCommonResult 17 | type ControlCommonResult struct { 18 | Code int `json:"code"` 19 | Message string `json:"message"` 20 | } 21 | 22 | // ControlPaginate 23 | type ControlPaginate struct { 24 | Total int `json:"total"` 25 | Current int `json:"current"` 26 | PageSize int `json:"pageSize"` 27 | } 28 | -------------------------------------------------------------------------------- /provider/internal/contextx/contextx.go: -------------------------------------------------------------------------------- 1 | package contextx 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | type ( 8 | traceIDCtx struct{} 9 | ) 10 | 11 | // NewTraceID Create a context to trace the ID 12 | func NewTraceID(ctx context.Context, traceID string) context.Context { 13 | return context.WithValue(ctx, traceIDCtx{}, traceID) 14 | } 15 | 16 | // FromTraceID gets the trace id from the context 17 | func FromTraceID(ctx context.Context) (string, bool) { 18 | v := ctx.Value(traceIDCtx{}) 19 | if v != nil { 20 | if s, ok := v.(string); ok { 21 | return s, s != "" 22 | } 23 | } 24 | return "", false 25 | } 26 | -------------------------------------------------------------------------------- /fullnode/examples/helm/templates/ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Ingress 3 | metadata: 4 | annotations: 5 | {{- range $key, $value := .Values.ingress.annotations }} 6 | {{ $key }}: {{ tpl $value $ | quote }} 7 | {{- end }} 8 | labels: 9 | app: zaportal 10 | name: zaportal 11 | spec: 12 | rules: 13 | - host: {{ .Values.ingress.host }} 14 | http: 15 | paths: 16 | - path: / 17 | backend: 18 | serviceName: zaportal 19 | servicePort: 80 20 | tls: 21 | - hosts: 22 | - {{ .Values.ingress.host }} 23 | secretName: zaportal-tls 24 | -------------------------------------------------------------------------------- /ca/util/cache.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "crypto/sha1" 5 | "encoding/hex" 6 | "math" 7 | "strconv" 8 | "time" 9 | 10 | "github.com/flowshield/flowshield/ca/pkg/memorycacher" 11 | "github.com/gin-gonic/gin" 12 | ) 13 | 14 | var MapCache *memorycacher.Cache 15 | 16 | func init() { 17 | MapCache = memorycacher.New(2*time.Minute, 10*time.Minute, math.MaxInt64) 18 | } 19 | 20 | func GinRequestHash(g *gin.Context) string { 21 | url := g.Request.URL.String() 22 | body := g.Request.ContentLength 23 | 24 | sha := sha1.Sum([]byte(url + strconv.FormatInt(body, 10))) 25 | 26 | return hex.EncodeToString(sha[:]) 27 | } 28 | -------------------------------------------------------------------------------- /portal/docs/docker.md: -------------------------------------------------------------------------------- 1 | # Docker 2 | 3 | ## Docker build 4 | 5 | ```bash 6 | docker build -t rovast/za-portal . 7 | ``` 8 | 9 | ## Run 10 | 11 | ```bash 12 | docker run --name zaportal -p 9080:9080 -d rovast/za-portal:latest 13 | ``` 14 | 15 | You can visit http://127.0.0.1:9080 16 | 17 | ## Settings 18 | 19 | ### Expose ports 20 | 21 | - 9080: frontend port 22 | - 80: backend port 23 | 24 | > Frontend will request `/api`, and will proxy by nginx, you can config it in `nginx.conf` 25 | 26 | ### Nginx configuration 27 | 28 | - conf file: `/etc/nginx/nginx.conf` 29 | - frontend dist path(www root): `/usr/share/nginx/html` 30 | 31 | -------------------------------------------------------------------------------- /ca/core/state.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/flowshield/flowshield/ca/core/config" 7 | "github.com/flowshield/flowshield/ca/pkg/logger" 8 | "gorm.io/gorm" 9 | ) 10 | 11 | // Config ... 12 | type Config struct { 13 | config.IConfig 14 | } 15 | 16 | // Is ... 17 | var Is *I 18 | 19 | // Elector ... 20 | type Elector interface { 21 | IsLeader() bool 22 | } 23 | 24 | // Logger ... 25 | type Logger struct { 26 | *logger.Logger 27 | } 28 | 29 | // I ... 30 | type I struct { 31 | Ctx context.Context 32 | Config *Config 33 | Logger *Logger 34 | Db *gorm.DB 35 | Elector Elector 36 | } 37 | -------------------------------------------------------------------------------- /fullnode/test/json_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "testing" 7 | 8 | "github.com/tidwall/gjson" 9 | ) 10 | 11 | type Person struct { 12 | FirstName string `json:"first"` 13 | LastName string `json:"last"` 14 | } 15 | 16 | func TestJson(t *testing.T) { 17 | const jsonStr = `{"name":{"first":"Janet","last":"Prichard"},"age":47}` 18 | value := gjson.Get(jsonStr, "name") 19 | var person Person 20 | json.Unmarshal([]byte(value.String()), &person) 21 | fmt.Println(person) 22 | } 23 | 24 | func TestString(t *testing.T) { 25 | var str = "abcdefg" 26 | fmt.Println(str[len(str)-2:]) 27 | } 28 | -------------------------------------------------------------------------------- /fullnode/app/base/controller/controller.go: -------------------------------------------------------------------------------- 1 | package controller 2 | 3 | import ( 4 | "github.com/gin-gonic/gin" 5 | "github.com/flowshield/flowshield/fullnode/pconst" 6 | "github.com/flowshield/flowshield/fullnode/pkg/logger" 7 | ) 8 | 9 | type Res struct { 10 | Code int `json:"code"` 11 | Data struct{} `json:"data"` 12 | Msg string `json:"message"` 13 | } 14 | 15 | func BindParams(c *gin.Context, params interface{}) (b bool, code int) { 16 | err := c.ShouldBind(params) 17 | if err != nil { 18 | logger.Warnf(c, "params error: %v", err) 19 | code = pconst.CODE_COMMON_PARAMS_INCOMPLETE 20 | return 21 | } 22 | b = true 23 | return 24 | } 25 | -------------------------------------------------------------------------------- /verifier/app/base/controller/controller.go: -------------------------------------------------------------------------------- 1 | package controller 2 | 3 | import ( 4 | "github.com/flowshield/flowshield/verifier/pconst" 5 | "github.com/flowshield/flowshield/verifier/pkg/logger" 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | type Res struct { 10 | Code int `json:"code"` 11 | Data struct{} `json:"data"` 12 | Msg string `json:"message"` 13 | } 14 | 15 | func BindParams(c *gin.Context, params interface{}) (b bool, code int) { 16 | err := c.ShouldBind(params) 17 | if err != nil { 18 | logger.Warnf(c, "params error: %v", err) 19 | code = pconst.CODE_COMMON_PARAMS_INCOMPLETE 20 | return 21 | } 22 | b = true 23 | return 24 | } 25 | -------------------------------------------------------------------------------- /portal/src/utils/request.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | // import qs from 'qs' 3 | import { requestInterceptors } from './request-helper' 4 | 5 | // create an axios instance 6 | const service = axios.create({ 7 | baseURL: process.env.VUE_APP_BASE_URL, 8 | // withCredentials: false, // send cookies when cross-domain requests 9 | // transformRequest: [function(data, headers) { 10 | // return qs.stringify(data) 11 | // }], 12 | // paramsSerializer: function(params) { 13 | // return qs.stringify(params, { indices: false }) 14 | // }, 15 | timeout: 50000 // request timeout 16 | }) 17 | 18 | requestInterceptors(service) 19 | 20 | export default service 21 | -------------------------------------------------------------------------------- /fullnode/app/v1/access/model/mmysql/resource.go: -------------------------------------------------------------------------------- 1 | package mmysql 2 | 3 | type Resource struct { 4 | ID uint `gorm:"primarykey"` 5 | CreatedAt int64 `gorm:"autoCreateTime"` 6 | UpdatedAt int64 `gorm:"autoUpdateTime"` 7 | Name string `json:"name"` 8 | UUID string `json:"uuid" gorm:"column:uuid"` 9 | UserUUID string `json:"user_uuid" gorm:"user_uuid"` 10 | Type string `json:"type"` 11 | Host string `json:"host"` // api.github.com 12 | Port string `json:"port" gorm:"column:port"` // 80-443;3306;6379 13 | Cid string `json:"cid"` 14 | } 15 | 16 | func (Resource) TableName() string { 17 | return "zta_resource" 18 | } 19 | -------------------------------------------------------------------------------- /verifier/server/http.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | 7 | "github.com/flowshield/flowshield/verifier/pkg/confer" 8 | "github.com/flowshield/flowshield/verifier/pkg/gin" 9 | "github.com/flowshield/flowshield/verifier/pkg/middle" 10 | "github.com/flowshield/flowshield/verifier/route" 11 | ) 12 | 13 | func RunHTTP() { 14 | engine := gin.NewGin() 15 | // 跨域中间件 16 | engine.Use(middle.CorsV2()) 17 | route.Home(engine) 18 | route.Api(engine) 19 | route.NotFound(engine) 20 | httpPort := confer.ConfigAppGetInt("port", 80) 21 | portStr := ":" + strconv.Itoa(httpPort) 22 | fmt.Println("start", httpPort) 23 | gin.ListenHTTP(portStr, engine, 10) 24 | } 25 | -------------------------------------------------------------------------------- /ca/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all build clean 2 | 3 | PROG=bin/ca 4 | SRCS=. 5 | 6 | # git commit hash 7 | COMMIT_HASH=$(shell git rev-parse --short HEAD || echo "GitNotFound") 8 | # Compilation date 9 | BUILD_DATE=$(shell date '+%Y-%m-%d %H:%M:%S') 10 | # Compilation conditions 11 | CFLAGS = -ldflags "-s -w -X \"main.BuildVersion=${COMMIT_HASH}\" -X \"main.BuildDate=$(BUILD_DATE)\"" 12 | 13 | all: 14 | if [ ! -d "./bin/" ]; then \ 15 | mkdir bin; \ 16 | fi 17 | CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(CFLAGS) -o $(PROG) $(SRCS) 18 | 19 | build: 20 | go build -race -tags=jsoniter 21 | 22 | compose: 23 | sudo docker-compose up -d 24 | 25 | run: 26 | go run main.go 27 | 28 | clean: 29 | rm -rf ./bin -------------------------------------------------------------------------------- /fullnode/app/v1/user/model/mmysql/user.go: -------------------------------------------------------------------------------- 1 | package mmysql 2 | 3 | const ( 4 | UnBind = iota 5 | Bind 6 | ) 7 | 8 | type User struct { 9 | ID uint `gorm:"primarykey"` 10 | CreatedAt int64 `gorm:"autoCreateTime"` 11 | UpdatedAt int64 `gorm:"autoUpdateTime"` 12 | Email string `json:"email"` 13 | AvatarUrl string `json:"avatar_url"` 14 | UUID string `json:"uuid" gorm:"column:uuid"` 15 | //Wallet string `json:"wallet"` 16 | Status int `json:"status"` // 0 未绑定 1 已绑定 17 | Master bool `json:"master" gorm:"-"` // 判断当前用户是否Dao主 18 | Provider bool `json:"provider" gorm:"-"` // 判断当前用户是否Provider 19 | } 20 | 21 | func (User) TableName() string { 22 | return "zta_user" 23 | } 24 | -------------------------------------------------------------------------------- /portal/src/api/servers.js: -------------------------------------------------------------------------------- 1 | import request from '@/utils/request' 2 | 3 | export function fetchZeroAccessServers(params = {}) { 4 | return request({ 5 | url: '/access/server', 6 | method: 'get', 7 | params 8 | }) 9 | } 10 | 11 | export function postZeroAccessServer(data = {}) { 12 | return request({ 13 | url: '/access/server', 14 | method: 'post', 15 | data 16 | }) 17 | } 18 | 19 | export function putZeroAccessServer(data = {}) { 20 | return request({ 21 | url: '/access/server', 22 | method: 'put', 23 | data 24 | }) 25 | } 26 | 27 | export function deleteZeroAccessServer(id) { 28 | return request({ 29 | url: `/access/server/${id}`, 30 | method: 'delete' 31 | }) 32 | } 33 | -------------------------------------------------------------------------------- /contract/artifacts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "Initializable", 4 | "sourceName": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol", 5 | "abi": [ 6 | { 7 | "anonymous": false, 8 | "inputs": [ 9 | { 10 | "indexed": false, 11 | "internalType": "uint8", 12 | "name": "version", 13 | "type": "uint8" 14 | } 15 | ], 16 | "name": "Initialized", 17 | "type": "event" 18 | } 19 | ], 20 | "bytecode": "0x", 21 | "deployedBytecode": "0x", 22 | "linkReferences": {}, 23 | "deployedLinkReferences": {} 24 | } 25 | -------------------------------------------------------------------------------- /contract/artifacts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "ContextUpgradeable", 4 | "sourceName": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol", 5 | "abi": [ 6 | { 7 | "anonymous": false, 8 | "inputs": [ 9 | { 10 | "indexed": false, 11 | "internalType": "uint8", 12 | "name": "version", 13 | "type": "uint8" 14 | } 15 | ], 16 | "name": "Initialized", 17 | "type": "event" 18 | } 19 | ], 20 | "bytecode": "0x", 21 | "deployedBytecode": "0x", 22 | "linkReferences": {}, 23 | "deployedLinkReferences": {} 24 | } 25 | -------------------------------------------------------------------------------- /ca/pkg/logger/redis_hook/loggers.go: -------------------------------------------------------------------------------- 1 | package redis_hook 2 | 3 | import ( 4 | "go.uber.org/zap/zapcore" 5 | "strings" 6 | ) 7 | 8 | // zap need extra data for fields 9 | func CreateZapOriginLogMessage(entry *zapcore.Entry, data map[string]interface{}) map[string]interface{} { 10 | fields := make(map[string]interface{}, len(data)) 11 | if data != nil { 12 | for k, v := range data { 13 | fields[k] = v 14 | } 15 | } 16 | var level = strings.ToUpper(entry.Level.String()) 17 | if level == "ERROR" { 18 | level = "ERR" 19 | } 20 | if level == "WARN" { 21 | level = "WARNING" 22 | } 23 | if level == "FATAL" { 24 | level = "CRIT" 25 | } 26 | fields["level"] = level 27 | fields["message"] = entry.Message 28 | return fields 29 | } 30 | -------------------------------------------------------------------------------- /verifier/verify/record.go: -------------------------------------------------------------------------------- 1 | package verify 2 | 3 | import "sync/atomic" 4 | 5 | type Record struct { 6 | Total uint64 `json:"total"` 7 | Success uint64 `json:"success"` 8 | Fail uint64 `json:"fail"` 9 | } 10 | 11 | func (r *Record) AddSuccess(num uint64) { 12 | atomic.AddUint64(&r.Fail, num) 13 | atomic.AddUint64(&r.Total, num) 14 | } 15 | 16 | func (r *Record) AddFail(num uint64) { 17 | atomic.AddUint64(&r.Fail, num) 18 | atomic.AddUint64(&r.Total, num) 19 | } 20 | 21 | func (r *Record) GetFail() uint64 { 22 | return atomic.LoadUint64(&r.Fail) 23 | } 24 | 25 | func (r *Record) GetSuccess() uint64 { 26 | return atomic.LoadUint64(&r.Success) 27 | } 28 | 29 | func (r *Record) GetTotal() uint64 { 30 | return atomic.LoadUint64(&r.Total) 31 | } 32 | -------------------------------------------------------------------------------- /client/pkg/util/json/json.go: -------------------------------------------------------------------------------- 1 | package json 2 | 3 | import ( 4 | jsoniter "github.com/json-iterator/go" 5 | ) 6 | 7 | // Defining JSON operations 8 | var ( 9 | json = jsoniter.ConfigCompatibleWithStandardLibrary 10 | Marshal = json.Marshal 11 | Unmarshal = json.Unmarshal 12 | MarshalIndent = json.MarshalIndent 13 | NewDecoder = json.NewDecoder 14 | NewEncoder = json.NewEncoder 15 | ) 16 | 17 | func MarshalToString(v interface{}) string { 18 | s, err := jsoniter.MarshalToString(v) 19 | if err != nil { 20 | return "" 21 | } 22 | return s 23 | } 24 | 25 | func UnmarshalFromString(str string, v interface{}) error { 26 | err := jsoniter.UnmarshalFromString(str, v) 27 | if err != nil { 28 | return err 29 | } 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /fullnode/pkg/util/json/json.go: -------------------------------------------------------------------------------- 1 | package json 2 | 3 | import ( 4 | jsoniter "github.com/json-iterator/go" 5 | ) 6 | 7 | // Defining JSON operations 8 | var ( 9 | json = jsoniter.ConfigCompatibleWithStandardLibrary 10 | Marshal = json.Marshal 11 | Unmarshal = json.Unmarshal 12 | MarshalIndent = json.MarshalIndent 13 | NewDecoder = json.NewDecoder 14 | NewEncoder = json.NewEncoder 15 | ) 16 | 17 | func MarshalToString(v interface{}) string { 18 | s, err := jsoniter.MarshalToString(v) 19 | if err != nil { 20 | return "" 21 | } 22 | return s 23 | } 24 | 25 | func UnmarshalFromString(str string, v interface{}) error { 26 | err := jsoniter.UnmarshalFromString(str, v) 27 | if err != nil { 28 | return err 29 | } 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /provider/pkg/util/json/json.go: -------------------------------------------------------------------------------- 1 | package json 2 | 3 | import ( 4 | jsoniter "github.com/json-iterator/go" 5 | ) 6 | 7 | // Defining JSON operations 8 | var ( 9 | json = jsoniter.ConfigCompatibleWithStandardLibrary 10 | Marshal = json.Marshal 11 | Unmarshal = json.Unmarshal 12 | MarshalIndent = json.MarshalIndent 13 | NewDecoder = json.NewDecoder 14 | NewEncoder = json.NewEncoder 15 | ) 16 | 17 | func MarshalToString(v interface{}) string { 18 | s, err := jsoniter.MarshalToString(v) 19 | if err != nil { 20 | return "" 21 | } 22 | return s 23 | } 24 | 25 | func UnmarshalFromString(str string, v interface{}) error { 26 | err := jsoniter.UnmarshalFromString(str, v) 27 | if err != nil { 28 | return err 29 | } 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /portal/src/api/relay.js: -------------------------------------------------------------------------------- 1 | import request from '@/utils/request' 2 | 3 | // 获取relay列表 4 | export function fetchZeroAccessRelays(params = {}) { 5 | return request({ 6 | url: '/access/relay', 7 | method: 'get', 8 | params 9 | }) 10 | } 11 | 12 | // 添加relay 13 | export function postZeroAccessRelay(data = {}) { 14 | return request({ 15 | url: '/access/relay', 16 | method: 'post', 17 | data 18 | }) 19 | } 20 | 21 | // 修改relay 22 | export function putZeroAccessRelay(data = {}) { 23 | return request({ 24 | url: '/access/relay', 25 | method: 'put', 26 | data 27 | }) 28 | } 29 | 30 | // 删除relay 31 | export function deleteZeroAccessRelay(id) { 32 | return request({ 33 | url: `/access/relay/${id}`, 34 | method: 'delete' 35 | }) 36 | } 37 | -------------------------------------------------------------------------------- /portal/tests/e2e/support/index.js: -------------------------------------------------------------------------------- 1 | // *********************************************************** 2 | // This example support/index.js is processed and 3 | // loaded automatically before your test files. 4 | // 5 | // This is a great place to put global configuration and 6 | // behavior that modifies Cypress. 7 | // 8 | // You can change the location of this file or turn off 9 | // automatically serving support files with the 10 | // 'supportFile' configuration option. 11 | // 12 | // You can read more here: 13 | // https://on.cypress.io/configuration 14 | // *********************************************************** 15 | 16 | // Import commands.js using ES2015 syntax: 17 | import './commands' 18 | 19 | // Alternatively you can use CommonJS syntax: 20 | // require('./commands') 21 | -------------------------------------------------------------------------------- /ca/pkg/logger/logger_test.go: -------------------------------------------------------------------------------- 1 | package logger 2 | 3 | import ( 4 | "go.uber.org/zap" 5 | "go.uber.org/zap/zapcore" 6 | "testing" 7 | ) 8 | 9 | func TestNewLogger(t *testing.T) { 10 | defer Sync() 11 | GlobalConfig(Conf{ 12 | Debug: true, 13 | Caller: true, 14 | AppInfo: &ConfigAppData{ 15 | AppName: "test", 16 | AppID: "test", 17 | AppVersion: "1.0", 18 | AppKey: "test", 19 | Channel: "1", 20 | SubOrgKey: "key", 21 | Language: "zh", 22 | }, 23 | }) 24 | S().Info("test") 25 | } 26 | 27 | func TestColorLogger(t *testing.T) { 28 | config := zap.NewDevelopmentConfig() 29 | config.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder 30 | logger, _ := config.Build() 31 | 32 | logger.Info("Now logs should be colored") 33 | } 34 | -------------------------------------------------------------------------------- /client/internal/schema/s_server.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | import "github.com/flowshield/flowshield/client/pkg/util/json" 4 | 5 | type ServerType string 6 | 7 | const ServerTypeProvider ServerType = "provider" 8 | 9 | type ServerInfo struct { 10 | PeerAddress string `json:"peer_address"` 11 | PeerId string `json:"peer_id"` 12 | Addr string `json:"addr"` 13 | Port int `json:"port"` 14 | MetaData MetaData `json:"meta_data"` 15 | GasPrice int `json:"price"` 16 | Type ServerType `json:"type"` 17 | } 18 | 19 | type MetaData struct { 20 | Ip string `json:"ip"` 21 | Loc string `json:"loc"` 22 | Colo string `json:"colo"` 23 | } 24 | 25 | func (a *ServerInfo) String() string { 26 | return json.MarshalToString(a) 27 | } 28 | -------------------------------------------------------------------------------- /verifier/route/route.go: -------------------------------------------------------------------------------- 1 | package route 2 | 3 | import ( 4 | "github.com/flowshield/flowshield/verifier/app/base/controller" 5 | "github.com/flowshield/flowshield/verifier/pconst" 6 | "github.com/flowshield/flowshield/verifier/pkg/confer" 7 | "github.com/flowshield/flowshield/verifier/route/health" 8 | "github.com/gin-gonic/gin" 9 | ) 10 | 11 | // Home 主页 12 | func Home(engine *gin.Engine) { 13 | engine.GET("", controller.Welcome) 14 | } 15 | 16 | func Api(engine *gin.Engine) { 17 | prefix := confer.ConfigAppGetString("UrlPrefix", "") 18 | RouteV1 := engine.Group(prefix + pconst.APIAPIV1URL) 19 | { 20 | health.APIHealth(RouteV1) 21 | } 22 | } 23 | 24 | func NotFound(r *gin.Engine) { 25 | r.NoRoute(func(c *gin.Context) { 26 | c.String(404, "404 Not Found") 27 | }) 28 | } 29 | -------------------------------------------------------------------------------- /verifier/server/init.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "github.com/flowshield/flowshield/verifier/pkg/confer" 5 | "github.com/flowshield/flowshield/verifier/pkg/logger" 6 | "github.com/flowshield/flowshield/verifier/pkg/mysql" 7 | "github.com/urfave/cli" 8 | ) 9 | 10 | func InitService(c *cli.Context) (err error) { 11 | if err = confer.Init(c.String("c")); err != nil { 12 | return 13 | } 14 | cfg := confer.GlobalConfig() 15 | logger.Init(&logger.Config{ 16 | Level: logger.LogLevel(), 17 | Filename: logger.LogFile(), 18 | SendToFile: logger.SendLogToFile(), 19 | Development: confer.ConfigEnvIsDev(), 20 | }) 21 | if err = mysql.Init(&cfg.Mysql); err != nil { 22 | logger.Errorf(nil, "mysql init error : %v", err) 23 | return 24 | } 25 | return 26 | } 27 | -------------------------------------------------------------------------------- /fullnode/pkg/schema/s_server.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | type ServerType string 4 | 5 | const ServerTypeProvider ServerType = "provider" 6 | 7 | const FullNode ServerType = "fullnode" 8 | 9 | type ServerInfo struct { 10 | PeerId string `json:"peer_id"` 11 | Addr string `json:"addr"` 12 | Port int `json:"port"` 13 | MetaData MetaData `json:"meta_data"` 14 | Price uint `json:"price"` 15 | Type ServerType `json:"type"` 16 | } 17 | 18 | type MetaData struct { 19 | Ip string `json:"ip"` 20 | Loc string `json:"loc"` 21 | Colo string `json:"colo"` 22 | } 23 | 24 | type ClientP2P struct { 25 | ServerCID string `json:"server_cid"` 26 | Wallet string `json:"wallet"` 27 | UUID string `json:"uuid"` 28 | Port int `json:"port"` 29 | } 30 | -------------------------------------------------------------------------------- /portal/src/api/resource.js: -------------------------------------------------------------------------------- 1 | import request from '@/utils/request' 2 | 3 | // 获取资源列表 4 | export function fetchZeroAccessResources(params = {}) { 5 | return request({ 6 | url: '/access/resource', 7 | method: 'get', 8 | params 9 | }) 10 | } 11 | 12 | // 添加资源 13 | export function postZeroAccessResource(data = {}) { 14 | return request({ 15 | url: '/access/resource', 16 | method: 'post', 17 | data 18 | }) 19 | } 20 | 21 | // 修改资源 22 | export function putZeroAccessResource(data = {}) { 23 | return request({ 24 | url: '/access/resource', 25 | method: 'put', 26 | data 27 | }) 28 | } 29 | 30 | // 删除资源 31 | export function deleteZeroAccessResource(id) { 32 | return request({ 33 | url: `/access/resource/${id}`, 34 | method: 'delete' 35 | }) 36 | } 37 | -------------------------------------------------------------------------------- /client/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/flowshield/flowshield/client 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/LyricTian/queue v1.3.0 7 | github.com/fatih/camelcase v1.0.0 // indirect 8 | github.com/fatih/structs v1.1.0 // indirect 9 | github.com/go-redis/redis v6.15.9+incompatible 10 | github.com/google/uuid v1.6.0 11 | github.com/ipfs/go-cid v0.4.1 12 | github.com/jinzhu/copier v0.4.0 13 | github.com/json-iterator/go v1.1.12 14 | github.com/koding/multiconfig v0.0.0-20171124222453-69c27309b2d7 15 | github.com/onsi/gomega v1.19.0 // indirect 16 | github.com/pkg/errors v0.9.1 17 | github.com/sirupsen/logrus v1.9.3 18 | github.com/urfave/cli/v2 v2.27.3 19 | github.com/web3-storage/go-w3s-client v0.0.7 20 | github.com/wumansgy/goEncrypt v1.0.0 21 | github.com/xtaci/smux v2.0.1+incompatible 22 | ) 23 | -------------------------------------------------------------------------------- /contract/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "contract", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "@nomicfoundation/hardhat-toolbox": "^2.0.0", 14 | "@nomiclabs/hardhat-ethers": "^2.0.6", 15 | "@nomiclabs/hardhat-waffle": "^2.0.3", 16 | "chai": "^4.3.6", 17 | "ethereum-waffle": "^3.4.4", 18 | "ethers": "^5.6.9", 19 | "hardhat": "^2.10.0" 20 | }, 21 | "dependencies": { 22 | "@openzeppelin/contracts": "^4.7.0", 23 | "@openzeppelin/contracts-upgradeable": "^4.7.2", 24 | "@openzeppelin/hardhat-upgrades": "^1.19.1", 25 | "dotenv": "^16.0.2" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /fullnode/app/v1/user/dao/api/github.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "io/ioutil" 7 | 8 | "github.com/gin-gonic/gin" 9 | "github.com/google/go-github/github" 10 | "golang.org/x/oauth2" 11 | ) 12 | 13 | func GetGithubUser(c *gin.Context, config *oauth2.Config, code string) (user *github.User, err error) { 14 | token, err := config.Exchange(c, code) 15 | if err != nil { 16 | return 17 | } 18 | client := config.Client(context.TODO(), token) 19 | response, err := client.Get("https://api.github.com/user") 20 | if err != nil { 21 | return 22 | } 23 | defer response.Body.Close() 24 | info, err := ioutil.ReadAll(response.Body) 25 | if err != nil { 26 | return 27 | } 28 | err = json.Unmarshal(info, &user) 29 | if err != nil { 30 | return 31 | } 32 | return 33 | } 34 | -------------------------------------------------------------------------------- /ca/pkg/signature/signer_test.go: -------------------------------------------------------------------------------- 1 | package signature 2 | 3 | import ( 4 | "crypto/ecdsa" 5 | "fmt" 6 | "github.com/flowshield/flowshield/ca/pkg/keygen" 7 | "testing" 8 | ) 9 | 10 | func TestEcdsaSign(t *testing.T) { 11 | priv, _, _ := keygen.GenKey(keygen.EcdsaSigAlg) 12 | s := NewSigner(priv) 13 | sign, err := s.Sign([]byte("Test")) 14 | if err != nil { 15 | panic(err) 16 | } 17 | fmt.Println(sign) 18 | } 19 | 20 | func TestEcdsaVerify(t *testing.T) { 21 | text := []byte("Test") 22 | priv, _, _ := keygen.GenKey(keygen.EcdsaSigAlg) 23 | s := NewSigner(priv) 24 | sign, err := s.Sign(text) 25 | if err != nil { 26 | panic(err) 27 | } 28 | key := priv.(*ecdsa.PrivateKey) 29 | v := NewVerifier(key.Public()) 30 | result, err := v.Verify(text, sign) 31 | if err != nil { 32 | panic(err) 33 | } 34 | fmt.Println(result) 35 | } 36 | -------------------------------------------------------------------------------- /ca/initer/initer.go: -------------------------------------------------------------------------------- 1 | package initer 2 | 3 | import ( 4 | "github.com/flowshield/flowshield/ca/ca/keymanager" 5 | "github.com/flowshield/flowshield/ca/core" 6 | "github.com/flowshield/flowshield/ca/pkg/logger" 7 | "github.com/urfave/cli" 8 | "log" 9 | // ... 10 | _ "github.com/flowshield/flowshield/ca/util" 11 | ) 12 | 13 | // Init Initialization 14 | func Init(c *cli.Context) error { 15 | conf, err := parseConfigs(c) 16 | if err != nil { 17 | return err 18 | } 19 | initLogger(&conf) 20 | log.Printf("started with conf: %+v", conf) 21 | 22 | l := &core.Logger{Logger: logger.S()} 23 | 24 | i := &core.I{ 25 | Config: &conf, 26 | Logger: l, 27 | } 28 | 29 | core.Is = i 30 | // CA Start 31 | if err := keymanager.InitKeeper(); err != nil { 32 | return err 33 | } 34 | 35 | logger.Info("success started.") 36 | return nil 37 | } 38 | -------------------------------------------------------------------------------- /provider/pkg/web3/eth/eth.go: -------------------------------------------------------------------------------- 1 | package eth 2 | 3 | import ( 4 | "context" 5 | "math/big" 6 | 7 | "github.com/flowshield/flowshield/provider/internal/config" 8 | 9 | "github.com/ethereum/go-ethereum/common" 10 | 11 | "github.com/ethereum/go-ethereum/ethclient" 12 | ) 13 | 14 | var client *ethclient.Client 15 | 16 | func Init(cfg *config.Web3) (err error) { 17 | client, err = ethclient.Dial(cfg.EthAddress()) 18 | if err != nil { 19 | return err 20 | } 21 | return nil 22 | } 23 | 24 | func GetEthBalance(ctx context.Context, address string) (*big.Int, error) { 25 | account := common.HexToAddress(address) 26 | balance, err := client.BalanceAt(ctx, account, nil) 27 | if err != nil { 28 | return nil, err 29 | } 30 | return balance, nil 31 | } 32 | 33 | func GetContractBalance(address string) (*big.Int, error) { 34 | return nil, nil 35 | } 36 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Basic set up for three package managers 2 | 3 | version: 2 4 | updates: 5 | 6 | # Maintain dependencies for GitHub Actions 7 | - package-ecosystem: "github-actions" 8 | directory: "/" 9 | schedule: 10 | interval: "daily" 11 | 12 | # Maintain dependencies for gomod 13 | - package-ecosystem: "gomod" 14 | directory: "/client" 15 | schedule: 16 | interval: "daily" 17 | 18 | - package-ecosystem: "gomod" 19 | directory: "/fullnode" 20 | schedule: 21 | interval: "daily" 22 | 23 | - package-ecosystem: "gomod" 24 | directory: "/provider" 25 | schedule: 26 | interval: "daily" 27 | 28 | - package-ecosystem: "gomod" 29 | directory: "/verifier" 30 | schedule: 31 | interval: "daily" 32 | 33 | - package-ecosystem: "gomod" 34 | directory: "/ca" 35 | schedule: 36 | interval: "daily" -------------------------------------------------------------------------------- /verifier/app/v1/node/controller/health.go: -------------------------------------------------------------------------------- 1 | package v1 2 | 3 | import ( 4 | "github.com/flowshield/flowshield/verifier/app/base/controller" 5 | "github.com/flowshield/flowshield/verifier/app/v1/node/model/mparam" 6 | "github.com/flowshield/flowshield/verifier/app/v1/node/service" 7 | "github.com/flowshield/flowshield/verifier/pkg/response" 8 | "github.com/gin-gonic/gin" 9 | ) 10 | 11 | // @Summary ListNode 12 | // @Description 获取全部节点 13 | // @Tags ZTA Node 14 | // @Produce json 15 | // @Success 200 {object} controller.Res 16 | // @Router /verifier/provider/health [post] 17 | func ProviderHealth(c *gin.Context) { 18 | param := &mparam.ProviderHealth{} 19 | b, code := controller.BindParams(c, ¶m) 20 | if !b { 21 | response.UtilResponseReturnJsonFailed(c, code) 22 | return 23 | } 24 | code, data := service.ProviderHealth(c, param) 25 | response.UtilResponseReturnJson(c, code, data) 26 | } 27 | -------------------------------------------------------------------------------- /portal/src/api/clients.js: -------------------------------------------------------------------------------- 1 | import request from '@/utils/request' 2 | 3 | export function fetchZeroAccessClients(params = {}) { 4 | return request({ 5 | url: '/access/client', 6 | method: 'get', 7 | params 8 | }) 9 | } 10 | 11 | export function postZeroAccessClientsPayNotify(data = {}) { 12 | return request({ 13 | url: '/access/client/notify', 14 | method: 'post', 15 | data 16 | }) 17 | } 18 | export function postZeroAccessClient(data = {}) { 19 | return request({ 20 | url: '/access/client', 21 | method: 'post', 22 | data 23 | }) 24 | } 25 | 26 | export function putZeroAccessClient(data = {}) { 27 | return request({ 28 | url: '/access/client', 29 | method: 'put', 30 | data 31 | }) 32 | } 33 | 34 | export function deleteZeroAccessClient(id) { 35 | return request({ 36 | url: `/access/client/${id}`, 37 | method: 'delete' 38 | }) 39 | } 40 | -------------------------------------------------------------------------------- /contract/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-artifact-1", 3 | "contractName": "AddressUpgradeable", 4 | "sourceName": "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol", 5 | "abi": [], 6 | "bytecode": "0x60566050600b82828239805160001a6073146043577f4e487b7100000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220f27157671d3c5868c24716171f9097885f02c47048143a1215c481954d38a6b164736f6c634300080f0033", 7 | "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220f27157671d3c5868c24716171f9097885f02c47048143a1215c481954d38a6b164736f6c634300080f0033", 8 | "linkReferences": {}, 9 | "deployedLinkReferences": {} 10 | } 11 | -------------------------------------------------------------------------------- /portal/README.md: -------------------------------------------------------------------------------- 1 | 🌈 _**Portal** is a user-friendly UI portal that provides users with a control interface with low thresholds._ 🌈 2 | --- 3 | 4 | ## 💪🏻 Start 5 | 6 | Required Tools: 7 | - [Node.js](https://nodejs.org/en/download/) >= 14 8 | - [Git](https://git-scm.com/downloads) 9 | 10 | 11 | ```bash 12 | # Project setup 13 | npm install 14 | 15 | # Compiles and hot-reloads for development 16 | npm run serve 17 | 18 | # Compiles and minifies for production 19 | npm run build 20 | ``` 21 | 22 | ## 😃 Contribute 23 | 24 | ### Bug Reports / Feature Requests 25 | If you want to report a bug or request a new feature. Free feel to open a [new issue](https://github.com/FlowShield/FlowShield/pulls). 26 | 27 | ### Pull Requests 28 | 29 | If you want to modify FlowShield-portal, this guideline may be useful for you [CONTRIBUTING](https://github.com/FlowShield/FlowShield/blob/main/portal/CONTRIBUTING.md) 30 | 31 | -------------------------------------------------------------------------------- /portal/src/permission.js: -------------------------------------------------------------------------------- 1 | import router from './router' 2 | import { EventBus } from '@/utils/event-bus' 3 | import store from '@/store' 4 | 5 | const whiteList = ['login', 'home', 'wallet', 'nodes', 'orders', 'resources'] // skip login 6 | 7 | router.beforeEach(async(to, from, next) => { 8 | EventBus.$emit('app.loading', true) 9 | document.title = to?.meta?.title || 'CloudSlit Portal' 10 | 11 | // goto login if needed 12 | try { 13 | await store.dispatch('getUserInfo') 14 | } catch (e) { 15 | if (!whiteList.includes(to.name)) { 16 | EventBus.$emit('app.message', 'Need login', 'warning') 17 | hideLoading() 18 | next({ name: 'login' }) 19 | } 20 | } 21 | 22 | next() 23 | }) 24 | 25 | router.afterEach(_ => { 26 | hideLoading() 27 | }) 28 | 29 | function hideLoading() { 30 | window.setTimeout(() => { 31 | EventBus.$emit('app.loading', false) 32 | }, 100) 33 | } 34 | -------------------------------------------------------------------------------- /ca/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "github.com/flowshield/flowshield/ca/cmd" 6 | "github.com/flowshield/flowshield/ca/initer" 7 | "github.com/flowshield/flowshield/ca/pkg/logger" 8 | "github.com/urfave/cli" 9 | "os" 10 | ) 11 | 12 | func main() { 13 | ctx := context.Background() 14 | 15 | app := cli.NewApp() 16 | app.Name = "capitalizone" 17 | app.Version = "1.0.0" 18 | app.Usage = "capitalizone" 19 | app.Commands = []cli.Command{ 20 | newTlsCmd(ctx), 21 | } 22 | app.Before = initer.Init 23 | err := app.Run(os.Args) 24 | if err != nil { 25 | logger.Named("Init").Errorf(err.Error()) 26 | } 27 | } 28 | 29 | // newTlsCmd Running TLS service 30 | func newTlsCmd(ctx context.Context) cli.Command { 31 | return cli.Command{ 32 | Name: "tls", 33 | Usage: "Running TLS service", 34 | Action: func(c *cli.Context) error { 35 | return cmd.RunTls(ctx) 36 | }, 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /portal/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 |
11 |
12 | ## Getting Started
13 |
14 | ### Configuration
15 |
16 | In the configs directory, the user stores the project configuration file with the file name: config.toml, which can be modified according to your own needs
17 |
18 | By default, you do not need to modify the configuration file, just refer to QuickStart.
19 |
20 | ### Quickstart
21 | ```shell
22 | $ make
23 | $ ./bin/client
24 | ```
25 |
26 | ## License
27 | FlowShield-client uses Apache 2.0 license. See [license](LICENSE) directory for details
28 |
29 | ## Disclaimers
30 | When you use this software, you have agreed and declared that the author, maintainer and contributor of this software are not responsible for any risks, costs or problems you encounter. If you find a software defect or bug, please submit a patch to help improve!
31 |
--------------------------------------------------------------------------------
/provider/pkg/logger/hook/redis/redis.go:
--------------------------------------------------------------------------------
1 | package redis
2 |
3 | import (
4 | "fmt"
5 |
6 | "github.com/flowshield/flowshield/provider/pkg/util/json"
7 |
8 | "github.com/go-redis/redis"
9 | "github.com/sirupsen/logrus"
10 | )
11 |
12 | type Config struct {
13 | Addr string
14 | Password string
15 | Key string
16 | }
17 |
18 | func New(c *Config) *Hook {
19 | redisdb := redis.NewClient(&redis.Options{
20 | Addr: c.Addr, // use default Addr
21 | Password: c.Password, // no password set
22 | DB: 0, // use default DB
23 | })
24 |
25 | _, err := redisdb.Ping().Result()
26 | if err != nil {
27 | fmt.Println("error creating message for REDIS:", err)
28 | panic(err)
29 | }
30 | return &Hook{
31 | cli: redisdb,
32 | key: c.Key,
33 | }
34 | }
35 |
36 | type Hook struct {
37 | cli *redis.Client
38 | key string
39 | }
40 |
41 | func (h *Hook) Exec(entry *logrus.Entry) error {
42 | fields := make(map[string]interface{})
43 | for k, v := range entry.Data {
44 | fields[k] = v
45 | }
46 | fields["level"] = entry.Level.String()
47 | fields["message"] = entry.Message
48 | b, _ := json.Marshal(fields)
49 | return h.cli.RPush(h.key, string(b)).Err()
50 | }
51 |
52 | func (h *Hook) Close() error {
53 | return h.cli.Close()
54 | }
55 |
--------------------------------------------------------------------------------
/ca/pkg/signature/signer.go:
--------------------------------------------------------------------------------
1 | package signature
2 |
3 | import (
4 | "crypto"
5 | "crypto/ecdsa"
6 | "crypto/rsa"
7 |
8 | "github.com/pkg/errors"
9 | )
10 |
11 | // Signer ...
12 | type Signer struct {
13 | priv crypto.PrivateKey
14 | }
15 |
16 | // NewSigner ...
17 | func NewSigner(priv crypto.PrivateKey) *Signer {
18 | return &Signer{priv: priv}
19 | }
20 |
21 | // Sign
22 | func (s *Signer) Sign(text []byte) (sign string, err error) {
23 | switch priv := s.priv.(type) {
24 | case *ecdsa.PrivateKey:
25 | sign, err = EcdsaSign(priv, text)
26 | return
27 | case *rsa.PrivateKey:
28 | // Todo supports RSA
29 | return "", errors.New("algo not supported")
30 | default:
31 | return "", errors.New("algo not supported")
32 | }
33 | }
34 |
35 | // Verifier ...
36 | type Verifier struct {
37 | pub crypto.PublicKey
38 | }
39 |
40 | // NewVerifier ...
41 | func NewVerifier(pub crypto.PublicKey) *Verifier {
42 | return &Verifier{pub: pub}
43 | }
44 |
45 | // Verify Verify signature
46 | func (v *Verifier) Verify(text []byte, sign string) (bool, error) {
47 | switch pub := v.pub.(type) {
48 | case *ecdsa.PublicKey:
49 | return EcdsaVerify(text, sign, pub)
50 | case *rsa.PublicKey:
51 | // Todo supports RSA
52 | default:
53 | }
54 | return false, errors.New("algo not supported")
55 | }
56 |
--------------------------------------------------------------------------------
/provider/internal/dao/provider/model/provider.go:
--------------------------------------------------------------------------------
1 | package model
2 |
3 | import "github.com/flowshield/flowshield/provider/internal/schema"
4 |
5 | type Providers []*Provider
6 |
7 | type Provider struct {
8 | ID uint `gorm:"primarykey" json:"id"`
9 | CreatedAt int64 `gorm:"autoCreateTime" json:"created_at"`
10 | UpdatedAt int64 `gorm:"autoUpdateTime" json:"updated_at"`
11 | ExpiredAt int64 `gorm:"autoExpiredTime" json:"expired_at"`
12 | Uuid string `gorm:"uuid" json:"uuid"`
13 | Wallet string `gorm:"wallet" json:"wallet"`
14 | ServerCid string `gorm:"server_cid" json:"server_cid"`
15 | Port int `gorm:"port" json:"port"`
16 | }
17 |
18 | func (Provider) TableName() string {
19 | return "pr_provider"
20 | }
21 |
22 | func (a *Provider) ToNodeOrder() *schema.NodeOrder {
23 | result := &schema.NodeOrder{
24 | Uuid: a.Uuid,
25 | Wallet: a.Wallet,
26 | ServerCid: a.ServerCid,
27 | Port: a.Port,
28 | }
29 | return result
30 | }
31 |
32 | func OrderToProvider(order *schema.NodeOrder, pc *schema.ProviderConfig) *Provider {
33 | result := &Provider{
34 | Uuid: order.Uuid,
35 | Wallet: order.Wallet,
36 | ServerCid: order.ServerCid,
37 | Port: order.Port,
38 | ExpiredAt: pc.CertConfig.NotAfter.Unix(),
39 | }
40 | return result
41 | }
42 |
--------------------------------------------------------------------------------
/fullnode/config.yaml:
--------------------------------------------------------------------------------
1 | #APP ENV
2 | app:
3 | env: "release" # dev,release
4 | sysname: "FlowShield"
5 | port: 8080
6 | domain: DOMAIN
7 |
8 | #Mysql
9 | mysql:
10 | dbname: "zta"
11 | prefix: "zta_"
12 | pool:
13 | pool-min-cap: 10
14 | pool-ex-cap: 5
15 | pool-max-cap: 40
16 | pool-idle-timeout: 3600
17 | pool-wait-count: 1000
18 | pool-wai-timeout: 30
19 | write:
20 | host: "CS_MYSQL_HOST"
21 | port: 23306
22 | user: "CS_MYSQL_USER"
23 | password: "CS_MYSQL_PASSWORD"
24 |
25 | #Redis
26 | redis:
27 | addr: "CS_REDIS_ADDR"
28 |
29 | #CA
30 | ca:
31 | sign-url: "CS_CA_SIGN_URL"
32 | auth-key: "CS_CA_AUTH_KEY"
33 |
34 | oauth2:
35 | client-id: "CS_OAUTH2_CLIENT_ID"
36 | client-secret: "CS_OAUTH2_CLIENT_SECRET"
37 |
38 | p2p:
39 | enable: true
40 | # account: "CS_ACCOUNT"
41 | service-discovery-id: "CS_P2P_SERVICE_DISCOVERY_ID"
42 | service-discovery-mode: "advertise" # advertise or announce
43 | service-metadata-topic: "CS_P2P_SERVICE_METADATA_TOPIC" # advertise or announce
44 |
45 | web3:
46 | register: "CS_WEB3_REGIST"
47 | private-key: "CS_PRIVATE_KEY"
48 | contract:
49 | token: "CS_CONTRACT_TOKEN"
50 | w3s:
51 | token: "CS_W3S_TOKEN"
52 | timeout: 10
53 | retry-count: 100
54 | eth:
55 | url: "CS_ETH_URL"
56 |
--------------------------------------------------------------------------------
/ca/pkg/logger/example/single_test.go:
--------------------------------------------------------------------------------
1 | package example
2 |
3 | import (
4 | "github.com/flowshield/flowshield/ca/pkg/logger"
5 | "github.com/flowshield/flowshield/ca/pkg/logger/redis_hook"
6 | "go.uber.org/zap/zapcore"
7 | "log"
8 | )
9 |
10 | var (
11 | EnvEnableRedisOutput bool // Simulated environment variables
12 | EnvDebug bool
13 | )
14 |
15 | func init() {
16 | EnvEnableRedisOutput = true
17 | EnvDebug = true
18 | initLogger()
19 | }
20 |
21 | func initLogger() {
22 | conf := &logger.Conf{
23 | Level: zapcore.DebugLevel, // Output log level
24 | Caller: true, //Whether to open record calling folder + number of lines + function name
25 | Debug: true, // Enable debug
26 | // All logs output to redis are above info level
27 | AppInfo: &logger.ConfigAppData{
28 | AppVersion: "1.0",
29 | Language: "zh-cn",
30 | },
31 | }
32 | if !EnvDebug || EnvEnableRedisOutput {
33 | // In case of production environment
34 | conf.Level = zapcore.InfoLevel
35 | conf.HookConfig = &redis_hook.HookConfig{
36 | Key: "log_key",
37 | Host: "redis.msp",
38 | Port: 6380,
39 | }
40 | }
41 | err := logger.GlobalConfig(*conf)
42 | if err != nil {
43 | log.Print("[ERR] Logger init error: ", err)
44 | }
45 | logger.Infof("info test: %v", "data")
46 | }
47 |
--------------------------------------------------------------------------------
/fullnode/pkg/confer/config_app.go:
--------------------------------------------------------------------------------
1 | package confer
2 |
3 | import (
4 | "strings"
5 | )
6 |
7 | func ConfigAppGetString(key string, defaultConfig string) string {
8 | config := ConfigAppGet(key)
9 | if config == nil {
10 | return defaultConfig
11 | } else {
12 | configStr := config.(string)
13 | if len(strings.TrimSpace(configStr)) == 0 {
14 | configStr = defaultConfig
15 | }
16 | return configStr
17 | }
18 | }
19 |
20 | func ConfigAppGetInt(key string, defaultConfig int) int {
21 | config := ConfigAppGet(key)
22 | if config == nil {
23 | return defaultConfig
24 | } else {
25 | configInt := config.(int)
26 | if configInt == 0 {
27 | configInt = defaultConfig
28 | }
29 | return configInt
30 | }
31 | }
32 |
33 | func ConfigAppGet(key string) interface{} {
34 | globalConfig.RLock()
35 | defer globalConfig.RUnlock()
36 | //将配置文件中的app字段转为map
37 | config, exists := globalConfig.App[key]
38 | if !exists {
39 | return nil
40 | }
41 | return config
42 | }
43 |
44 | func ConfigEnvGet() string {
45 | strEnv := ConfigAppGet("env")
46 | return strEnv.(string)
47 | }
48 |
49 | func ConfigEnvIsDev() bool {
50 | env := ConfigEnvGet()
51 | if env == "dev" {
52 | return true
53 | }
54 | return false
55 | }
56 |
57 | func ConfigEnvIsBeta() bool {
58 | return ConfigEnvGet() == "beta"
59 | }
60 |
--------------------------------------------------------------------------------
/fullnode/config_nervos.yaml:
--------------------------------------------------------------------------------
1 | #APP ENV
2 | app:
3 | env: "release" # dev,release
4 | sysname: "FlowShield"
5 | port: 8080
6 | domain: DOMAIN
7 |
8 | #Mysql
9 | mysql:
10 | dbname: "zta"
11 | prefix: "zta_"
12 | pool:
13 | pool-min-cap: 10
14 | pool-ex-cap: 5
15 | pool-max-cap: 40
16 | pool-idle-timeout: 3600
17 | pool-wait-count: 1000
18 | pool-wai-timeout: 30
19 | write:
20 | host: "CS_MYSQL_HOST"
21 | port: 23306
22 | user: "CS_MYSQL_USER"
23 | password: "CS_MYSQL_PASSWORD"
24 |
25 | #Redis
26 | redis:
27 | addr: "CS_REDIS_ADDR"
28 |
29 | #CA
30 | ca:
31 | sign-url: "CS_CA_SIGN_URL"
32 | auth-key: "CS_CA_AUTH_KEY"
33 |
34 | oauth2:
35 | client-id: "CS_OAUTH2_CLIENT_ID"
36 | client-secret: "CS_OAUTH2_CLIENT_SECRET"
37 |
38 | p2p:
39 | enable: true
40 | # account: "CS_ACCOUNT"
41 | service-discovery-id: "flowshield/provider"
42 | service-discovery-mode: "advertise" # advertise or announce
43 | service-metadata-topic: "flowshield_provider_metadata" # advertise or announce
44 |
45 | web3:
46 | register: "CS_WEB3_REGIST"
47 | private-key: "CS_PRIVATE_KEY"
48 | contract:
49 | token: "CS_CONTRACT_TOKEN"
50 | w3s:
51 | token: "CS_W3S_TOKEN"
52 | timeout: 10
53 | retry-count: 100
54 | eth:
55 | url: "https://godwoken-testnet-v1.ckbapp.dev"
56 | projectid: ""
57 |
--------------------------------------------------------------------------------
/portal/src/router/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import VueRouter from 'vue-router'
3 |
4 | Vue.use(VueRouter)
5 |
6 | const routes = [
7 | {
8 | path: '/',
9 | name: 'home',
10 | component: () => import('@/views/HomeView')
11 | },
12 | {
13 | path: '/login',
14 | name: 'login',
15 | component: () => import('@/views/login')
16 | },
17 | {
18 | path: '/clients',
19 | name: 'clients',
20 | component: () => import('@/views/clients')
21 | },
22 | {
23 | path: '/servers',
24 | name: 'servers',
25 | component: () => import('@/views/servers')
26 | },
27 | {
28 | path: '/resources',
29 | name: 'resources',
30 | component: () => import('@/views/resources')
31 | },
32 | {
33 | path: '/relay',
34 | name: 'relay',
35 | component: () => import('@/views/relay')
36 | },
37 | {
38 | path: '/nodes',
39 | name: 'nodes',
40 | component: () => import('@/views/nodes')
41 | },
42 | {
43 | path: '/orders',
44 | name: 'orders',
45 | component: () => import('@/views/orders')
46 | },
47 | {
48 | path: '/wallet',
49 | name: 'wallet',
50 | component: () => import('@/views/wallet')
51 | }
52 | ]
53 |
54 | const router = new VueRouter({
55 | mode: 'history',
56 | base: process.env.BASE_URL,
57 | routes
58 | })
59 |
60 | export default router
61 |
--------------------------------------------------------------------------------
/fullnode/config_eth.yaml:
--------------------------------------------------------------------------------
1 | #APP ENV
2 | app:
3 | env: "release" # dev,release
4 | sysname: "FlowShield"
5 | port: 8080
6 | domain: DOMAIN
7 |
8 | #Mysql
9 | mysql:
10 | dbname: "zta"
11 | prefix: "zta_"
12 | pool:
13 | pool-min-cap: 10
14 | pool-ex-cap: 5
15 | pool-max-cap: 40
16 | pool-idle-timeout: 3600
17 | pool-wait-count: 1000
18 | pool-wai-timeout: 30
19 | write:
20 | host: "CS_MYSQL_HOST"
21 | port: 23306
22 | user: "CS_MYSQL_USER"
23 | password: "CS_MYSQL_PASSWORD"
24 |
25 | #Redis
26 | redis:
27 | addr: "CS_REDIS_ADDR"
28 |
29 | #CA
30 | ca:
31 | sign-url: "CS_CA_SIGN_URL"
32 | auth-key: "CS_CA_AUTH_KEY"
33 |
34 | oauth2:
35 | client-id: "CS_OAUTH2_CLIENT_ID"
36 | client-secret: "CS_OAUTH2_CLIENT_SECRET"
37 |
38 | p2p:
39 | enable: true
40 | # account: "CS_ACCOUNT"
41 | service-discovery-id: "flowshield/provider"
42 | service-discovery-mode: "advertise" # advertise or announce
43 | service-metadata-topic: "flowshield_provider_metadata" # advertise or announce
44 |
45 | web3:
46 | register: "CS_WEB3_REGIST"
47 | private-key: "CS_PRIVATE_KEY"
48 | contract:
49 | token: "CS_CONTRACT_TOKEN"
50 | w3s:
51 | token: "CS_W3S_TOKEN"
52 | timeout: 10
53 | retry-count: 100
54 | eth:
55 | url: "https://ropsten.infura.io/v3"
56 | projectid: "45630f96f9d841679dc200a7c97763d2"
57 |
--------------------------------------------------------------------------------
/deploy/fullnode/docker-compose/nginx.conf:
--------------------------------------------------------------------------------
1 | user nginx;
2 | worker_processes auto;
3 |
4 | error_log /var/log/nginx/error.log warn;
5 | pid /var/run/nginx.pid;
6 |
7 | events {
8 | worker_connections 10240;
9 | }
10 |
11 | http {
12 | sendfile on;
13 | tcp_nopush on;
14 | tcp_nodelay on;
15 |
16 | keepalive_timeout 65;
17 |
18 | access_log off;
19 | error_log off;
20 |
21 | include mime.types;
22 | default_type application/octet-stream;
23 |
24 | gzip on;
25 | gzip_vary on;
26 | gzip_proxied any;
27 | gzip_comp_level 6;
28 |
29 | server {
30 | listen 80 default_server;
31 |
32 | server_name dash.flowshield.xyz; #here is your domain
33 |
34 | root /usr/share/nginx/html;
35 | index index.html;
36 |
37 | location ^~ /api/ {
38 | proxy_pass http://flowshield-backend:8080;
39 | }
40 |
41 | location ^~ /a/ {
42 | proxy_pass http://flowshield-backend:8080;
43 | }
44 |
45 | location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
46 | expires 30d;
47 | access_log off;
48 | }
49 |
50 | location ~ .*\.(js|css)?$ {
51 | expires 7d;
52 | access_log off;
53 | }
54 |
55 | location / {
56 | try_files $uri $uri/ /index.html;
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/verifier/pkg/confer/config_app.go:
--------------------------------------------------------------------------------
1 | package confer
2 |
3 | import "github.com/flowshield/flowshield/verifier/pkg/util"
4 |
5 | func ConfigAppGetString(key string, defaultConfig string) string {
6 | config := ConfigAppGet(key)
7 | if config == nil {
8 | return defaultConfig
9 | } else {
10 | configStr := config.(string)
11 | if util.UtilIsEmpty(configStr) {
12 | configStr = defaultConfig
13 | }
14 | return configStr
15 | }
16 | }
17 |
18 | func ConfigAppGetInt(key string, defaultConfig int) int {
19 | config := ConfigAppGet(key)
20 | if config == nil {
21 | return defaultConfig
22 | } else {
23 | configInt := config.(int)
24 | if configInt == 0 {
25 | configInt = defaultConfig
26 | }
27 | return configInt
28 | }
29 | }
30 |
31 | func ConfigAppGet(key string) interface{} {
32 | globalConfig.RLock()
33 | defer globalConfig.RUnlock()
34 | //将配置文件中的app字段转为map
35 | config, exists := globalConfig.App[key]
36 | if !exists {
37 | return nil
38 | }
39 | return config
40 | }
41 |
42 | func ConfigEnvGet() string {
43 | strEnv := ConfigAppGet("env")
44 | return strEnv.(string)
45 | }
46 |
47 | func ConfigEnvIsDev() bool {
48 | env := ConfigEnvGet()
49 | if env == "dev" || env == "debug" {
50 | return true
51 | }
52 | return false
53 | }
54 |
55 | func ConfigEnvIsBeta() bool {
56 | env := ConfigEnvGet()
57 | if env == "beta" {
58 | return true
59 | }
60 | return false
61 | }
62 |
--------------------------------------------------------------------------------
/verifier/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "context"
5 | "fmt"
6 | "os"
7 | "os/signal"
8 | "syscall"
9 |
10 | "github.com/flowshield/flowshield/verifier/verify"
11 |
12 | "github.com/flowshield/flowshield/verifier/server"
13 | "github.com/urfave/cli"
14 | _ "go.uber.org/automaxprocs"
15 | )
16 |
17 | func main() {
18 | app := cli.NewApp()
19 | app.Name = "verifier"
20 | app.Author = "TS"
21 | app.Flags = []cli.Flag{
22 | cli.StringFlag{
23 | Name: "c",
24 | Value: "config.yaml",
25 | Usage: "config file url",
26 | },
27 | }
28 | app.Before = server.InitService
29 | app.Action = func(c *cli.Context) error {
30 | if err := verify.VerObj.Run(context.TODO()); err != nil {
31 | return err
32 | }
33 | server.RunHTTP()
34 | return nil
35 | }
36 | //app.After = func(c *cli.Context) error {
37 | //exitSignal()
38 | //return nil
39 | //}
40 | err := app.Run(os.Args)
41 | if err != nil {
42 | panic("app run error:" + err.Error())
43 | }
44 | }
45 |
46 | func exitSignal() {
47 | sigs := make(chan os.Signal, 1)
48 | signal.Notify(sigs, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
49 | for sig := range sigs {
50 | switch sig {
51 | case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
52 | fmt.Println("Bye!")
53 | os.Exit(0)
54 | case syscall.SIGHUP:
55 | fmt.Println("+++++++++++++++++++++++++++++")
56 | default:
57 | fmt.Println(sig)
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/fullnode/agent/user.go:
--------------------------------------------------------------------------------
1 | package agent
2 |
3 | import (
4 | "fmt"
5 | "runtime/debug"
6 | "time"
7 |
8 | "github.com/flowshield/flowshield/fullnode/app/v1/user/model/mmysql"
9 |
10 | mysqlUser "github.com/flowshield/flowshield/fullnode/app/v1/user/dao/mysql"
11 | serviceUser "github.com/flowshield/flowshield/fullnode/app/v1/user/service"
12 | "github.com/flowshield/flowshield/fullnode/pkg/logger"
13 | )
14 |
15 | // SyncUserBindStatus 每30秒轮循未绑定的用户,判断是否已绑定
16 | func SyncUserBindStatus() {
17 | closeChan := make(chan interface{}) // 信号监控
18 | go func() {
19 | for range closeChan {
20 | go handleUserBindStatus(closeChan)
21 | }
22 | }()
23 | go handleUserBindStatus(closeChan)
24 | }
25 |
26 | func handleUserBindStatus(closeChan chan<- interface{}) {
27 | userDao := mysqlUser.NewUser(nil)
28 | defer func() {
29 | if err := recover(); err != nil {
30 | logger.Errorf(nil, "handleUserBindStatus stacktrace from panic:\n"+string(debug.Stack()), fmt.Errorf("%v", err))
31 | }
32 | closeChan <- struct{}{}
33 | }()
34 | for {
35 | select {
36 | case <-time.After(time.Second * 10):
37 | userList, err := userDao.GetUserByStatus(mmysql.UnBind)
38 | if err != nil {
39 | logger.Errorf(nil, "handleUserBindStatus get user by status error: %v", err)
40 | continue
41 | }
42 | for _, value := range userList {
43 | time.Sleep(5 * time.Second)
44 | serviceUser.CheckAndBindUser(&value)
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/provider/README.md:
--------------------------------------------------------------------------------
1 | # FlowShield Provider
2 |
3 | As a service network provider program, miners can deploy network services through this program to obtain rewards.
4 |
5 | The program automatically finds through P2P networking and uses PubSub mode to share its own data.
6 |
7 | Currently, websocket traffic transmission is supported.
8 |
9 | ## How does it work?
10 |
11 | ### Scene Introduction
12 |
13 |
14 | ## Getting Started
15 |
16 | ### Configuration
17 |
18 | In the configs directory, the user stores the project configuration file with the file name: config.toml, which can be modified according to your own needs
19 |
20 | During deployment, you can refer to our current [deployment example](https://github.com/FlowShield/FlowShield/tree/main/deploy/provider) and modify the corresponding configuration
21 |
22 |
23 | ### Quickstart
24 | ```shell
25 | $ make
26 | $ ./bin/provider -c ./configs/config.toml
27 | ```
28 |
29 | ## License
30 | FlowShield-Provider uses Apache 2.0 license. See [license](LICENSE) directory for details
31 |
32 | ## Disclaimers
33 | When you use this software, you have agreed and declared that the author, maintainer and contributor of this software are not responsible for any risks, costs or problems you encounter. If you find a software defect or bug, please submit a patch to help improve!
34 |
--------------------------------------------------------------------------------
/verifier/verify/provider.go:
--------------------------------------------------------------------------------
1 | package verify
2 |
3 | import (
4 | "time"
5 | )
6 |
7 | type Provider struct {
8 | PeerId string `json:"peer_id"`
9 | Addr string `json:"addr"`
10 | Port int `json:"port"`
11 | IP string `json:"ip"`
12 | Loc string `json:"loc"`
13 | Colo string `json:"colo"`
14 | Price uint `json:"price"`
15 | Order []*Order `json:"order"`
16 | }
17 |
18 | func providers(orders []*OrderMysql) (providers []*Provider, err error) {
19 | if orders == nil || len(orders) == 0 {
20 | return
21 | }
22 | var providerMap = make(map[string][]*OrderMysql)
23 | for _, value := range orders {
24 | providerMap[value.PeerID] = append(providerMap[value.PeerID], value)
25 | }
26 | for key, value := range providerMap {
27 | orderSli := make([]*Order, 0)
28 | for _, v := range value {
29 | orderObj := &Order{
30 | PeerID: v.PeerID,
31 | Port: v.Port,
32 | OrderID: v.UUID,
33 | StartTime: time.Unix(v.UpdatedAt, 0),
34 | EndTime: time.Unix(v.UpdatedAt, 0).Add(time.Duration(v.Duration) * 60 * 60),
35 | Healthy: nil,
36 | }
37 | orderSli = append(orderSli, orderObj)
38 | }
39 | provider := &Provider{
40 | PeerId: key,
41 | Addr: value[0].NodeIP,
42 | //Port: value[0].Port,
43 | IP: value[0].NodeIP,
44 | //Loc: "",
45 | //Colo: "",
46 | //Price: 0,
47 | Order: orderSli,
48 | }
49 | providers = append(providers, provider)
50 | }
51 | return
52 | }
53 |
--------------------------------------------------------------------------------
/fullnode/agent/client.go:
--------------------------------------------------------------------------------
1 | package agent
2 |
3 | import (
4 | "fmt"
5 | "runtime/debug"
6 | "time"
7 |
8 | "github.com/flowshield/flowshield/fullnode/app/v1/access/service"
9 |
10 | "github.com/flowshield/flowshield/fullnode/app/v1/access/model/mmysql"
11 |
12 | "github.com/flowshield/flowshield/fullnode/app/v1/access/dao/mysql"
13 | "github.com/flowshield/flowshield/fullnode/app/v1/access/model/mparam"
14 |
15 | "github.com/flowshield/flowshield/fullnode/pkg/logger"
16 | )
17 |
18 | // SyncClientOrderStatus 每30秒轮循10分钟内的订单,判断是否已支付
19 | func SyncClientOrderStatus() {
20 | closeChan := make(chan interface{}) // 信号监控
21 | go func() {
22 | for range closeChan {
23 | go handleClientOrderStatus(closeChan)
24 | }
25 | }()
26 | go handleClientOrderStatus(closeChan)
27 | }
28 |
29 | func handleClientOrderStatus(closeChan chan<- interface{}) {
30 | clientDao := mysql.NewClient(nil)
31 | defer func() {
32 | if err := recover(); err != nil {
33 | logger.Errorf(nil, "handleClientOrderStatus stacktrace from panic:\n"+string(debug.Stack()), fmt.Errorf("%v", err))
34 | }
35 | closeChan <- struct{}{}
36 | }()
37 | for {
38 | select {
39 | case <-time.After(time.Second * 30):
40 | clientList, err := clientDao.CheckStatusClient(&mparam.CheckStatus{
41 | Status: mmysql.WaitingPaid,
42 | Duration: 10,
43 | })
44 | if err != nil {
45 | continue
46 | }
47 | for _, value := range clientList {
48 | time.Sleep(5 * time.Second)
49 | service.NotifyClient(nil, &mparam.NotifyClient{UUID: value.UUID})
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/fullnode/app/v1/user/model/mapi/github.go:
--------------------------------------------------------------------------------
1 | package mapi
2 |
3 | type GithubUser struct {
4 | Login string `json:"login"`
5 | ID int `json:"id"`
6 | NodeID string `json:"node_id"`
7 | AvatarURL string `json:"avatar_url"`
8 | GravatarID string `json:"gravatar_id"`
9 | URL string `json:"url"`
10 | HtmlUrl string `json:"html_url"`
11 | FollowersURL string `json:"followers_url"`
12 | FollowingURL string `json:"following_url"`
13 | GistsURL string `json:"gists_url"`
14 | StarredURL string `json:"starred_url"`
15 | SubscriptionsURL string `json:"subscriptions_url"`
16 | OrganizationsURL string `json:"organizations_url"`
17 | ReposURL string `json:"repos_url"`
18 | EventsURL string `json:"events_url"`
19 | ReceivedEventsURL string `json:"received_events_url"`
20 | Type string `json:"type"`
21 | SiteAdmin bool `json:"site_admin"`
22 | Name string `json:"name"`
23 | Company string `json:"company"`
24 | Blog string `json:"blog"`
25 | Location string `json:"location"`
26 | Email string `json:"email"`
27 | Hireable bool `json:"hireable"`
28 | Bio string `json:"bio"`
29 | TwitterUserName string `json:"twitter_username"`
30 | PublicRepos int `json:"public_repos"`
31 | PublicGists int `json:"public_gits"`
32 | Followers int `json:"followers"`
33 | Following int `json:"following"`
34 | CreatedAt string `json:"created_at"`
35 | UpdatedAt string `json:"updated_at"`
36 | }
37 |
--------------------------------------------------------------------------------
/fullnode/pconst/api.go:
--------------------------------------------------------------------------------
1 | package pconst
2 |
3 | // Constants for API
4 | const (
5 | IAPIRoot = "/i"
6 | APPAPIRoot = "/app"
7 | APIAPIRoot = "/api"
8 | ADMINAPIRoot = "/admin"
9 | APIV1Version = "v1"
10 | APIV2Version = "v2"
11 | APIV3Version = "v3"
12 | APIV4Version = "v4"
13 | IAPIV1URL = IAPIRoot + "/" + APIV1Version
14 | IAPIV2URL = IAPIRoot + "/" + APIV2Version
15 | IAPIV3URL = IAPIRoot + "/" + APIV3Version
16 | IAPIV4URL = IAPIRoot + "/" + APIV4Version
17 | APPAPIV1URL = APPAPIRoot + "/" + APIV1Version
18 | APIAPIV1URL = APIAPIRoot + "/" + APIV1Version
19 | ADMINAPIV1URL = ADMINAPIRoot + "/" + APIV1Version
20 | APPAPIV2URL = APPAPIRoot + "/" + APIV2Version
21 | APIAPIV2URL = APIAPIRoot + "/" + APIV2Version
22 | //time
23 |
24 | TIME_FORMAT_Y_M_D_H_I_S_MS = "2006-01-02 15:04:05.000"
25 | TIME_FORMAT_Y_M_D_H_I_S = "2006-01-02 15:04:05"
26 | TIME_FORMAT_Y_M_D_H_I_S_2 = "2006/01/02 15:04:05"
27 | TIME_FORMAT_Y_M_D = "2006.01.02"
28 | TIME_FORMAT_Y_M_D_ = "2006-01-02"
29 | TIME_FORMAT_Y_MS_D_ = "2006-January-02"
30 | TIME_FORMAT_M_D_H_I = "01.02 15:04"
31 | TIME_FORMAT_H_I = "15:04"
32 |
33 | TIME_ONE_SECOND = 1
34 | TIME_TWO_SECOND = 2
35 | TIME_ONE_MINUTE = 60
36 | TIME_TEN_MINUTE = 600
37 | TIME_ONE_HOUR = 3600
38 | TIME_ONE_DAY = 86400
39 | TIME_THREE_DAY = 259200
40 | TIME_ONE_WEEK = 604800
41 | TIME_ONE_MONTH = 2592000
42 | TIME_ONE_YEAR = 31536000
43 |
44 | //common
45 |
46 | COMMON_PAGE_LIMIT_NUM_10 = 10
47 | COMMON_PAGE_LIMIT_NUM_20 = 20
48 | COMMON_PAGE_LIMIT_NUM_MAX = 20
49 |
50 | COMMON_ERROR_RETRY_LIMIT_NUM = 5
51 | )
52 |
--------------------------------------------------------------------------------
/portal/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 | Build a global web3 decentralized private retrieval network for data, building cyber sovereignty
21 | 22 |{{ getPemContent(item) }}
17 |