Some checks failed
Go / build-and-release (push) Has been cancelled
- Add 'serve' subcommand for ephemeral RAM-based relay at /dev/shm with open ACL mode for testing and benchmarking - Fix e-tag and p-tag decoding to use ValueHex()/ValueBinary() methods instead of Value() which returns raw bytes for binary-optimized storage - Document all command-line tools in readme.adoc (relay-tester, benchmark, stresstest, blossomtest, aggregator, convert, FIND, policytest, etc.) - Switch Docker images from Alpine to Debian for proper libsecp256k1 Schnorr signature and ECDH support required by Nostr - Upgrade Docker Go version from 1.21 to 1.25 - Add ramdisk mode (--ramdisk) to benchmark script for eliminating disk I/O bottlenecks in performance measurements - Add docker-compose.ramdisk.yml for tmpfs-based benchmark volumes - Add test coverage for privileged policy with binary-encoded p-tags - Fix blossom test to expect 200 OK for anonymous uploads when auth is not required (RequireAuth=false with ACL mode 'none') - Update follows ACL to handle both binary and hex p-tag formats - Grant owner access to all users in serve mode via None ACL - Add benchmark reports from multi-relay comparison run - Update CLAUDE.md with binary tag handling documentation - Bump version to v0.30.2
95 lines
1.7 KiB
Go
95 lines
1.7 KiB
Go
package acl
|
|
|
|
import (
|
|
"next.orly.dev/app/config"
|
|
"git.mleku.dev/mleku/nostr/encoders/bech32encoding"
|
|
"git.mleku.dev/mleku/nostr/encoders/event"
|
|
"next.orly.dev/pkg/utils"
|
|
)
|
|
|
|
type None struct {
|
|
cfg *config.C
|
|
owners [][]byte
|
|
admins [][]byte
|
|
}
|
|
|
|
func (n *None) Configure(cfg ...any) (err error) {
|
|
for _, ca := range cfg {
|
|
switch c := ca.(type) {
|
|
case *config.C:
|
|
n.cfg = c
|
|
}
|
|
}
|
|
if n.cfg == nil {
|
|
return
|
|
}
|
|
|
|
// Load owners
|
|
for _, owner := range n.cfg.Owners {
|
|
if len(owner) == 0 {
|
|
continue
|
|
}
|
|
var pk []byte
|
|
if pk, err = bech32encoding.NpubOrHexToPublicKeyBinary(owner); err != nil {
|
|
continue
|
|
}
|
|
n.owners = append(n.owners, pk)
|
|
}
|
|
|
|
// Load admins
|
|
for _, admin := range n.cfg.Admins {
|
|
if len(admin) == 0 {
|
|
continue
|
|
}
|
|
var pk []byte
|
|
if pk, err = bech32encoding.NpubOrHexToPublicKeyBinary(admin); err != nil {
|
|
continue
|
|
}
|
|
n.admins = append(n.admins, pk)
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func (n *None) GetAccessLevel(pub []byte, address string) (level string) {
|
|
// In serve mode, grant full owner access to everyone
|
|
if n.cfg != nil && n.cfg.ServeMode {
|
|
return "owner"
|
|
}
|
|
|
|
// Check owners first
|
|
for _, v := range n.owners {
|
|
if utils.FastEqual(v, pub) {
|
|
return "owner"
|
|
}
|
|
}
|
|
|
|
// Check admins
|
|
for _, v := range n.admins {
|
|
if utils.FastEqual(v, pub) {
|
|
return "admin"
|
|
}
|
|
}
|
|
|
|
// Default to write for everyone else
|
|
return "write"
|
|
}
|
|
|
|
func (n None) GetACLInfo() (name, description, documentation string) {
|
|
return "none", "no ACL", "blanket write access for all clients"
|
|
}
|
|
|
|
func (n None) Type() string {
|
|
return "none"
|
|
}
|
|
|
|
func (n None) CheckPolicy(ev *event.E) (allowed bool, err error) {
|
|
return true, nil
|
|
}
|
|
|
|
func (n None) Syncer() {}
|
|
|
|
func init() {
|
|
Registry.Register(new(None))
|
|
}
|