Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
number571 committed Oct 14, 2023
1 parent c2c49cf commit a048519
Show file tree
Hide file tree
Showing 124 changed files with 396 additions and 1,306 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
- Update `cmd/hidden_lake/service`: CNetworkMaxConns 64 -> 256
- Update `examples/echo_service/prod_test`: append switch prod_1/prod_2 in Makefile with PROD param
- Update `cmd/hidden_lake`: delete jino, timeweb.cloud providers
- Update `cmd/hidden_lake/messenger`: delete auth
- Update `cmd/hidden_lake/service`: delete SetPrivKey/ResetPrivKey
- Update `cmd/hidden_lake/service`: generates priv key file

### BUG FIXES

Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ Some final applications are compositions of other applications. Due to this, suc
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. Go library (used by `pkg/crypto/keybuilder`) [golang.org/x/crypto](https://golang.org/x/crypto "x/crypto");
5. Go library (used by `cmd/hidden_lake/messenger`) [github.com/wagslane/go-password-validator](https://github.com/wagslane/go-password-validator "wagslane/go-password-validator");
6. CSS/JS library (used by `cmd/hidden_lake/messenger`) [getbootstrap.com](https://getbootstrap.com "bootstrap")
5. CSS/JS library (used by `cmd/hidden_lake/messenger`) [getbootstrap.com](https://getbootstrap.com "bootstrap")

## Library based applications

Expand Down Expand Up @@ -351,8 +350,8 @@ $ make run # run ./bin/hlm
```

Open ports `9591` (HTTP, interface) and `9592` (HTTP, incoming).
Creates `./hlm.cfg` or `./_mounted/hlm.cfg` (docker), `./hlm.db` or `./_mounted/hlm.db` (docker) files and `./hlm.stg` or `./_mounted/hlm.stg` (docker).
The file `hlm.db` stores all sent/received messages in encrypted view. The file `hlm.stg` stores all auth information (logins, passwords, private keys) in encrypted view.
Creates `./hlm.cfg` or `./_mounted/hlm.cfg` (docker) and `./hlm.db` or `./_mounted/hlm.db` (docker) files.
The file `hlm.db` stores all sent/received messages in encrypted view.

Default config `hlm.cfg`

Expand Down
2 changes: 1 addition & 1 deletion cmd/hidden_lake/composite/service_messenger/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ run:
./$(BINPATH)/hlc_sm
clean:
rm -f $(BINPATH)/hlc_sm $(BINPATH)/hlc_sm_*
rm -rf hls.cfg hlm.cfg hlm.stg hls.db hlm.db
rm -rf hls.cfg hlm.cfg hls.db hlm.db
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ type sApp struct {
fHLM types.ICommand
}

func initApp(pPath string) (types.ICommand, error) {
hlsApp, err := hls_app.InitApp(pPath)
func initApp(pPath, pKey string) (types.ICommand, error) {
hlsApp, err := hls_app.InitApp(pPath, pKey)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func main() {
app, err := initApp(".")
app, err := initApp(".", "./priv.key")
if err != nil {
panic(err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ type sApp struct {
fHLT types.ICommand
}

func initApp(pPath string) (types.ICommand, error) {
hlsApp, err := hls_app.InitApp(pPath)
func initApp(pPath, pKey string) (types.ICommand, error) {
hlsApp, err := hls_app.InitApp(pPath, pKey)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func main() {
app, err := initApp(".")
app, err := initApp(".", "./priv.key")
if err != nil {
panic(err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ run:
./$(BINPATH)/hlc_stm
clean:
rm -f $(BINPATH)/hlc_stm $(BINPATH)/hlc_stm_*
rm -rf hls.cfg hlt.cfg hlm.cfg hlm.stg hls.db hlm.db hlt.db
rm -rf hls.cfg hlt.cfg hlm.cfg hls.db hlm.db hlt.db
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ type sApp struct {
fHLM types.ICommand
}

func initApp(pPath string) (types.ICommand, error) {
hlsApp, err := hls_app.InitApp(pPath)
func initApp(pPath, pKey string) (types.ICommand, error) {
hlsApp, err := hls_app.InitApp(pPath, pKey)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func main() {
app, err := initApp(".")
app, err := initApp(".", "./priv.key")
if err != nil {
panic(err)
}
Expand Down
1 change: 0 additions & 1 deletion cmd/hidden_lake/messenger/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
hlm
hlm.cfg
hlm.stg
hlm.db/
prog_hls
hls.cfg
Expand Down
2 changes: 1 addition & 1 deletion cmd/hidden_lake/messenger/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test:
for i in {1..$(N)}; do go clean -testcache; echo $$i; go test ./...; done
clean:
rm -f $(BINPATH)/hlm $(BINPATH)/hlm_*
rm -rf hlm.cfg hlm.db hlm.stg
rm -rf hlm.cfg hlm.db

docker-default: docker-build docker-run
docker-build:
Expand Down
4 changes: 2 additions & 2 deletions cmd/hidden_lake/messenger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ $ make run # run ./bin/hlm
```

Open ports `9591` (HTTP, interface) and `9592` (HTTP, incoming).
Creates `./hlm.cfg` or `./_mounted/hlm.cfg` (docker), `./hlm.db` or `./_mounted/hlm.db` (docker) files and `./hlm.stg` or `./_mounted/hlm.stg` (docker).
The file `hlm.db` stores all sent/received messages in encrypted view. The file `hlm.stg` stores all auth information (logins, passwords, private keys) in encrypted view.
Creates `./hlm.cfg` or `./_mounted/hlm.cfg` (docker) and `./hlm.db` or `./_mounted/hlm.db` (docker) files.
The file `hlm.db` stores all sent/received messages in encrypted view.

Default config `hlm.cfg`

Expand Down
11 changes: 2 additions & 9 deletions cmd/hidden_lake/messenger/internal/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package database
import (
"sync"

"github.com/number571/go-peer/cmd/hidden_lake/messenger/pkg/settings"
"github.com/number571/go-peer/pkg/encoding"
"github.com/number571/go-peer/pkg/errors"
"github.com/number571/go-peer/pkg/storage"
Expand All @@ -15,14 +14,8 @@ type sKeyValueDB struct {
fDB *gp_database.IKVDatabase
}

func NewKeyValueDB(pPath, pPassword string) (IKVDatabase, error) {
db, err := gp_database.NewKeyValueDB(
storage.NewSettings(&storage.SSettings{
FPath: pPath,
FWorkSize: settings.CWorkForKeys,
FPassword: pPassword,
}),
)
func NewKeyValueDB(pSettings storage.ISettings) (IKVDatabase, error) {
db, err := gp_database.NewKeyValueDB(pSettings)
if err != nil {
return nil, errors.WrapError(err, "new key/value database")
}
Expand Down
7 changes: 0 additions & 7 deletions cmd/hidden_lake/messenger/internal/database/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ import (
"github.com/number571/go-peer/pkg/types"
)

type IWrapperDB interface {
types.ICloser

Get() IKVDatabase
Set(IKVDatabase) IWrapperDB
}

type IKVDatabase interface {
types.ICloser

Expand Down
57 changes: 0 additions & 57 deletions cmd/hidden_lake/messenger/internal/database/wrapper.go

This file was deleted.

8 changes: 4 additions & 4 deletions cmd/hidden_lake/messenger/internal/handler/about.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import (
"html/template"
"net/http"

"github.com/number571/go-peer/cmd/hidden_lake/messenger/pkg/app/state"
"github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/config"
"github.com/number571/go-peer/cmd/hidden_lake/messenger/web"
"github.com/number571/go-peer/pkg/logger"

hlm_settings "github.com/number571/go-peer/cmd/hidden_lake/messenger/pkg/settings"
http_logger "github.com/number571/go-peer/internal/logger/http"
)

func AboutPage(pStateManager state.IStateManager, pLogger logger.ILogger) http.HandlerFunc {
func AboutPage(pLogger logger.ILogger, pCfg config.IConfig) http.HandlerFunc {
return func(pW http.ResponseWriter, pR *http.Request) {
logBuilder := http_logger.NewLogBuilder(hlm_settings.CServiceName, pR)

if pR.URL.Path != "/about" {
NotFoundPage(pStateManager, pLogger)(pW, pR)
NotFoundPage(pLogger, pCfg)(pW, pR)
return
}

Expand All @@ -31,6 +31,6 @@ func AboutPage(pStateManager state.IStateManager, pLogger logger.ILogger) http.H
}

pLogger.PushInfo(logBuilder.WithMessage(http_logger.CLogSuccess))
t.Execute(pW, pStateManager.GetTemplate())
t.Execute(pW, getTemplate(pCfg))
}
}
6 changes: 3 additions & 3 deletions cmd/hidden_lake/messenger/internal/handler/favicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ package handler
import (
"net/http"

"github.com/number571/go-peer/cmd/hidden_lake/messenger/pkg/app/state"
http_logger "github.com/number571/go-peer/internal/logger/http"
"github.com/number571/go-peer/pkg/logger"

"github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/config"
hlm_settings "github.com/number571/go-peer/cmd/hidden_lake/messenger/pkg/settings"
)

func FaviconPage(pStateManager state.IStateManager, pLogger logger.ILogger) http.HandlerFunc {
func FaviconPage(pLogger logger.ILogger, pCfg config.IConfig) http.HandlerFunc {
return func(pW http.ResponseWriter, pR *http.Request) {
logBuilder := http_logger.NewLogBuilder(hlm_settings.CServiceName, pR)

if pR.URL.Path != "/favicon.ico" {
NotFoundPage(pStateManager, pLogger)(pW, pR)
NotFoundPage(pLogger, pCfg)(pW, pR)
return
}

Expand Down
30 changes: 13 additions & 17 deletions cmd/hidden_lake/messenger/internal/handler/friends.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sort"
"strings"

"github.com/number571/go-peer/cmd/hidden_lake/messenger/pkg/app/state"
"github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/config"
hlm_settings "github.com/number571/go-peer/cmd/hidden_lake/messenger/pkg/settings"
"github.com/number571/go-peer/cmd/hidden_lake/messenger/web"
http_logger "github.com/number571/go-peer/internal/logger/http"
Expand All @@ -16,27 +16,23 @@ import (
)

type sFriends struct {
*state.STemplateState
*sTemplate
FFriends []string
}

func FriendsPage(pStateManager state.IStateManager, pLogger logger.ILogger) http.HandlerFunc {
func FriendsPage(pLogger logger.ILogger, pCfg config.IConfig) http.HandlerFunc {
return func(pW http.ResponseWriter, pR *http.Request) {
logBuilder := http_logger.NewLogBuilder(hlm_settings.CServiceName, pR)

if pR.URL.Path != "/friends" {
NotFoundPage(pStateManager, pLogger)(pW, pR)
return
}

if !pStateManager.StateIsActive() {
pLogger.PushInfo(logBuilder.WithMessage(http_logger.CLogRedirect))
http.Redirect(pW, pR, "/sign/in", http.StatusFound)
NotFoundPage(pLogger, pCfg)(pW, pR)
return
}

pR.ParseForm()

client := getClient(pCfg)

switch pR.FormValue("method") {
case http.MethodPost:
aliasName := strings.TrimSpace(pR.FormValue("alias_name"))
Expand All @@ -52,7 +48,7 @@ func FriendsPage(pStateManager state.IStateManager, pLogger logger.ILogger) http
fmt.Fprint(pW, "error: public key is nil")
return
}
if err := pStateManager.AddFriend(aliasName, pubKey); err != nil {
if err := client.AddFriend(aliasName, pubKey); err != nil {
pLogger.PushWarn(logBuilder.WithMessage("add_friend"))
fmt.Fprint(pW, "error: add friend")
return
Expand All @@ -64,26 +60,26 @@ func FriendsPage(pStateManager state.IStateManager, pLogger logger.ILogger) http
fmt.Fprint(pW, "error: alias_name is null")
return
}
if err := pStateManager.DelFriend(aliasName); err != nil {
if err := client.DelFriend(aliasName); err != nil {
pLogger.PushWarn(logBuilder.WithMessage("del_friend"))
fmt.Fprint(pW, "error: del friend")
return
}
}

res, err := pStateManager.GetClient().GetFriends()
friends, err := client.GetFriends()
if err != nil {
pLogger.PushWarn(logBuilder.WithMessage("get_friends"))
fmt.Fprint(pW, "error: read friends")
return
}

result := new(sFriends)
result.STemplateState = pStateManager.GetTemplate()
result.FFriends = make([]string, 0, len(res)+1) // +1 CIamAliasName
result.sTemplate = getTemplate(pCfg)
result.FFriends = make([]string, 0, len(friends)+1) // +1 CIamAliasName

friendsList := make([]string, 0, len(res))
for aliasName := range res {
friendsList := make([]string, 0, len(friends))
for aliasName := range friends {
friendsList = append(friendsList, aliasName)
}
sort.Strings(friendsList)
Expand Down
Loading

0 comments on commit a048519

Please sign in to comment.