internal

package
v0.0.0-...-670e16d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(data []byte, key []byte) ([]byte, error)

func Encrypt

func Encrypt(data []byte, key []byte) ([]byte, error)

func ParseEvent

func ParseEvent(obj map[string]any) (*nostr.Event, error)

func PrintKeyList

func PrintKeyList(keys []*KeyInfo)

func Scanline

func Scanline() string

func SerializeKeys

func SerializeKeys(l []string) []string

func Serve

func Serve(ctx context.Context, conn *Connection, ch chan<- *ConnectRequest, wg *sync.WaitGroup)

func UpdateRelays

func UpdateRelays(ctx context.Context, key *KeyInfo, boots []string, w *sync.WaitGroup)

Types

type AppMeta

type AppMeta struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Url         string `json:"url,omitempty"`
}

type ConnMetadata

type ConnMetadata struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Url         string `json:"url,omitempty"`
}

type ConnectRequest

type ConnectRequest struct {
	Method string `json:"method"`
	ID     string `json:"id"`
	Params []any  `json:"params"`

	Conn *Connection
	// contains filtered or unexported fields
}

func (*ConnectRequest) CheckAllow

func (cr *ConnectRequest) CheckAllow(name string) error

func (*ConnectRequest) Response

func (cr *ConnectRequest) Response(data any) error

type Connection

type Connection struct {
	AppID    string        `json:"appid"`
	Relay    string        `json:"relay"`
	PubKey   string        `json:"pubkey"`
	Metadata *ConnMetadata `json:"metadata"`
	Allows   []string      `json:"allows"`
	Acked    bool          `json:"acked"`
	KeyInfo  *KeyInfo      `json:"-"`
}

type DB

type DB struct {
	Db *bolt.DB
}

func Open

func Open(p string) (*DB, error)

func (*DB) Close

func (d *DB) Close() error

func (*DB) Disconnect

func (d *DB) Disconnect(id string) error

func (*DB) GetKey

func (d *DB) GetKey(pub string, pass []byte) (*KeyInfo, error)

func (*DB) Has

func (d *DB) Has(key string) bool

func (*DB) List

func (d *DB) List() (keys []*KeyInfo, err error)

func (*DB) ListConnection

func (d *DB) ListConnection() (list []*Connection, err error)

func (*DB) Remove

func (d *DB) Remove(key []byte) (err error)

func (*DB) SaveEvent

func (d *DB) SaveEvent(bucket []byte, event *nostr.Event) error

func (*DB) SaveKey

func (d *DB) SaveKey(pub string, priv []byte) error

func (*DB) SaveMetadata

func (d *DB) SaveMetadata(key []byte, metadata string) error

func (*DB) SaveRelays

func (d *DB) SaveRelays(key []byte, relays []string) error

func (*DB) SetConnection

func (d *DB) SetConnection(c *Connection) error

type KeyInfo

type KeyInfo struct {
	Pubkey   string
	Privkey  string
	Metadata *KeyMetadata
	Relays   RelayMap
}

type KeyMetadata

type KeyMetadata struct {
	Name     string `json:"display_name,omitempty"`
	Username string `json:"name,omitempty"`
	Nip05    string `json:"nip05,omitempty"`
}

type NostrConnectInfo

type NostrConnectInfo struct {
	Relay    string
	Metadata *AppMeta
	Pubkey   string
	Allows   map[string]bool
}

func ParseURL

func ParseURL(u string) (*NostrConnectInfo, error)

type RelayAttr

type RelayAttr struct {
	Read  bool `json:"read"`
	Write bool `json:"write"`
}

type RelayMap

type RelayMap map[string]*RelayAttr

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL