Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sidecar
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
sidecar
Commits
c6a9d55d
Commit
c6a9d55d
authored
Nov 16, 2021
by
suyanlong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add config information
parent
dec3580b
Pipeline
#8250
failed with stages
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
38 deletions
+67
-38
init.go
cmd/sidecar/init.go
+31
-5
p2p.go
cmd/sidecar/p2p.go
+12
-9
go.mod
go.mod
+5
-6
go.sum
go.sum
+0
-2
config.go
internal/repo/config.go
+16
-16
tool.go
tool/tool.go
+3
-0
No files found.
cmd/sidecar/init.go
View file @
c6a9d55d
...
...
@@ -6,6 +6,7 @@ import (
"os"
"path/filepath"
"github.com/BurntSushi/toml"
"github.com/urfave/cli"
"gitlab.33.cn/link33/sidecar/internal/repo"
...
...
@@ -21,17 +22,42 @@ var initCMD = cli.Command{
return
err
}
if
tool
.
Exist
(
filepath
.
Join
(
repoRoot
,
repo
.
ConfigName
))
{
path
:=
filepath
.
Join
(
repoRoot
,
repo
.
ConfigName
)
if
tool
.
Exist
(
path
)
{
fmt
.
Println
(
"sidecar configuration file already exists"
)
fmt
.
Println
(
"reinitializing would overwrite your configuration, Y/N?"
)
input
:=
bufio
.
NewScanner
(
os
.
Stdin
)
input
.
Scan
()
if
input
.
Text
()
==
"Y"
||
input
.
Text
()
==
"y"
{
return
repo
.
Initialize
(
repoRoot
)
err
=
repo
.
Initialize
(
repoRoot
)
}
return
nil
}
else
{
err
=
repo
.
Initialize
(
repoRoot
)
}
return
repo
.
Initialize
(
repoRoot
)
if
err
!=
nil
{
return
err
}
return
afterWork
(
ctx
,
path
)
},
}
func
afterWork
(
ctx
*
cli
.
Context
,
path
string
)
error
{
id
,
err
:=
LoadID
(
ctx
)
if
err
!=
nil
{
return
err
}
config
:=
&
repo
.
Config
{}
_
,
err
=
toml
.
DecodeFile
(
path
,
config
)
if
err
!=
nil
{
return
err
}
if
len
(
config
.
Peer
.
Peers
)
==
0
{
config
.
Peer
.
Peers
=
make
([]
string
,
1
)
}
config
.
Peer
.
Peers
[
0
]
=
fmt
.
Sprintf
(
"/ip4/127.0.0.1/tcp/4000/p2p/%s"
,
id
)
file
,
err
:=
os
.
OpenFile
(
path
,
os
.
O_RDWR
|
os
.
O_TRUNC
|
os
.
O_CREATE
,
os
.
FileMode
(
0766
))
if
err
!=
nil
{
return
err
}
return
toml
.
NewEncoder
(
file
)
.
Encode
(
config
)
}
cmd/sidecar/p2p.go
View file @
c6a9d55d
...
...
@@ -24,31 +24,34 @@ var p2pCMD = cli.Command{
}
func
p2pID
(
ctx
*
cli
.
Context
)
error
{
id
,
err
:=
LoadID
(
ctx
)
fmt
.
Println
(
id
)
return
err
}
func
LoadID
(
ctx
*
cli
.
Context
)
(
string
,
error
)
{
repoRoot
,
err
:=
repo
.
PathRootWithDefault
(
ctx
.
GlobalString
(
"repo"
))
if
err
!=
nil
{
return
err
return
""
,
err
}
privKey
,
err
:=
repo
.
LoadNodePrivateKey
(
repoRoot
)
if
err
!=
nil
{
return
err
return
""
,
err
}
stdKey
,
err
:=
asym
.
PrivKeyToStdKey
(
privKey
)
if
err
!=
nil
{
return
err
return
""
,
err
}
_
,
pk
,
err
:=
crypto2
.
KeyPairFromStdKey
(
&
stdKey
)
if
err
!=
nil
{
return
err
return
""
,
err
}
id
,
err
:=
peer
.
IDFromPublicKey
(
pk
)
if
err
!=
nil
{
return
err
return
""
,
err
}
fmt
.
Println
(
id
)
return
nil
return
id
.
String
(),
nil
}
go.mod
View file @
c6a9d55d
...
...
@@ -3,6 +3,7 @@ module gitlab.33.cn/link33/sidecar
go 1.17
require (
github.com/BurntSushi/toml v0.3.1
github.com/Rican7/retry v0.1.0
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
github.com/bits-and-blooms/bitset v1.2.1
...
...
@@ -29,8 +30,11 @@ require (
github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd
github.com/hashicorp/go-multierror v1.1.0
github.com/hashicorp/go-plugin v1.3.0
github.com/herumi/bls-eth-go-binary v0.0.0-20210917013441-d37c07cfda4e
github.com/huandu/skiplist v1.2.0
github.com/huandu/xstrings v1.3.2
github.com/hyperledger/fabric v2.0.1+incompatible
github.com/hyperledger/fabric-protos-go v0.0.0-20200330074707-cfe579e86986
github.com/imdario/mergo v0.3.12
github.com/ipfs/go-cid v0.0.7
github.com/jinzhu/copier v0.3.2
...
...
@@ -57,6 +61,7 @@ require (
github.com/urfave/cli v1.22.1
github.com/vmihailenco/msgpack/v5 v5.3.4
github.com/wangjia184/sortedset v0.0.0-20210325043434-64dd27e173e2
github.com/wasmerio/go-ext-wasm v0.3.1
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013
google.golang.org/grpc v1.33.1
)
...
...
@@ -81,11 +86,8 @@ require (
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect
github.com/herumi/bls-eth-go-binary v0.0.0-20210917013441-d37c07cfda4e // indirect
github.com/huin/goupnp v1.0.0 // indirect
github.com/hyperledger/fabric v2.0.1+incompatible // indirect
github.com/hyperledger/fabric-amcl v0.0.0-20200424173818-327c9e2cf77a // indirect
github.com/hyperledger/fabric-protos-go v0.0.0-20200330074707-cfe579e86986 // indirect
github.com/ipfs/go-datastore v0.4.4 // indirect
github.com/ipfs/go-ipfs-util v0.0.1 // indirect
github.com/ipfs/go-ipns v0.0.2 // indirect
...
...
@@ -140,7 +142,6 @@ require (
github.com/looplab/fsm v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/meshplus/bitxhub-model v1.2.1-0.20210524063354-5d48e2fee178 // indirect
github.com/miekg/pkcs11 v1.0.3 // indirect
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
github.com/minio/sha256-simd v0.1.1 // indirect
...
...
@@ -171,14 +172,12 @@ require (
github.com/spf13/jwalterweatherman v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/supranational/blst v0.3.6 // indirect
github.com/sykesm/zap-logfmt v0.0.3 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954 // indirect
github.com/tidwall/match v1.0.3 // indirect
github.com/tidwall/pretty v1.0.2 // indirect
github.com/ugorji/go/codec v1.1.7 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/wasmerio/go-ext-wasm v0.3.1 // indirect
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect
github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 // indirect
go.opencensus.io v0.22.3 // indirect
...
...
go.sum
View file @
c6a9d55d
...
...
@@ -937,8 +937,6 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/supranational/blst v0.3.6 h1:a24cPQB0qYpXPMZx177aapCM50/YrTMt/TKAUa7TzdM=
github.com/supranational/blst v0.3.6/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/sykesm/zap-logfmt v0.0.3 h1:3Wrhf7+I9JEUD8B6KPtDAr9j2jrS0/EPLy7GCE1t/+U=
github.com/sykesm/zap-logfmt v0.0.3/go.mod h1:AuBd9xQjAe3URrWT1BBDk2v2onAZHkZkWRMiYZXiZWA=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
...
...
internal/repo/config.go
View file @
c6a9d55d
...
...
@@ -110,22 +110,22 @@ func DefaultConfig() *Config {
Connectors
:
[]
string
{},
Providers
:
1
,
},
//Appchains: Appchains{
[]Appchain{
//
{
//
Enable: true,
//
Type: "appchain",
//
DID: "did:bitxhub:appchain:.",
//
Plugin: "appchain_plugin",
//
Config: "fabric",
//
},
//
{
//
Enable: true,
//
Type: "hub",
//
DID: "did:bitxhub:chain33:.",
//
Plugin: "appchain_plugin",
//
Config: "chain33",
//
},
//}
},
Appchains
:
[]
Appchain
{
{
Enable
:
true
,
Type
:
"appchain"
,
DID
:
"did:bitxhub:appchain:."
,
Plugin
:
"appchain_plugin"
,
Config
:
"fabric"
,
},
{
Enable
:
true
,
Type
:
"hub"
,
DID
:
"did:bitxhub:chain33:."
,
Plugin
:
"appchain_plugin"
,
Config
:
"chain33"
,
},
},
}
}
...
...
tool/tool.go
View file @
c6a9d55d
...
...
@@ -71,3 +71,6 @@ func Exist(path string) bool {
// https://github.com/golang/groupcache
// https://github.com/bluele/gcache
// https://github.com/goburrow/cache
//Scan git repos (or files) for secrets using regex and entropy 🔑
//https://github.com/zricethezav/gitleaks
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment