diff --git a/cmd/goatak_server/udpserver.go b/cmd/goatak_server/udpserver.go index b7445ee..b218d0a 100644 --- a/cmd/goatak_server/udpserver.go +++ b/cmd/goatak_server/udpserver.go @@ -71,12 +71,7 @@ func (app *App) ListenUDP(ctx context.Context, addr string) error { continue } - scope := ev.Access - if scope == "" { - scope = "broadcast" - } - - c, err := cot.EventToProtoExt(ev, "", scope) + c, err := cot.EventToProtoExt(ev, "", "BROADCAST") if err != nil { app.logger.Error("error", "error", err.Error()) } diff --git a/internal/client/client_handler.go b/internal/client/client_handler.go index eaeb951..4e015b2 100644 --- a/internal/client/client_handler.go +++ b/internal/client/client_handler.go @@ -200,7 +200,7 @@ func (h *ConnClientHandler) handleRead(ctx context.Context) { } msg.From = h.addr - msg.Scope = h.getScope() + msg.Scope = h.GetUser().GetScope() // add new contact uid if msg.IsContact() { @@ -482,11 +482,3 @@ func (h *ConnClientHandler) tryAddPacket(msg []byte) bool { return true } - -func (h *ConnClientHandler) getScope() string { - if h.user == nil { - return "" - } - - return h.user.Scope -} diff --git a/internal/model/user.go b/internal/model/user.go index 6b4bf85..d1b54d7 100644 --- a/internal/model/user.go +++ b/internal/model/user.go @@ -7,7 +7,7 @@ type User struct { Role string `yaml:"role,omitempty"` Typ string `yaml:"type,omitempty"` Password string `yaml:"password"` - Scope string `yaml:"scope,omitempty"` + Scope string `yaml:"scope"` ReadScope []string `yaml:"read_scope,omitempty"` } @@ -29,10 +29,10 @@ func (u *User) GetScope() string { func (u *User) CanSeeScope(scope string) bool { if u == nil { - return true + return scope == "" } - if u.Scope == "" || u.Scope == scope { + if u.GetScope() == scope { return true } diff --git a/users.yml b/users.yml index a6765af..9712e0d 100644 --- a/users.yml +++ b/users.yml @@ -3,3 +3,5 @@ # role: HQ, Team Lead, Team Member, K9, Forward Observer, Sniper, Medic, RTO - user: user password: $2a$14$r9/RteHNKtwH.sdc9WmBHe49.MZe8fU8DrCuT4yAGTxIM/fB0mAP2 + scope: test + read_scope: [ ]