Skip to content

Commit

Permalink
utils
Browse files Browse the repository at this point in the history
  • Loading branch information
kdudkov committed May 23, 2024
1 parent b2fb4e1 commit d0213bf
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 347 deletions.
4 changes: 2 additions & 2 deletions cmd/goatak_server/admin_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ func getWsHandler(app *App) air.Handler {
h := wshandler.NewHandler(name, ws)

app.logger.Debug("ws listener connected")
app.changeCb.Subscribe(name, h.SendItem)
app.deleteCb.Subscribe(name, h.DeleteItem)
app.changeCb.SubscribeNamed(name, h.SendItem)
app.deleteCb.SubscribeNamed(name, h.DeleteItem)
h.Listen()
app.logger.Debug("ws listener disconnected")

Expand Down
10 changes: 5 additions & 5 deletions cmd/goatak_server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import (

"github.com/glebarez/sqlite"
"github.com/google/uuid"
"github.com/kdudkov/goutils/callback"
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/viper"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"software.sslmate.com/src/go-pkcs12"

"github.com/kdudkov/goatak/cmd/goatak_server/missions"
"github.com/kdudkov/goatak/internal/callbacks"
"github.com/kdudkov/goatak/internal/client"
im "github.com/kdudkov/goatak/internal/model"
"github.com/kdudkov/goatak/internal/pm"
Expand Down Expand Up @@ -84,8 +84,8 @@ type App struct {

handlers sync.Map

changeCb *callbacks.Callback[*model.Item]
deleteCb *callbacks.Callback[string]
changeCb *callback.Callback[*model.Item]
deleteCb *callback.Callback[string]

items repository.ItemsRepository
messages []*model.ChatMessage
Expand All @@ -107,8 +107,8 @@ func NewApp(config *AppConfig) *App {
users: repository.NewFileUserRepo(config.usersFile),
ch: make(chan *cot.CotMessage, 100),
handlers: sync.Map{},
changeCb: callbacks.New[*model.Item](),
deleteCb: callbacks.New[string](),
changeCb: callback.New[*model.Item](),
deleteCb: callback.New[string](),
items: repository.NewItemsMemoryRepo(),
feeds: repository.NewFeedsFileRepo(filepath.Join(config.dataDir, "feeds")),
uid: uuid.NewString(),
Expand Down
2 changes: 1 addition & 1 deletion cmd/mm/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"net/http"
"time"

"github.com/kdudkov/goatak/pkg/request"
"github.com/kdudkov/goutils/request"

mp "github.com/kdudkov/goatak/internal/model"
"github.com/kdudkov/goatak/pkg/model"
Expand Down
2 changes: 1 addition & 1 deletion cmd/webclient/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"net/http"
"time"

"github.com/kdudkov/goatak/pkg/request"
"github.com/kdudkov/goutils/request"

"github.com/kdudkov/goatak/pkg/model"
)
Expand Down
6 changes: 3 additions & 3 deletions cmd/webclient/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ func getWsHandler(app *App) air.Handler {
h := wshandler.NewHandler(name, ws)

app.logger.Debug("ws listener connected")
app.changeCb.Subscribe(name, h.SendItem)
app.deleteCb.Subscribe(name, h.DeleteItem)
app.chatCb.Subscribe(name, h.NewChatMessage)
app.changeCb.SubscribeNamed(name, h.SendItem)
app.deleteCb.SubscribeNamed(name, h.DeleteItem)
app.chatCb.SubscribeNamed(name, h.NewChatMessage)
h.Listen()
app.logger.Debug("ws listener disconnected")

Expand Down
14 changes: 7 additions & 7 deletions cmd/webclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import (

"github.com/spf13/viper"

"github.com/kdudkov/goatak/internal/callbacks"
"github.com/kdudkov/goatak/internal/client"
"github.com/kdudkov/goatak/internal/repository"
"github.com/kdudkov/goatak/pkg/cot"
"github.com/kdudkov/goatak/pkg/cotproto"
"github.com/kdudkov/goatak/pkg/log"
"github.com/kdudkov/goatak/pkg/model"
"github.com/kdudkov/goatak/pkg/tlsutil"
"github.com/kdudkov/goutils/callback"
)

const (
Expand All @@ -51,9 +51,9 @@ type App struct {
tlsCert *tls.Certificate
cas *x509.CertPool
cl *client.ConnClientHandler
changeCb *callbacks.Callback[*model.Item]
deleteCb *callbacks.Callback[string]
chatCb *callbacks.Callback[*model.ChatMessage]
changeCb *callback.Callback[*model.Item]
deleteCb *callback.Callback[string]
chatCb *callback.Callback[*model.ChatMessage]
eventProcessors []*EventProcessor
remoteAPI *RemoteAPI
saveFile string
Expand Down Expand Up @@ -105,9 +105,9 @@ func NewApp(uid string, callsign string, connectStr string, webPort int) *App {
webPort: webPort,
items: repository.NewItemsMemoryRepo(),
dialTimeout: time.Second * 5,
changeCb: callbacks.New[*model.Item](),
deleteCb: callbacks.New[string](),
chatCb: callbacks.New[*model.ChatMessage](),
changeCb: callback.New[*model.Item](),
deleteCb: callback.New[string](),
chatCb: callback.New[*model.ChatMessage](),
chatMessages: model.NewChatMessages(uid),
eventProcessors: make([]*EventProcessor, 0),
pos: atomic.Pointer[model.Pos]{},
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/kdudkov/goatak

go 1.21
go 1.22.2

require (
github.com/air-gases/authenticator v0.11.0
Expand All @@ -9,11 +9,11 @@ require (
github.com/glebarez/sqlite v1.11.0
github.com/google/uuid v1.6.0
github.com/jroimartin/gocui v0.5.0
github.com/kdudkov/goutils v0.0.0-20240523090608-c589e6c759b7
github.com/prometheus/client_golang v1.19.0
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.9.0
golang.org/x/crypto v0.22.0
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f
golang.org/x/net v0.24.0
google.golang.org/protobuf v1.33.0
gopkg.in/yaml.v3 v3.0.1
Expand Down Expand Up @@ -60,6 +60,7 @@ require (
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jroimartin/gocui v0.5.0 h1:DCZc97zY9dMnHXJSJLLmx9VqiEnAj0yh0eTNpuEtG/4=
github.com/jroimartin/gocui v0.5.0/go.mod h1:l7Hz8DoYoL6NoYnlnaX6XCNR62G7J5FfSW5jEogzaxE=
github.com/kdudkov/goutils v0.0.0-20240523090608-c589e6c759b7 h1:Ff0x/5mSsHrHiZOyECj3FQE1a9reGF5YqqckLrJn+/U=
github.com/kdudkov/goutils v0.0.0-20240523090608-c589e6c759b7/go.mod h1:43RRUp5UXgq5CkCpw7thT4W4VYeMydShe6T0eart6Js=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
Expand Down Expand Up @@ -150,8 +152,8 @@ go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN8
golang.org/x/crypto v0.0.0-20210415154028-4f45737414dc/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY=
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI=
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
Expand All @@ -175,8 +177,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY=
golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg=
golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw=
golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
Expand Down
52 changes: 0 additions & 52 deletions internal/callbacks/callbacks_test.go

This file was deleted.

66 changes: 0 additions & 66 deletions internal/callbacks/events.go

This file was deleted.

45 changes: 0 additions & 45 deletions internal/callbacks/manager.go

This file was deleted.

2 changes: 1 addition & 1 deletion internal/client/enroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"github.com/spf13/viper"
"software.sslmate.com/src/go-pkcs12"

"github.com/kdudkov/goatak/pkg/request"
"github.com/kdudkov/goatak/pkg/tlsutil"
"github.com/kdudkov/goutils/request"
)

const (
Expand Down
Loading

0 comments on commit d0213bf

Please sign in to comment.