Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
number571 committed Aug 13, 2023
1 parent bfbf1bd commit 3068ce9
Show file tree
Hide file tree
Showing 111 changed files with 1,577 additions and 525 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,43 @@

<!-- ... -->

## v1.5.16
## v1.5.17

*??? ??, ????*

<!-- ... -->

## v1.5.16

*August 13, 2023*

### IMPROVEMENTS

- Update `docs`: append article decentralized_key_exchange_protocol
- Update `cmd/hidden_lake/README.md`: append to connections "characteristics", "provider" fields
- Update `cmd/hidden_lake/messenger`: append network key updater
- Update `cmd/hidden_lake`: append http loggers to service, traffic, messenger

### CHANGES

- Update `cfgs[message_size_bytes]`: change from 4KiB to 8KiB
- Update `hidden_lake/*/init_app.go`: append trimsuffix "/" for path value
- Update `composite/mobile/service_messenger`: app.New -> app.NewWithID
- Update `cfgs[messages_capacity]`: change from (1 << 10) to (1 << 20)
- Update `pkg/client/message`: change separator from \n\n to ===
- Update `examples/anon_messenger`: change request.sh -> _request/main.go
- Update `examples/echo_service`: append _request/main.go, move request.sh -> _request/

### BUG FIXES

- Update `hidden_lake/service`: messageSize (4 << 20) -> (4 << 10)
- Update `Makefiles`: append .exe extenstion to windows compile
- Update `hidden_lake/messenger`: edit CDefaultConnectionHLSAddress -> hls_settings.CDefaultHTTPAddress
- Update `cmd/hidden_lake/service,traffic`: update README API
- Update `cmd/hidden_lake/messenger`: fix relation priv_key with HLS (append check IsMyPubKey?)
- Update `cmd/hidden_lake/messenger`: append check in state/update.go for got messages from HLT
- Update `cmd/hidden_lake/messenger`: append E2E encryption of request messages HLM <-> HLM throw HLS
- Update `pkg/client`: fix static size of messages

<!-- ... -->

Expand Down
6 changes: 3 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
7. HLM: do error pages
8. HLM: group chats, name of senders
9. Fix docker build for arm macOS
10. HLM: append NetworkKey editor
12. HLT: append logs into handlers
13. HLS: append proxy connections
10. HLS: append proxy connections
11. HLM: handlers paths to settings
12. HLS: addConnection -> addConnections, delConnection -> delConnections, ...
2 changes: 1 addition & 1 deletion cmd/hidden_lake/messenger/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sync"

"github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/utils"
"github.com/number571/go-peer/internal/logger"
logger "github.com/number571/go-peer/internal/logger/std"
"github.com/number571/go-peer/internal/settings"
"github.com/number571/go-peer/pkg/encoding"
"github.com/number571/go-peer/pkg/errors"
Expand Down
2 changes: 1 addition & 1 deletion cmd/hidden_lake/messenger/internal/config/init.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package config

import (
"github.com/number571/go-peer/internal/logger"
logger "github.com/number571/go-peer/internal/logger/std"
"github.com/number571/go-peer/internal/settings"
"github.com/number571/go-peer/pkg/filesystem"

Expand Down
2 changes: 1 addition & 1 deletion cmd/hidden_lake/messenger/internal/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package config

import (
"github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/utils"
"github.com/number571/go-peer/internal/logger"
logger "github.com/number571/go-peer/internal/logger/std"
"github.com/number571/go-peer/internal/settings"
)

Expand Down
11 changes: 9 additions & 2 deletions cmd/hidden_lake/messenger/internal/handler/about.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ import (

"github.com/number571/go-peer/cmd/hidden_lake/messenger/pkg/app/state"
"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) http.HandlerFunc {
func AboutPage(pStateManager state.IStateManager, pLogger logger.ILogger) http.HandlerFunc {
return func(pW http.ResponseWriter, pR *http.Request) {
httpLogger := http_logger.NewHTTPLogger(hlm_settings.CServiceName, pR)

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

Expand All @@ -24,6 +30,7 @@ func AboutPage(pStateManager state.IStateManager) http.HandlerFunc {
panic("can't load hmtl files")
}

pLogger.PushInfo(httpLogger.Get(http_logger.CLogSuccess))
t.Execute(pW, pStateManager.GetTemplate())
}
}
22 changes: 8 additions & 14 deletions cmd/hidden_lake/messenger/internal/handler/data_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,35 @@ import (
"encoding/base64"

"github.com/number571/go-peer/cmd/hidden_lake/messenger/internal/utils"
)

type iDataType byte

const (
cIsText iDataType = 1
cIsFile iDataType = 2
hlm_settings "github.com/number571/go-peer/cmd/hidden_lake/messenger/pkg/settings"
)

func isText(pBytes []byte) bool {
if len(pBytes) == 0 {
return false
}
return iDataType(pBytes[0]) == cIsText
return pBytes[0] == hlm_settings.CIsText
}

func isFile(pBytes []byte) bool {
if len(pBytes) == 0 {
return false
}
return iDataType(pBytes[0]) == cIsFile
return pBytes[0] == hlm_settings.CIsFile
}

func wrapText(pMsg string) []byte {
return bytes.Join([][]byte{
{byte(cIsText)},
{hlm_settings.CIsText},
[]byte(pMsg),
}, []byte{})
}

func wrapFile(filename string, pBytes []byte) []byte {
return bytes.Join([][]byte{
{byte(cIsFile)},
{hlm_settings.CIsFile},
[]byte(filename),
{byte(cIsFile)},
{hlm_settings.CIsFile},
pBytes,
}, []byte{})
}
Expand All @@ -55,15 +49,15 @@ func unwrapFile(pBytes []byte) (string, string) {
if len(pBytes) == 0 { // need use first isFile
panic("length of bytes = 0")
}
splited := bytes.Split(pBytes[1:], []byte{byte(cIsFile)})
splited := bytes.Split(pBytes[1:], []byte{hlm_settings.CIsFile})
if len(splited) < 2 {
return "", ""
}
filename := string(splited[0])
if utils.HasNotWritableCharacters(filename) {
return "", ""
}
fileBytes := bytes.Join(splited[1:], []byte{byte(cIsFile)}) // in base64
fileBytes := bytes.Join(splited[1:], []byte{hlm_settings.CIsFile}) // in base64
if len(fileBytes) == 0 {
return "", ""
}
Expand Down
12 changes: 10 additions & 2 deletions cmd/hidden_lake/messenger/internal/handler/favicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@ 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"

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

func FaviconPage(pStateManager state.IStateManager) http.HandlerFunc {
func FaviconPage(pStateManager state.IStateManager, pLogger logger.ILogger) http.HandlerFunc {
return func(pW http.ResponseWriter, pR *http.Request) {
httpLogger := http_logger.NewHTTPLogger(hlm_settings.CServiceName, pR)

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

pLogger.PushInfo(httpLogger.Get(http_logger.CLogSuccess))
http.Redirect(pW, pR, "/static/img/favicon.ico", http.StatusFound)
}
}
25 changes: 19 additions & 6 deletions cmd/hidden_lake/messenger/internal/handler/friends.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,29 @@ import (
"strings"

"github.com/number571/go-peer/cmd/hidden_lake/messenger/pkg/app/state"
"github.com/number571/go-peer/cmd/hidden_lake/messenger/pkg/settings"
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"
"github.com/number571/go-peer/pkg/crypto/asymmetric"
"github.com/number571/go-peer/pkg/logger"
)

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

func FriendsPage(pStateManager state.IStateManager) http.HandlerFunc {
func FriendsPage(pStateManager state.IStateManager, pLogger logger.ILogger) http.HandlerFunc {
return func(pW http.ResponseWriter, pR *http.Request) {
httpLogger := http_logger.NewHTTPLogger(hlm_settings.CServiceName, pR)

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

if !pStateManager.StateIsActive() {
pLogger.PushInfo(httpLogger.Get(http_logger.CLogRedirect))
http.Redirect(pW, pR, "/sign/in", http.StatusFound)
return
}
Expand All @@ -36,33 +41,39 @@ func FriendsPage(pStateManager state.IStateManager) http.HandlerFunc {
case http.MethodPost:
aliasName := strings.TrimSpace(pR.FormValue("alias_name"))
pubStrKey := strings.TrimSpace(pR.FormValue("public_key"))
if aliasName == settings.CIamAliasName || aliasName == "" || pubStrKey == "" {
if aliasName == hlm_settings.CIamAliasName || aliasName == "" || pubStrKey == "" {
pLogger.PushWarn(httpLogger.Get("get_alias_name"))
fmt.Fprint(pW, "error: host or port is null")
return
}
pubKey := asymmetric.LoadRSAPubKey(pubStrKey)
if pubKey == nil {
pLogger.PushWarn(httpLogger.Get("get_public_key"))
fmt.Fprint(pW, "error: public key is nil")
return
}
if err := pStateManager.AddFriend(aliasName, pubKey); err != nil {
pLogger.PushWarn(httpLogger.Get("add_friend"))
fmt.Fprint(pW, "error: add friend")
return
}
case http.MethodDelete:
aliasName := strings.TrimSpace(pR.FormValue("alias_name"))
if aliasName == settings.CIamAliasName || aliasName == "" {
if aliasName == hlm_settings.CIamAliasName || aliasName == "" {
pLogger.PushWarn(httpLogger.Get("get_alias_name"))
fmt.Fprint(pW, "error: alias_name is null")
return
}
if err := pStateManager.DelFriend(aliasName); err != nil {
pLogger.PushWarn(httpLogger.Get("del_friend"))
fmt.Fprint(pW, "error: del friend")
return
}
}

res, err := pStateManager.GetClient().GetFriends()
if err != nil {
pLogger.PushWarn(httpLogger.Get("get_friends"))
fmt.Fprint(pW, "error: read friends")
return
}
Expand All @@ -77,7 +88,7 @@ func FriendsPage(pStateManager state.IStateManager) http.HandlerFunc {
}
sort.Strings(friendsList)

result.FFriends = append(result.FFriends, settings.CIamAliasName) // in top
result.FFriends = append(result.FFriends, hlm_settings.CIamAliasName) // in top
result.FFriends = append(result.FFriends, friendsList...)

t, err := template.ParseFS(
Expand All @@ -88,6 +99,8 @@ func FriendsPage(pStateManager state.IStateManager) http.HandlerFunc {
if err != nil {
panic("can't load hmtl files")
}

pLogger.PushInfo(httpLogger.Get(http_logger.CLogSuccess))
t.Execute(pW, result)
}
}
Loading

0 comments on commit 3068ce9

Please sign in to comment.