mirror of
https://github.com/number571/go-peer.git
synced 2026-09-14 11:05:42 +05:00
update
This commit is contained in:
parent
14b06d2721
commit
e2aaec4ade
@ -21,7 +21,8 @@ The `go-peer` library contains a large number of functions necessary to ensure t
|
||||
1. Go library (used by `pkg/storage/database`) [github.com/syndtr/goleveldb](https://github.com/syndtr/goleveldb "yndtr/goleveldb");
|
||||
2. Go library (used by `cmd/hidden_lake/messenger`) [github.com/boombuler/barcode](https://github.com/boombuler/barcode "boombuler/barcode");
|
||||
3. Go library (used by `cmd/hidden_lake/messenger`) [golang.org/x/net](https://golang.org/x/net "x/net");
|
||||
4. CSS/JS library (used by `cmd/hidden_lake/messenger`) [getbootstrap.com](https://getbootstrap.com "bootstrap")
|
||||
4. Go library (used by `cmd/hidden_lake/service`, `cmd/hidden_lake/messenger`) [github.com/fyne-io/fyne](https://github.com/fyne-io/fyne "fyne")
|
||||
5. CSS/JS library (used by `cmd/hidden_lake/messenger`) [getbootstrap.com](https://getbootstrap.com "bootstrap")
|
||||
|
||||
## Library based applications
|
||||
|
||||
|
||||
1
TODO.md
1
TODO.md
@ -5,3 +5,4 @@
|
||||
3. Write tests for coverage > 70%
|
||||
4. Develop union_blockchain
|
||||
5. Write linters (names with prefixes 'p', 'f', 's', 'i', 'c', 'g'), (objects with name=p)
|
||||
6. Create example with mobile
|
||||
|
||||
@ -39,19 +39,29 @@ func NewChain(sett ISettings, priv asymmetric.IPrivKey, genesis block.IBlock) (I
|
||||
return nil, fmt.Errorf("chain already exists")
|
||||
}
|
||||
|
||||
blocksDB, err := database.NewLevelDB(
|
||||
database.NewSettings(&database.SSettings{
|
||||
FPath: sett.GetBlocksPath(),
|
||||
}),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
transactionsDB, err := database.NewLevelDB(
|
||||
database.NewSettings(&database.SSettings{
|
||||
FPath: sett.GetTransactionsPath(),
|
||||
}),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
chain := &sChain{
|
||||
fSettings: sett,
|
||||
fPrivKey: priv,
|
||||
fBlocks: database.NewLevelDB(
|
||||
database.NewSettings(&database.SSettings{
|
||||
FPath: sett.GetBlocksPath(),
|
||||
}),
|
||||
),
|
||||
fTransactions: database.NewLevelDB(
|
||||
database.NewSettings(&database.SSettings{
|
||||
FPath: sett.GetTransactionsPath(),
|
||||
}),
|
||||
),
|
||||
fSettings: sett,
|
||||
fPrivKey: priv,
|
||||
fBlocks: blocksDB,
|
||||
fTransactions: transactionsDB,
|
||||
fMempool: mempool.NewMempool(
|
||||
sett.GetMempoolSettings(),
|
||||
sett.GetMempoolPath(),
|
||||
@ -81,19 +91,29 @@ func LoadChain(sett ISettings, priv asymmetric.IPrivKey) (IChain, error) {
|
||||
return nil, fmt.Errorf("chain not exists")
|
||||
}
|
||||
|
||||
blocksDB, err := database.NewLevelDB(
|
||||
database.NewSettings(&database.SSettings{
|
||||
FPath: sett.GetBlocksPath(),
|
||||
}),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
transactionsDB, err := database.NewLevelDB(
|
||||
database.NewSettings(&database.SSettings{
|
||||
FPath: sett.GetTransactionsPath(),
|
||||
}),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
chain := &sChain{
|
||||
fSettings: sett,
|
||||
fPrivKey: priv,
|
||||
fBlocks: database.NewLevelDB(
|
||||
database.NewSettings(&database.SSettings{
|
||||
FPath: sett.GetBlocksPath(),
|
||||
}),
|
||||
),
|
||||
fTransactions: database.NewLevelDB(
|
||||
database.NewSettings(&database.SSettings{
|
||||
FPath: sett.GetTransactionsPath(),
|
||||
}),
|
||||
),
|
||||
fSettings: sett,
|
||||
fPrivKey: priv,
|
||||
fBlocks: blocksDB,
|
||||
fTransactions: transactionsDB,
|
||||
fMempool: mempool.NewMempool(
|
||||
sett.GetMempoolSettings(),
|
||||
sett.GetMempoolPath(),
|
||||
@ -20,16 +20,20 @@ type sMempool struct {
|
||||
}
|
||||
|
||||
func NewMempool(sett ISettings, path string) IMempool {
|
||||
db, err := database.NewLevelDB(
|
||||
database.NewSettings(&database.SSettings{
|
||||
FPath: path,
|
||||
}),
|
||||
)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
mempool := &sMempool{
|
||||
fSettings: sett,
|
||||
fDB: database.NewLevelDB(
|
||||
database.NewSettings(&database.SSettings{
|
||||
FPath: path,
|
||||
}),
|
||||
),
|
||||
fDB: db,
|
||||
}
|
||||
_, err := mempool.fDB.Get(getKeyHeight())
|
||||
if err != nil {
|
||||
if _, err := mempool.fDB.Get(getKeyHeight()); err != nil {
|
||||
res := encoding.Uint64ToBytes(0)
|
||||
err := mempool.fDB.Set(getKeyHeight(), res[:])
|
||||
if err != nil {
|
||||
@ -75,23 +79,24 @@ func (mempool *sMempool) Clear() {
|
||||
mempool.fMutex.Lock()
|
||||
defer mempool.fMutex.Unlock()
|
||||
|
||||
iter := mempool.fDB.GetIterator([]byte(cPrefix))
|
||||
defer iter.Close()
|
||||
// TODO:
|
||||
// iter := mempool.fDB.GetIterator([]byte(cPrefix))
|
||||
// defer iter.Close()
|
||||
|
||||
// TODO: iter.Key without load transaction
|
||||
for iter.Next() {
|
||||
txBytes := iter.GetValue()
|
||||
// // TODO: iter.Key without load transaction
|
||||
// for iter.Next() {
|
||||
// txBytes := iter.GetValue()
|
||||
|
||||
tx := transaction.LoadTransaction(
|
||||
mempool.fSettings.GetBlockSettings().GetTransactionSettings(),
|
||||
txBytes,
|
||||
)
|
||||
if tx == nil {
|
||||
panic("mempool: tx is nil")
|
||||
}
|
||||
// tx := transaction.LoadTransaction(
|
||||
// mempool.fSettings.GetBlockSettings().GetTransactionSettings(),
|
||||
// txBytes,
|
||||
// )
|
||||
// if tx == nil {
|
||||
// panic("mempool: tx is nil")
|
||||
// }
|
||||
|
||||
mempool.deleteTX(tx.Hash())
|
||||
}
|
||||
// mempool.deleteTX(tx.Hash())
|
||||
// }
|
||||
}
|
||||
|
||||
func (mempool *sMempool) Push(tx transaction.ITransaction) {
|
||||
@ -126,43 +131,46 @@ func (mempool *sMempool) Pop() []transaction.ITransaction {
|
||||
mempool.fMutex.Lock()
|
||||
defer mempool.fMutex.Unlock()
|
||||
|
||||
// count of tx need be = block size
|
||||
blockCountTXs := mempool.fSettings.GetBlockSettings().GetCountTXs()
|
||||
if mempool.getHeight() < blockCountTXs {
|
||||
return nil
|
||||
}
|
||||
// TODO:
|
||||
// // count of tx need be = block size
|
||||
// blockCountTXs := mempool.fSettings.GetBlockSettings().GetCountTXs()
|
||||
// if mempool.getHeight() < blockCountTXs {
|
||||
// return nil
|
||||
// }
|
||||
|
||||
var (
|
||||
txs []transaction.ITransaction
|
||||
count uint64
|
||||
)
|
||||
// var (
|
||||
// txs []transaction.ITransaction
|
||||
// count uint64
|
||||
// )
|
||||
|
||||
iter := mempool.fDB.GetIterator([]byte(cPrefix))
|
||||
defer iter.Close()
|
||||
// iter := mempool.fDB.GetIterator([]byte(cPrefix))
|
||||
// defer iter.Close()
|
||||
|
||||
for count = 0; iter.Next() && count < blockCountTXs; count++ {
|
||||
txBytes := iter.GetValue()
|
||||
// for count = 0; iter.Next() && count < blockCountTXs; count++ {
|
||||
// txBytes := iter.GetValue()
|
||||
|
||||
tx := transaction.LoadTransaction(
|
||||
mempool.fSettings.GetBlockSettings().GetTransactionSettings(),
|
||||
txBytes,
|
||||
)
|
||||
if tx == nil {
|
||||
return nil
|
||||
}
|
||||
// tx := transaction.LoadTransaction(
|
||||
// mempool.fSettings.GetBlockSettings().GetTransactionSettings(),
|
||||
// txBytes,
|
||||
// )
|
||||
// if tx == nil {
|
||||
// return nil
|
||||
// }
|
||||
|
||||
txs = append(txs, tx)
|
||||
}
|
||||
// txs = append(txs, tx)
|
||||
// }
|
||||
|
||||
if count != blockCountTXs {
|
||||
panic("count != settings.CSizeTrns")
|
||||
}
|
||||
// if count != blockCountTXs {
|
||||
// panic("count != settings.CSizeTrns")
|
||||
// }
|
||||
|
||||
for _, tx := range txs {
|
||||
mempool.deleteTX(tx.Hash())
|
||||
}
|
||||
// for _, tx := range txs {
|
||||
// mempool.deleteTX(tx.Hash())
|
||||
// }
|
||||
|
||||
return txs
|
||||
// return txs
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mempool *sMempool) getHeight() uint64 {
|
||||
@ -26,11 +26,15 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
db = database.NewLevelDB(
|
||||
var err error
|
||||
db, err = database.NewSQLiteDB(
|
||||
database.NewSettings(&database.SSettings{
|
||||
FPath: databasePath,
|
||||
}),
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if _, err := db.Get([]byte(dataCountKey)); err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
@ -8,4 +8,4 @@ run:
|
||||
./$(BINPATH)/service
|
||||
clean:
|
||||
rm -f $(BINPATH)/common_service
|
||||
rm -rf $(BINPATH)/common_service.db
|
||||
rm -rf common_service.db
|
||||
|
||||
@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
databasePath = "service.db"
|
||||
databasePath = "common_service.db"
|
||||
dataCountKey = "count_service"
|
||||
)
|
||||
|
||||
@ -23,21 +23,27 @@ var (
|
||||
db database.IKeyValueDB
|
||||
)
|
||||
|
||||
func init() {
|
||||
db = database.NewLevelDB(
|
||||
func initDB() database.IKeyValueDB {
|
||||
var err error
|
||||
db, err = database.NewSQLiteDB(
|
||||
database.NewSettings(&database.SSettings{
|
||||
FPath: databasePath,
|
||||
}),
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if _, err := db.Get([]byte(dataCountKey)); err == nil {
|
||||
return
|
||||
return db
|
||||
}
|
||||
if err := db.Set([]byte(dataCountKey), []byte("0")); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return db
|
||||
}
|
||||
|
||||
func main() {
|
||||
db := initDB()
|
||||
defer db.Close()
|
||||
|
||||
if len(os.Args) != 2 {
|
||||
|
||||
@ -23,7 +23,7 @@ func initApp(path string) (types.ICommand, types.ICommand, error) {
|
||||
cfgHLS, err := hls_config.InitConfig(
|
||||
fmt.Sprintf("%s/%s", path, hls_settings.CPathCFG),
|
||||
&hls_config.SConfig{
|
||||
FNetwork: "android_" + hls_settings.CServiceName,
|
||||
FNetwork: "mobile_" + hls_settings.CServiceName,
|
||||
FAddress: &hls_config.SAddress{
|
||||
FTCP: "localhost:9571",
|
||||
FHTTP: "localhost:9572",
|
||||
@ -40,7 +40,7 @@ func initApp(path string) (types.ICommand, types.ICommand, error) {
|
||||
cfgHLM, err := config.InitConfig(
|
||||
fmt.Sprintf("%s/%s", path, settings.CPathCFG),
|
||||
&config.SConfig{
|
||||
FStorageKey: "android_" + settings.CServiceName,
|
||||
FStorageKey: "mobile_" + settings.CServiceName,
|
||||
FAddress: &config.SAddress{
|
||||
FInterface: "localhost:9591",
|
||||
FIncoming: "localhost:9592",
|
||||
|
||||
@ -14,13 +14,16 @@ type sKeyValueDB struct {
|
||||
}
|
||||
|
||||
func NewKeyValueDB(pPath string, pKey []byte) IKeyValueDB {
|
||||
db := gp_database.NewLevelDB(
|
||||
db, err := gp_database.NewSQLiteDB(
|
||||
gp_database.NewSettings(&gp_database.SSettings{
|
||||
FPath: pPath,
|
||||
FHashing: true,
|
||||
FCipherKey: pKey,
|
||||
}),
|
||||
)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return &sKeyValueDB{
|
||||
fDB: &db,
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ func initApp(path string) (types.ICommand, error) {
|
||||
cfg, err := pkg_config.InitConfig(
|
||||
fmt.Sprintf("%s/%s", path, pkg_settings.CPathCFG),
|
||||
&pkg_config.SConfig{
|
||||
FNetwork: "android_" + pkg_settings.CServiceName,
|
||||
FNetwork: "mobile_" + pkg_settings.CServiceName,
|
||||
FAddress: &pkg_config.SAddress{
|
||||
FTCP: "localhost:9571",
|
||||
FHTTP: "localhost:9572",
|
||||
|
||||
@ -67,13 +67,18 @@ func (p *sApp) Run() error {
|
||||
}
|
||||
p.fIsRun = true
|
||||
|
||||
res := make(chan error)
|
||||
p.fNode.GetWrapperDB().Set(database.NewLevelDB(
|
||||
db, err := database.NewSQLiteDB(
|
||||
database.NewSettings(&database.SSettings{
|
||||
FPath: fmt.Sprintf("%s/%s", p.fPathTo, pkg_settings.CPathDB),
|
||||
FHashing: true,
|
||||
}),
|
||||
))
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
res := make(chan error)
|
||||
p.fNode.GetWrapperDB().Set(db)
|
||||
|
||||
go func() {
|
||||
if p.fConfig.GetAddress().GetHTTP() == "" {
|
||||
|
||||
@ -42,7 +42,7 @@ func TestApp(t *testing.T) {
|
||||
}
|
||||
|
||||
privKey := asymmetric.LoadRSAPrivKey(testutils.TcPrivKey)
|
||||
app := NewApp(cfg, privKey, "")
|
||||
app := NewApp(cfg, privKey, ".")
|
||||
if err := app.Run(); err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
|
||||
@ -19,17 +19,20 @@ type sKeyValueDB struct {
|
||||
}
|
||||
|
||||
func NewKeyValueDB(pSett ISettings) IKeyValueDB {
|
||||
levelDB := gp_database.NewLevelDB(
|
||||
sqlDB, err := gp_database.NewSQLiteDB(
|
||||
gp_database.NewSettings(&gp_database.SSettings{
|
||||
FPath: pSett.GetPath(),
|
||||
}),
|
||||
)
|
||||
if levelDB == nil {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if sqlDB == nil {
|
||||
panic("storage (hashes) is nil")
|
||||
}
|
||||
db := &sKeyValueDB{
|
||||
fSettings: pSett,
|
||||
fDB: levelDB,
|
||||
fDB: sqlDB,
|
||||
}
|
||||
db.fPointer = db.getPointer()
|
||||
return db
|
||||
|
||||
@ -4,3 +4,4 @@ clean:
|
||||
make -C ./anon_messenger clean
|
||||
make -C ./echo_service clean
|
||||
make -C ./traffic_keeper clean
|
||||
make -C ./mobile_app clean
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
.PHONY: default build run
|
||||
# https://github.com/fyne-io/fyne
|
||||
.PHONY: default build run clean
|
||||
default: build run
|
||||
build:
|
||||
fyne package -os android -appID my.domain.appname -icon icon.png
|
||||
run:
|
||||
fyne install -os android -appID my.domain.appname -icon icon.png
|
||||
clean:
|
||||
rm -f mobile_app.apk
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"github.com/number571/go-peer/pkg/payload"
|
||||
)
|
||||
|
||||
// TODO!!!
|
||||
func main() {
|
||||
var (
|
||||
client1 = newClient()
|
||||
|
||||
@ -14,6 +14,7 @@ const (
|
||||
payloadHead = 0x1
|
||||
)
|
||||
|
||||
// TODO!!!
|
||||
func main() {
|
||||
q := queue.NewMessageQueue(
|
||||
queue.NewSettings(&queue.SSettings{
|
||||
|
||||
@ -31,6 +31,7 @@ func deleteDBs() {
|
||||
os.RemoveAll(dbPath2)
|
||||
}
|
||||
|
||||
// TODO!!!
|
||||
func main() {
|
||||
deleteDBs()
|
||||
defer deleteDBs()
|
||||
@ -73,12 +74,16 @@ func main() {
|
||||
}
|
||||
|
||||
func newNode(dbPath string) anonymity.INode {
|
||||
db, err := database.NewSQLiteDB(
|
||||
database.NewSettings(&database.SSettings{FPath: dbPath}),
|
||||
)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return anonymity.NewNode(
|
||||
anonymity.NewSettings(&anonymity.SSettings{}),
|
||||
logger.NewLogger(logger.NewSettings(&logger.SSettings{})),
|
||||
database.NewLevelDB(
|
||||
database.NewSettings(&database.SSettings{FPath: dbPath}),
|
||||
),
|
||||
db,
|
||||
network.NewNode(
|
||||
network.NewSettings(&network.SSettings{
|
||||
FConnSettings: conn.NewSettings(&conn.SSettings{}),
|
||||
|
||||
@ -9,7 +9,6 @@ import (
|
||||
"github.com/number571/go-peer/pkg/client"
|
||||
"github.com/number571/go-peer/pkg/client/queue"
|
||||
"github.com/number571/go-peer/pkg/crypto/asymmetric"
|
||||
"github.com/number571/go-peer/pkg/friends"
|
||||
"github.com/number571/go-peer/pkg/logger"
|
||||
"github.com/number571/go-peer/pkg/network"
|
||||
"github.com/number571/go-peer/pkg/network/anonymity"
|
||||
@ -32,6 +31,7 @@ func deleteDBs() {
|
||||
os.RemoveAll(dbPath2)
|
||||
}
|
||||
|
||||
// TODO!!!
|
||||
func main() {
|
||||
deleteDBs()
|
||||
defer deleteDBs()
|
||||
@ -41,11 +41,11 @@ func main() {
|
||||
service2 = newNode(dbPath2)
|
||||
)
|
||||
|
||||
service1.Handle(serviceHeader, handler("#1"))
|
||||
service2.Handle(serviceHeader, handler("#2"))
|
||||
service1.HandleFunc(serviceHeader, handler("#1"))
|
||||
service2.HandleFunc(serviceHeader, handler("#2"))
|
||||
|
||||
service1.F2F().Append(service2.Queue().Client().PubKey())
|
||||
service2.F2F().Append(service1.Queue().Client().PubKey())
|
||||
service1.GetListPubKeys().AddPubKey(service2.GetMessageQueue().GetClient().GetPubKey())
|
||||
service2.GetListPubKeys().AddPubKey(service1.GetMessageQueue().GetClient().GetPubKey())
|
||||
|
||||
if err := service1.Run(); err != nil {
|
||||
panic(err)
|
||||
@ -55,7 +55,7 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
go service1.Network().Listen(serviceAddress)
|
||||
go service1.GetNetworkNode().Listen(serviceAddress)
|
||||
time.Sleep(time.Second)
|
||||
|
||||
if _, err := service2.Network().Connect(serviceAddress); err != nil {
|
||||
@ -105,12 +105,16 @@ func handler(serviceName string) anonymity.IHandlerF {
|
||||
}
|
||||
|
||||
func newNode(dbPath string) anonymity.INode {
|
||||
db, err := database.NewSQLiteDB(
|
||||
database.NewSettings(&database.SSettings{FPath: dbPath}),
|
||||
)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return anonymity.NewNode(
|
||||
anonymity.NewSettings(&anonymity.SSettings{}),
|
||||
logger.NewLogger(logger.NewSettings(&logger.SSettings{})),
|
||||
database.NewLevelDB(
|
||||
database.NewSettings(&database.SSettings{FPath: dbPath}),
|
||||
),
|
||||
db,
|
||||
network.NewNode(
|
||||
network.NewSettings(&network.SSettings{
|
||||
FConnSettings: conn.NewSettings(&conn.SSettings{}),
|
||||
@ -123,6 +127,6 @@ func newNode(dbPath string) anonymity.INode {
|
||||
asymmetric.NewRSAPrivKey(1024),
|
||||
),
|
||||
),
|
||||
friends.NewF2F(),
|
||||
asymmetric.NewListPubKeys(),
|
||||
)
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ const (
|
||||
serviceAddress = ":8080"
|
||||
)
|
||||
|
||||
// TODO!!!
|
||||
// client <-> service1 <-> service2
|
||||
func main() {
|
||||
var (
|
||||
|
||||
@ -14,6 +14,7 @@ const (
|
||||
serviceAddress = ":8080"
|
||||
)
|
||||
|
||||
// TODO!!!
|
||||
func main() {
|
||||
service := network.NewNode(network.NewSettings(&network.SSettings{}))
|
||||
service.Handle(serviceHeader, func(n network.INode, c conn.IConn, reqBytes []byte) {
|
||||
|
||||
1
go.mod
1
go.mod
@ -26,6 +26,7 @@ require (
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
|
||||
github.com/gopherjs/gopherjs v1.17.2 // indirect
|
||||
github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.16 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/srwiley/oksvg v0.0.0-20220731023508-a61f04f16b76 // indirect
|
||||
github.com/srwiley/rasterx v0.0.0-20210519020934-456a8d69b780 // indirect
|
||||
|
||||
2
go.sum
2
go.sum
@ -227,6 +227,8 @@ github.com/lucor/goinfo v0.0.0-20210802170112-c078a2b0f08b/go.mod h1:PRq09yoB+Q2
|
||||
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||
github.com/mcuadros/go-version v0.0.0-20190830083331-035f6764e8d2/go.mod h1:76rfSfYPWj01Z85hUf/ituArm797mNKcvINh1OlsZKo=
|
||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
|
||||
@ -134,19 +134,23 @@ func testNewNodes(t *testing.T, timeWait time.Duration) [5]INode {
|
||||
}
|
||||
|
||||
func testNewNode(i int, timeWait time.Duration, addr string) INode {
|
||||
db, err := database.NewSQLiteDB(
|
||||
database.NewSettings(&database.SSettings{
|
||||
FPath: fmt.Sprintf(tcPathDBTemplate, i),
|
||||
FHashing: true,
|
||||
FCipherKey: []byte(testutils.TcKey1),
|
||||
}),
|
||||
)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
node := NewNode(
|
||||
NewSettings(&SSettings{
|
||||
FRetryEnqueue: 0,
|
||||
FTimeWait: timeWait,
|
||||
}),
|
||||
logger.NewLogger(logger.NewSettings(&logger.SSettings{})),
|
||||
NewWrapperDB().Set(database.NewLevelDB(
|
||||
database.NewSettings(&database.SSettings{
|
||||
FPath: fmt.Sprintf(tcPathDBTemplate, i),
|
||||
FHashing: true,
|
||||
FCipherKey: []byte(testutils.TcKey1),
|
||||
}),
|
||||
)),
|
||||
NewWrapperDB().Set(db),
|
||||
network.NewNode(
|
||||
network.NewSettings(&network.SSettings{
|
||||
FAddress: addr,
|
||||
|
||||
@ -11,31 +11,56 @@ import (
|
||||
testutils "github.com/number571/go-peer/test/_data"
|
||||
)
|
||||
|
||||
const (
|
||||
tcPathDBTemplate = "database_test_%d.db"
|
||||
countOfIter = 10
|
||||
type (
|
||||
tiDBConsctruct func(ISettings) (IKeyValueDB, error)
|
||||
)
|
||||
|
||||
func TestFailCreateLevelDB(t *testing.T) {
|
||||
const (
|
||||
tcPathDBTemplate = "database_test_%d.db"
|
||||
)
|
||||
|
||||
func TestAllDBs(t *testing.T) {
|
||||
testFailCreate(t, NewLevelDB)
|
||||
testFailCreate(t, NewSQLiteDB)
|
||||
|
||||
testCreate(t, NewLevelDB)
|
||||
testCreate(t, NewSQLiteDB)
|
||||
|
||||
testCipherKey(t, NewLevelDB)
|
||||
testCipherKey(t, NewSQLiteDB)
|
||||
|
||||
testBasic(t, NewLevelDB)
|
||||
testBasic(t, NewSQLiteDB)
|
||||
}
|
||||
|
||||
func testFailCreate(t *testing.T, dbConstruct tiDBConsctruct) {
|
||||
dbPath := fmt.Sprintf(
|
||||
"/fail_test_random/%s/111/222/333",
|
||||
random.NewStdPRNG().GetString(16),
|
||||
)
|
||||
defer os.RemoveAll(dbPath)
|
||||
|
||||
store := NewLevelDB(NewSettings(&SSettings{
|
||||
store, err := dbConstruct(NewSettings(&SSettings{
|
||||
FPath: dbPath,
|
||||
}))
|
||||
if err == nil {
|
||||
t.Errorf("incorrect: error is nil")
|
||||
return
|
||||
}
|
||||
if store != nil {
|
||||
t.Errorf("this path '%s' realy exists?", dbPath)
|
||||
store.Close()
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateLevelDB(t *testing.T) {
|
||||
func testCreate(t *testing.T, dbConstruct tiDBConsctruct) {
|
||||
defer os.RemoveAll(cPath)
|
||||
|
||||
store := NewLevelDB(NewSettings(&SSettings{}))
|
||||
store, err := dbConstruct(NewSettings(&SSettings{}))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
defer store.Close()
|
||||
|
||||
if !bytes.Equal(store.GetSettings().GetCipherKey(), []byte(cCipherKey)) {
|
||||
@ -54,25 +79,33 @@ func TestCreateLevelDB(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCipherKeyLevelDB(t *testing.T) {
|
||||
dbPath := fmt.Sprintf(tcPathDBTemplate, 3)
|
||||
func testCipherKey(t *testing.T, dbConstruct tiDBConsctruct) {
|
||||
dbPath := fmt.Sprintf(tcPathDBTemplate, 2)
|
||||
defer os.RemoveAll(dbPath)
|
||||
|
||||
store := NewLevelDB(NewSettings(&SSettings{
|
||||
store, err := dbConstruct(NewSettings(&SSettings{
|
||||
FPath: dbPath,
|
||||
FHashing: true,
|
||||
FCipherKey: []byte(testutils.TcKey1),
|
||||
}))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
defer store.Close()
|
||||
|
||||
store.Set([]byte(testutils.TcKey2), []byte(testutils.TcKey3))
|
||||
|
||||
store.Close() // open this database with another key
|
||||
store = NewLevelDB(NewSettings(&SSettings{
|
||||
store, err = dbConstruct(NewSettings(&SSettings{
|
||||
FPath: dbPath,
|
||||
FHashing: true,
|
||||
FCipherKey: []byte(testutils.TcKey2),
|
||||
}))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
defer store.Close()
|
||||
|
||||
if _, err := store.Get([]byte(testutils.TcKey2)); err == nil {
|
||||
@ -81,15 +114,19 @@ func TestCipherKeyLevelDB(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLevelDB(t *testing.T) {
|
||||
dbPath := fmt.Sprintf(tcPathDBTemplate, 2)
|
||||
func testBasic(t *testing.T, dbConstruct tiDBConsctruct) {
|
||||
dbPath := fmt.Sprintf(tcPathDBTemplate, 1)
|
||||
defer os.RemoveAll(dbPath)
|
||||
|
||||
store := NewLevelDB(NewSettings(&SSettings{
|
||||
store, err := dbConstruct(NewSettings(&SSettings{
|
||||
FPath: dbPath,
|
||||
FHashing: true,
|
||||
FCipherKey: []byte(testutils.TcKey1),
|
||||
}))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
defer store.Close()
|
||||
|
||||
secret1 := asymmetric.NewRSAPrivKey(512).ToBytes()
|
||||
@ -112,59 +149,8 @@ func TestLevelDB(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
iter := store.GetIterator([]byte("_value"))
|
||||
if iter != nil {
|
||||
t.Error("iter is not null with hashing=true")
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := store.Get([]byte("undefined key")); err == nil {
|
||||
t.Error("got value by undefined key")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func TestLevelDBIter(t *testing.T) {
|
||||
dbPath := fmt.Sprintf(tcPathDBTemplate, 1)
|
||||
defer os.RemoveAll(dbPath)
|
||||
|
||||
store := NewLevelDB(NewSettings(&SSettings{
|
||||
FPath: dbPath,
|
||||
FHashing: false,
|
||||
FCipherKey: []byte(testutils.TcKey1),
|
||||
}))
|
||||
defer store.Close()
|
||||
|
||||
for i := 0; i < countOfIter; i++ {
|
||||
err := store.Set(
|
||||
[]byte(fmt.Sprintf("%s%d", testutils.TcKey2, i)),
|
||||
[]byte(fmt.Sprintf("%s%d", testutils.TcVal1, i)),
|
||||
)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
count := 0
|
||||
iter := store.GetIterator([]byte(testutils.TcKey2))
|
||||
defer iter.Close()
|
||||
|
||||
for iter.Next() {
|
||||
if !bytes.Equal([]byte(fmt.Sprintf("%s%d", testutils.TcKey2, count)), iter.GetKey()) {
|
||||
t.Error("key not equal saved key")
|
||||
return
|
||||
}
|
||||
val := string(iter.GetValue())
|
||||
if val != fmt.Sprintf("%s%d", testutils.TcVal1, count) {
|
||||
t.Error("value not equal saved value")
|
||||
return
|
||||
}
|
||||
count++
|
||||
}
|
||||
|
||||
if count != countOfIter {
|
||||
t.Error("count not equal count of iter")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
45
pkg/storage/database/encrypt.go
Normal file
45
pkg/storage/database/encrypt.go
Normal file
@ -0,0 +1,45 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"github.com/number571/go-peer/pkg/crypto/hashing"
|
||||
"github.com/number571/go-peer/pkg/crypto/symmetric"
|
||||
)
|
||||
|
||||
func doEncrypt(pCipher symmetric.ICipher, pDataBytes []byte) []byte {
|
||||
return bytes.Join(
|
||||
[][]byte{
|
||||
hashing.NewHMACSHA256Hasher(
|
||||
pCipher.ToBytes(),
|
||||
pDataBytes,
|
||||
).ToBytes(),
|
||||
pCipher.EncryptBytes(pDataBytes),
|
||||
},
|
||||
[]byte{},
|
||||
)
|
||||
}
|
||||
|
||||
func tryDecrypt(pCipher symmetric.ICipher, pEncBytes []byte) ([]byte, error) {
|
||||
if len(pEncBytes) < hashing.CSHA256Size+symmetric.CAESBlockSize {
|
||||
return nil, fmt.Errorf("incorrect size of encrypted data")
|
||||
}
|
||||
|
||||
decBytes := pCipher.DecryptBytes(pEncBytes[hashing.CSHA256Size:])
|
||||
if decBytes == nil {
|
||||
return nil, fmt.Errorf("failed decrypt message")
|
||||
}
|
||||
|
||||
gotHashed := pEncBytes[:hashing.CSHA256Size]
|
||||
newHashed := hashing.NewHMACSHA256Hasher(
|
||||
pCipher.ToBytes(),
|
||||
decBytes,
|
||||
).ToBytes()
|
||||
|
||||
if !bytes.Equal(gotHashed, newHashed) {
|
||||
return nil, fmt.Errorf("incorrect hash of decrypted data")
|
||||
}
|
||||
|
||||
return decBytes, nil
|
||||
}
|
||||
@ -2,20 +2,16 @@ package database
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/number571/go-peer/pkg/crypto/hashing"
|
||||
"github.com/number571/go-peer/pkg/crypto/random"
|
||||
"github.com/number571/go-peer/pkg/crypto/symmetric"
|
||||
"github.com/syndtr/goleveldb/leveldb"
|
||||
"github.com/syndtr/goleveldb/leveldb/iterator"
|
||||
"github.com/syndtr/goleveldb/leveldb/util"
|
||||
)
|
||||
|
||||
var (
|
||||
_ IKeyValueDB = &sLevelDB{}
|
||||
_ IIterator = &sLevelDBIterator{}
|
||||
)
|
||||
|
||||
type sLevelDB struct {
|
||||
@ -26,22 +22,16 @@ type sLevelDB struct {
|
||||
fCipher symmetric.ICipher
|
||||
}
|
||||
|
||||
type sLevelDBIterator struct {
|
||||
fMutex sync.Mutex
|
||||
fIter iterator.Iterator
|
||||
fCipher symmetric.ICipher
|
||||
}
|
||||
|
||||
func NewLevelDB(pSett ISettings) IKeyValueDB {
|
||||
func NewLevelDB(pSett ISettings) (IKeyValueDB, error) {
|
||||
db, err := leveldb.OpenFile(pSett.GetPath(), nil)
|
||||
if err != nil {
|
||||
return nil
|
||||
return nil, err
|
||||
}
|
||||
salt, err := db.Get(pSett.GetSaltKey(), nil)
|
||||
if err != nil {
|
||||
salt = random.NewStdPRNG().GetBytes(symmetric.CAESKeySize)
|
||||
if err := db.Put(pSett.GetSaltKey(), salt, nil); err != nil {
|
||||
return nil
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return &sLevelDB{
|
||||
@ -49,7 +39,7 @@ func NewLevelDB(pSett ISettings) IKeyValueDB {
|
||||
fDB: db,
|
||||
fSettings: pSett,
|
||||
fCipher: symmetric.NewAESCipher(pSett.GetCipherKey()),
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *sLevelDB) GetSettings() ISettings {
|
||||
@ -96,93 +86,6 @@ func (p *sLevelDB) Close() error {
|
||||
return p.fDB.Close()
|
||||
}
|
||||
|
||||
// Storage in hashing mode can't iterates
|
||||
func (p *sLevelDB) GetIterator(pPrefix []byte) IIterator {
|
||||
p.fMutex.Lock()
|
||||
defer p.fMutex.Unlock()
|
||||
|
||||
if p.fSettings.GetHashing() {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &sLevelDBIterator{
|
||||
fIter: p.fDB.NewIterator(util.BytesPrefix(pPrefix), nil),
|
||||
fCipher: p.fCipher,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *sLevelDBIterator) Next() bool {
|
||||
p.fMutex.Lock()
|
||||
defer p.fMutex.Unlock()
|
||||
|
||||
return p.fIter.Next()
|
||||
}
|
||||
|
||||
func (p *sLevelDBIterator) GetKey() []byte {
|
||||
p.fMutex.Lock()
|
||||
defer p.fMutex.Unlock()
|
||||
|
||||
return p.fIter.Key()
|
||||
}
|
||||
|
||||
func (p *sLevelDBIterator) GetValue() []byte {
|
||||
p.fMutex.Lock()
|
||||
defer p.fMutex.Unlock()
|
||||
|
||||
decBytes, err := tryDecrypt(
|
||||
p.fCipher,
|
||||
p.fIter.Value(),
|
||||
)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return decBytes
|
||||
}
|
||||
|
||||
func (p *sLevelDBIterator) Close() error {
|
||||
p.fMutex.Lock()
|
||||
defer p.fMutex.Unlock()
|
||||
|
||||
p.fIter.Release()
|
||||
return nil
|
||||
}
|
||||
|
||||
func doEncrypt(pCipher symmetric.ICipher, pDataBytes []byte) []byte {
|
||||
return bytes.Join(
|
||||
[][]byte{
|
||||
hashing.NewHMACSHA256Hasher(
|
||||
pCipher.ToBytes(),
|
||||
pDataBytes,
|
||||
).ToBytes(),
|
||||
pCipher.EncryptBytes(pDataBytes),
|
||||
},
|
||||
[]byte{},
|
||||
)
|
||||
}
|
||||
|
||||
func tryDecrypt(pCipher symmetric.ICipher, pEncBytes []byte) ([]byte, error) {
|
||||
if len(pEncBytes) < hashing.CSHA256Size+symmetric.CAESBlockSize {
|
||||
return nil, fmt.Errorf("incorrect size of encrypted data")
|
||||
}
|
||||
|
||||
decBytes := pCipher.DecryptBytes(pEncBytes[hashing.CSHA256Size:])
|
||||
if decBytes == nil {
|
||||
return nil, fmt.Errorf("failed decrypt message")
|
||||
}
|
||||
|
||||
gotHashed := pEncBytes[:hashing.CSHA256Size]
|
||||
newHashed := hashing.NewHMACSHA256Hasher(
|
||||
pCipher.ToBytes(),
|
||||
decBytes,
|
||||
).ToBytes()
|
||||
|
||||
if !bytes.Equal(gotHashed, newHashed) {
|
||||
return nil, fmt.Errorf("incorrect hash of decrypted data")
|
||||
}
|
||||
|
||||
return decBytes, nil
|
||||
}
|
||||
|
||||
func (p *sLevelDB) tryHash(pKey []byte) []byte {
|
||||
if !p.fSettings.GetHashing() {
|
||||
return pKey
|
||||
|
||||
129
pkg/storage/database/sqlite.go
Normal file
129
pkg/storage/database/sqlite.go
Normal file
@ -0,0 +1,129 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"database/sql"
|
||||
"sync"
|
||||
|
||||
"github.com/number571/go-peer/pkg/crypto/hashing"
|
||||
"github.com/number571/go-peer/pkg/crypto/random"
|
||||
"github.com/number571/go-peer/pkg/crypto/symmetric"
|
||||
"github.com/number571/go-peer/pkg/encoding"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
const (
|
||||
cTabelKV = `
|
||||
CREATE TABLE IF NOT EXISTS kv (
|
||||
key text unique,
|
||||
value text
|
||||
);
|
||||
`
|
||||
)
|
||||
|
||||
var (
|
||||
_ IKeyValueDB = &sSQLiteDB{}
|
||||
)
|
||||
|
||||
type sSQLiteDB struct {
|
||||
fMutex sync.Mutex
|
||||
fSalt []byte
|
||||
fDB *sql.DB
|
||||
fSettings ISettings
|
||||
fCipher symmetric.ICipher
|
||||
}
|
||||
|
||||
// TODO: return error
|
||||
func NewSQLiteDB(pSett ISettings) (IKeyValueDB, error) {
|
||||
db, err := sql.Open("sqlite3", pSett.GetPath())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, err := db.Exec(cTabelKV); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
saltKey := pSett.GetSaltKey()
|
||||
var saltValue string
|
||||
row := db.QueryRow("SELECT value FROM kv WHERE key = $1", saltKey)
|
||||
if err := row.Scan(&saltValue); err != nil {
|
||||
saltValue = encoding.HexEncode(random.NewStdPRNG().GetBytes(symmetric.CAESKeySize))
|
||||
_, err := db.Exec("REPLACE INTO kv (key, value) VALUES ($1,$2)", pSett.GetSaltKey(), saltValue)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return &sSQLiteDB{
|
||||
fSalt: encoding.HexDecode(saltValue),
|
||||
fDB: db,
|
||||
fSettings: pSett,
|
||||
fCipher: symmetric.NewAESCipher(pSett.GetCipherKey()),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *sSQLiteDB) GetSettings() ISettings {
|
||||
return p.fSettings
|
||||
}
|
||||
|
||||
func (p *sSQLiteDB) Set(pKey []byte, pValue []byte) error {
|
||||
p.fMutex.Lock()
|
||||
defer p.fMutex.Unlock()
|
||||
|
||||
_, err := p.fDB.Exec(
|
||||
"REPLACE INTO kv (key, value) VALUES ($1,$2)",
|
||||
encoding.HexEncode(p.tryHash(pKey)),
|
||||
encoding.HexEncode(doEncrypt(p.fCipher, pValue)),
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *sSQLiteDB) Get(pKey []byte) ([]byte, error) {
|
||||
p.fMutex.Lock()
|
||||
defer p.fMutex.Unlock()
|
||||
|
||||
var encValue string
|
||||
row := p.fDB.QueryRow("SELECT value FROM kv WHERE key = $1", encoding.HexEncode(p.tryHash(pKey)))
|
||||
if err := row.Scan(&encValue); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return tryDecrypt(
|
||||
p.fCipher,
|
||||
encoding.HexDecode(encValue),
|
||||
)
|
||||
}
|
||||
|
||||
func (p *sSQLiteDB) Del(pKey []byte) error {
|
||||
p.fMutex.Lock()
|
||||
defer p.fMutex.Unlock()
|
||||
|
||||
_, err := p.fDB.Exec(
|
||||
"DELETE FROM kv WHERE key = $1",
|
||||
encoding.HexEncode(p.tryHash(pKey)),
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *sSQLiteDB) Close() error {
|
||||
p.fMutex.Lock()
|
||||
defer p.fMutex.Unlock()
|
||||
|
||||
return p.fDB.Close()
|
||||
}
|
||||
|
||||
func (p *sSQLiteDB) tryHash(pKey []byte) []byte {
|
||||
if !p.fSettings.GetHashing() {
|
||||
return pKey
|
||||
}
|
||||
saltWithKey := bytes.Join(
|
||||
[][]byte{
|
||||
p.fSalt,
|
||||
pKey,
|
||||
},
|
||||
[]byte{},
|
||||
)
|
||||
return hashing.NewSHA256Hasher(saltWithKey).ToBytes()
|
||||
}
|
||||
@ -17,13 +17,4 @@ type IKeyValueDB interface {
|
||||
types.ICloser
|
||||
|
||||
GetSettings() ISettings
|
||||
GetIterator([]byte) IIterator
|
||||
}
|
||||
|
||||
type IIterator interface {
|
||||
types.ICloser
|
||||
Next() bool
|
||||
|
||||
GetKey() []byte
|
||||
GetValue() []byte
|
||||
}
|
||||
|
||||
@ -21,18 +21,22 @@ const (
|
||||
)
|
||||
|
||||
func TestNewNode(pathDB, addr string) anonymity.INode {
|
||||
db, err := database.NewSQLiteDB(
|
||||
database.NewSettings(&database.SSettings{
|
||||
FPath: pathDB,
|
||||
FHashing: true,
|
||||
FCipherKey: []byte(testutils.TcKey1),
|
||||
}),
|
||||
)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
node := anonymity.NewNode(
|
||||
anonymity.NewSettings(&anonymity.SSettings{
|
||||
FTimeWait: 30 * time.Second,
|
||||
}),
|
||||
logger.NewLogger(logger.NewSettings(&logger.SSettings{})),
|
||||
anonymity.NewWrapperDB().Set(database.NewLevelDB(
|
||||
database.NewSettings(&database.SSettings{
|
||||
FPath: pathDB,
|
||||
FHashing: true,
|
||||
FCipherKey: []byte(testutils.TcKey1),
|
||||
}),
|
||||
)),
|
||||
anonymity.NewWrapperDB().Set(db),
|
||||
TestNewNetworkNode(addr),
|
||||
queue.NewMessageQueue(
|
||||
queue.NewSettings(&queue.SSettings{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,62 +1,57 @@
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/adapters/common 0.045s coverage: [no statements]
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/adapters/common/recv 0.048s coverage: 3.7% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/adapters/common/send 0.031s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/adapters/common/service 0.041s coverage: 4.2% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/adapters/common 0.084s coverage: [no statements]
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/adapters/common/recv 0.116s coverage: 6.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/adapters/common/send 0.047s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/adapters/common/service 0.050s coverage: 0.0% of statements
|
||||
? github.com/number571/go-peer/cmd/hidden_lake/messenger/cmd/m_hlm [no test files]
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/messenger/cmd/hlm 0.038s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/app 0.064s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/app/state 0.055s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/chat_queue 0.052s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/config 0.064s coverage: 60.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/database 0.046s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/handler 0.055s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/settings 0.046s coverage: [no statements]
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/messenger/web 0.046s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/messenger/cmd/hlm 0.108s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/app 0.097s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/app/state 0.085s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/chat_queue 0.108s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/config 0.112s coverage: 60.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/database 0.127s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/handler 0.037s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/settings 0.034s coverage: [no statements]
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/messenger/web 0.062s coverage: 0.0% of statements
|
||||
? github.com/number571/go-peer/cmd/hidden_lake/service/cmd/m_hls [no test files]
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/service/cmd/hls 0.060s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/service/internal/handler 10.507s coverage: 65.1% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/service/pkg/app 6.530s coverage: 75.4% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/service/pkg/client 0.049s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/service/pkg/config 0.063s coverage: 53.7% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/service/pkg/request 0.051s coverage: 100.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/service/pkg/settings 0.044s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/traffic/cmd/hlt 0.052s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/traffic/internal/app 6.136s coverage: 56.7% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/traffic/internal/config 0.046s coverage: 75.7% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/traffic/internal/database 0.583s coverage: 68.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/traffic/internal/handler 1.569s coverage: 62.8% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/traffic/pkg/client 0.030s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/traffic/pkg/settings 0.025s coverage: [no statements]
|
||||
ok github.com/number571/go-peer/cmd/union_blockchain 0.027s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/union_blockchain/kernel 0.027s coverage: [no statements]
|
||||
ok github.com/number571/go-peer/cmd/union_blockchain/kernel/block 0.436s coverage: 71.4% of statements
|
||||
ok github.com/number571/go-peer/cmd/union_blockchain/kernel/chain 9.611s coverage: 79.7% of statements
|
||||
ok github.com/number571/go-peer/cmd/union_blockchain/kernel/mempool 0.403s coverage: 73.9% of statements
|
||||
ok github.com/number571/go-peer/cmd/union_blockchain/kernel/transaction 0.051s coverage: 68.6% of statements
|
||||
ok github.com/number571/go-peer/internal/api 0.029s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/internal/logger 0.032s coverage: 88.9% of statements
|
||||
ok github.com/number571/go-peer/internal/pprof 0.033s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/pkg/client 1.232s coverage: 73.4% of statements
|
||||
ok github.com/number571/go-peer/pkg/client/message 0.077s coverage: 76.3% of statements
|
||||
ok github.com/number571/go-peer/pkg/client/queue 6.746s coverage: 88.6% of statements
|
||||
ok github.com/number571/go-peer/pkg/crypto 0.047s coverage: [no statements]
|
||||
ok github.com/number571/go-peer/pkg/crypto/asymmetric 0.291s coverage: 84.9% of statements
|
||||
ok github.com/number571/go-peer/pkg/crypto/entropy 0.058s coverage: 100.0% of statements
|
||||
ok github.com/number571/go-peer/pkg/crypto/hashing 0.057s coverage: 85.7% of statements
|
||||
ok github.com/number571/go-peer/pkg/crypto/puzzle 0.094s coverage: 94.7% of statements
|
||||
ok github.com/number571/go-peer/pkg/crypto/random 0.042s coverage: 81.8% of statements
|
||||
ok github.com/number571/go-peer/pkg/crypto/symmetric 0.042s coverage: 72.0% of statements
|
||||
ok github.com/number571/go-peer/pkg/encoding 0.072s coverage: 83.3% of statements
|
||||
ok github.com/number571/go-peer/pkg/filesystem 0.062s coverage: 100.0% of statements
|
||||
ok github.com/number571/go-peer/pkg/logger 0.059s coverage: 84.6% of statements
|
||||
ok github.com/number571/go-peer/pkg/network 14.321s coverage: 91.5% of statements
|
||||
ok github.com/number571/go-peer/pkg/network/anonymity 19.936s coverage: 80.7% of statements
|
||||
ok github.com/number571/go-peer/pkg/network/anonymity/logger 0.054s coverage: 92.3% of statements
|
||||
ok github.com/number571/go-peer/pkg/network/conn 0.056s coverage: 81.8% of statements
|
||||
ok github.com/number571/go-peer/pkg/network/conn_keeper 1.101s coverage: 100.0% of statements
|
||||
ok github.com/number571/go-peer/pkg/network/message 0.038s coverage: 75.0% of statements
|
||||
ok github.com/number571/go-peer/pkg/payload 0.049s coverage: 90.0% of statements
|
||||
ok github.com/number571/go-peer/pkg/storage 1.130s coverage: 84.8% of statements
|
||||
ok github.com/number571/go-peer/pkg/storage/database 1.958s coverage: 94.5% of statements
|
||||
ok github.com/number571/go-peer/pkg/types 0.970s coverage: 100.0% of statements
|
||||
ok github.com/number571/go-peer/pkg/wrapper 0.916s coverage: 100.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/service/cmd/hls 0.037s coverage: 0.0% of statements
|
||||
? github.com/number571/go-peer/internal/mobile [no test files]
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/service/internal/handler 7.268s coverage: 65.1% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/service/pkg/app 6.162s coverage: 75.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/service/pkg/client 0.057s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/service/pkg/config 0.057s coverage: 53.7% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/service/pkg/request 0.049s coverage: 100.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/service/pkg/settings 0.050s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/traffic/cmd/hlt 0.049s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/traffic/internal/app 6.088s coverage: 56.7% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/traffic/internal/config 0.031s coverage: 75.7% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/traffic/internal/database 0.702s coverage: 67.6% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/traffic/internal/handler 1.584s coverage: 62.8% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/traffic/pkg/client 0.053s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/cmd/hidden_lake/traffic/pkg/settings 0.053s coverage: [no statements]
|
||||
ok github.com/number571/go-peer/internal/api 0.054s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/internal/logger 0.053s coverage: 88.9% of statements
|
||||
ok github.com/number571/go-peer/internal/pprof 0.050s coverage: 0.0% of statements
|
||||
ok github.com/number571/go-peer/pkg/client 1.038s coverage: 73.4% of statements
|
||||
ok github.com/number571/go-peer/pkg/client/message 0.100s coverage: 76.3% of statements
|
||||
ok github.com/number571/go-peer/pkg/client/queue 6.707s coverage: 90.0% of statements
|
||||
ok github.com/number571/go-peer/pkg/crypto 0.044s coverage: [no statements]
|
||||
ok github.com/number571/go-peer/pkg/crypto/asymmetric 0.271s coverage: 84.9% of statements
|
||||
ok github.com/number571/go-peer/pkg/crypto/entropy 0.079s coverage: 100.0% of statements
|
||||
ok github.com/number571/go-peer/pkg/crypto/hashing 0.066s coverage: 85.7% of statements
|
||||
ok github.com/number571/go-peer/pkg/crypto/puzzle 0.083s coverage: 94.7% of statements
|
||||
ok github.com/number571/go-peer/pkg/crypto/random 0.029s coverage: 81.8% of statements
|
||||
ok github.com/number571/go-peer/pkg/crypto/symmetric 0.037s coverage: 72.0% of statements
|
||||
ok github.com/number571/go-peer/pkg/encoding 0.033s coverage: 83.3% of statements
|
||||
ok github.com/number571/go-peer/pkg/filesystem 0.034s coverage: 100.0% of statements
|
||||
ok github.com/number571/go-peer/pkg/logger 0.029s coverage: 84.6% of statements
|
||||
ok github.com/number571/go-peer/pkg/network 10.103s coverage: 91.5% of statements
|
||||
ok github.com/number571/go-peer/pkg/network/anonymity 16.537s coverage: 82.5% of statements
|
||||
ok github.com/number571/go-peer/pkg/network/anonymity/logger 0.033s coverage: 92.3% of statements
|
||||
ok github.com/number571/go-peer/pkg/network/conn 0.044s coverage: 81.8% of statements
|
||||
ok github.com/number571/go-peer/pkg/network/conn_keeper 1.080s coverage: 100.0% of statements
|
||||
ok github.com/number571/go-peer/pkg/network/message 0.034s coverage: 75.0% of statements
|
||||
ok github.com/number571/go-peer/pkg/payload 0.030s coverage: 90.0% of statements
|
||||
ok github.com/number571/go-peer/pkg/storage 0.128s coverage: 84.8% of statements
|
||||
ok github.com/number571/go-peer/pkg/storage/database 1.330s coverage: 92.1% of statements
|
||||
ok github.com/number571/go-peer/pkg/types 0.171s coverage: 100.0% of statements
|
||||
ok github.com/number571/go-peer/pkg/wrapper 0.170s coverage: 100.0% of statements
|
||||
|
||||
Loading…
Reference in New Issue
Block a user