diff --git a/addresstag/addresstag.go b/addresstag/addresstag.go index 25c67c1..dfe86e4 100644 --- a/addresstag/addresstag.go +++ b/addresstag/addresstag.go @@ -4,6 +4,7 @@ import ( "strconv" "strings" + "realy.mleku.dev/chk" "realy.mleku.dev/hex" ) @@ -11,8 +12,10 @@ import ( func DecodeAddressTag(tagValue string) (k uint16, pkb []byte, d string) { split := strings.Split(tagValue, ":") if len(split) == 3 { + var err error + var key uint64 if pkb, _ = hex.Dec(split[1]); len(pkb) == 32 { - if key, err := strconv.ParseUint(split[0], 10, 16); err == nil { + if key, err = strconv.ParseUint(split[0], 10, 16); !chk.E(err) { return uint16(key), pkb, split[2] } } diff --git a/apputil/util.go b/apputil/util.go deleted file mode 100644 index 52357d5..0000000 --- a/apputil/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package apputil - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/auth/nip42.go b/auth/nip42.go index d68ced6..8bfd643 100644 --- a/auth/nip42.go +++ b/auth/nip42.go @@ -7,8 +7,10 @@ import ( "strings" "time" + "realy.mleku.dev/chk" "realy.mleku.dev/event" "realy.mleku.dev/kind" + "realy.mleku.dev/log" "realy.mleku.dev/tag" "realy.mleku.dev/tags" "realy.mleku.dev/timestamp" @@ -37,11 +39,7 @@ func CreateUnsigned(pubkey, challenge []byte, relayURL string) (ev *event.T) { // helper function for ValidateAuthEvent. func parseURL(input string) (*url.URL, error) { - return url.Parse( - strings.ToLower( - strings.TrimSuffix(input, "/"), - ), - ) + return url.Parse(strings.ToLower(strings.TrimSuffix(input, "/"))) } var ( diff --git a/auth/nip42_test.go b/auth/nip42_test.go index c17a726..7c2f0ea 100644 --- a/auth/nip42_test.go +++ b/auth/nip42_test.go @@ -3,6 +3,7 @@ package auth import ( "testing" + "realy.mleku.dev/chk" "realy.mleku.dev/p256k" ) diff --git a/auth/util.go b/auth/util.go deleted file mode 100644 index 90b8256..0000000 --- a/auth/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package auth - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/bech32encoding/keys.go b/bech32encoding/keys.go index 6a1c630..babd99a 100644 --- a/bech32encoding/keys.go +++ b/bech32encoding/keys.go @@ -3,11 +3,13 @@ package bech32encoding import ( "bytes" + "realy.mleku.dev/chk" btcec "realy.mleku.dev/ec" "realy.mleku.dev/ec/bech32" "realy.mleku.dev/ec/schnorr" "realy.mleku.dev/ec/secp256k1" "realy.mleku.dev/hex" + "realy.mleku.dev/log" ) const ( diff --git a/bech32encoding/nip19.go b/bech32encoding/nip19.go index e9051c8..115c5d3 100644 --- a/bech32encoding/nip19.go +++ b/bech32encoding/nip19.go @@ -6,11 +6,14 @@ import ( "realy.mleku.dev/bech32encoding/pointers" "realy.mleku.dev/bech32encoding/tlv" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/bech32" "realy.mleku.dev/ec/schnorr" + "realy.mleku.dev/errorf" "realy.mleku.dev/eventid" "realy.mleku.dev/hex" "realy.mleku.dev/kind" + "realy.mleku.dev/log" "realy.mleku.dev/sha256" ) diff --git a/bech32encoding/nip19_test.go b/bech32encoding/nip19_test.go index 6f932e3..1cbd4ad 100644 --- a/bech32encoding/nip19_test.go +++ b/bech32encoding/nip19_test.go @@ -6,9 +6,11 @@ import ( "testing" "realy.mleku.dev/bech32encoding/pointers" + "realy.mleku.dev/chk" "realy.mleku.dev/eventid" "realy.mleku.dev/hex" "realy.mleku.dev/kind" + "realy.mleku.dev/log" ) func TestEncodeNpub(t *testing.T) { diff --git a/bech32encoding/pointers/util.go b/bech32encoding/pointers/util.go deleted file mode 100644 index b818f7b..0000000 --- a/bech32encoding/pointers/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package pointers - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/bech32encoding/tlv/tlv.go b/bech32encoding/tlv/tlv.go index 838a877..d35f564 100644 --- a/bech32encoding/tlv/tlv.go +++ b/bech32encoding/tlv/tlv.go @@ -5,6 +5,8 @@ package tlv import ( "io" + + "realy.mleku.dev/chk" ) const ( @@ -18,17 +20,17 @@ const ( func ReadEntry(buf io.Reader) (typ uint8, value []byte) { var err error t := make([]byte, 1) - if _, err = buf.Read(t); err != nil { + if _, err = buf.Read(t); chk.E(err) { return } typ = t[0] l := make([]byte, 1) - if _, err = buf.Read(l); err != nil { + if _, err = buf.Read(l); chk.E(err) { return } length := int(l[0]) value = make([]byte, length) - if _, err = buf.Read(value); err != nil { + if _, err = buf.Read(value); chk.E(err) { // nil value signals end of data or error value = nil } diff --git a/bech32encoding/util.go b/bech32encoding/util.go deleted file mode 100644 index b754092..0000000 --- a/bech32encoding/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package bech32encoding - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/bin/binary.go b/bin/binary.go index 1e2132f..8039428 100644 --- a/bin/binary.go +++ b/bin/binary.go @@ -2,6 +2,8 @@ package bin import ( "encoding/binary" + + "realy.mleku.dev/errorf" ) // Append is a straight append with length prefix. diff --git a/bin/util.go b/bin/util.go deleted file mode 100644 index 99c8142..0000000 --- a/bin/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package bin - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/chk/chk.go b/chk/chk.go new file mode 100644 index 0000000..69f3b84 --- /dev/null +++ b/chk/chk.go @@ -0,0 +1,13 @@ +// Package chk is a convenience shortcut to use shorter names to access the lol.Logger. +package chk + +import ( + "realy.mleku.dev/lol" +) + +var F, E, W, I, D, T lol.Chk + +func init() { + F, E, W, I, D, T = lol.Main.Check.F, lol.Main.Check.E, lol.Main.Check.W, lol.Main.Check.I, + lol.Main.Check.D, lol.Main.Check.T +} diff --git a/cmd/lerproxy/buf/bufpool.go b/cmd/lerproxy/buf/bufpool.go index 7a65653..95abf42 100644 --- a/cmd/lerproxy/buf/bufpool.go +++ b/cmd/lerproxy/buf/bufpool.go @@ -5,12 +5,12 @@ import "sync" var bufferPool = &sync.Pool{ New: func() interface{} { - buf := make(by, 32*1024) + buf := make([]byte, 32*1024) return &buf }, } type Pool struct{} -func (bp Pool) Get() by { return *(bufferPool.Get().(*by)) } -func (bp Pool) Put(b by) { bufferPool.Put(&b) } +func (bp Pool) Get() []byte { return *(bufferPool.Get().(*[]byte)) } +func (bp Pool) Put(b []byte) { bufferPool.Put(&b) } diff --git a/cmd/lerproxy/buf/util.go b/cmd/lerproxy/buf/util.go deleted file mode 100644 index 957c9e9..0000000 --- a/cmd/lerproxy/buf/util.go +++ /dev/null @@ -1,22 +0,0 @@ -package buf - -import ( - "bytes" - - "realy.mleku.dev/context" - "realy.mleku.dev/lol" -) - -type ( - bo = bool - by = []byte - st = string - er = error - no = int - cx = context.T -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf - equals = bytes.Equal -) diff --git a/cmd/lerproxy/hsts/proxy.go b/cmd/lerproxy/hsts/proxy.go index e26f9f9..07cee2e 100644 --- a/cmd/lerproxy/hsts/proxy.go +++ b/cmd/lerproxy/hsts/proxy.go @@ -8,8 +8,7 @@ type Proxy struct { } func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { - w.Header(). - Set("Strict-Transport-Security", - "max-age=31536000; includeSubDomains; preload") + w.Header().Set("Strict-Transport-Security", + "max-age=31536000; includeSubDomains; preload") p.ServeHTTP(w, r) } diff --git a/cmd/lerproxy/hsts/util.go b/cmd/lerproxy/hsts/util.go deleted file mode 100644 index a9df076..0000000 --- a/cmd/lerproxy/hsts/util.go +++ /dev/null @@ -1,22 +0,0 @@ -package hsts - -import ( - "bytes" - - "realy.mleku.dev/context" - "realy.mleku.dev/lol" -) - -type ( - bo = bool - by = []byte - st = string - er = error - no = int - cx = context.T -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf - equals = bytes.Equal -) diff --git a/cmd/lerproxy/main.go b/cmd/lerproxy/main.go index a4b62a1..4f56f96 100644 --- a/cmd/lerproxy/main.go +++ b/cmd/lerproxy/main.go @@ -26,26 +26,28 @@ import ( "golang.org/x/crypto/acme/autocert" "golang.org/x/sync/errgroup" + "realy.mleku.dev/chk" "realy.mleku.dev/cmd/lerproxy/buf" "realy.mleku.dev/cmd/lerproxy/hsts" "realy.mleku.dev/cmd/lerproxy/reverse" "realy.mleku.dev/cmd/lerproxy/tcpkeepalive" "realy.mleku.dev/cmd/lerproxy/util" "realy.mleku.dev/context" + "realy.mleku.dev/log" ) type runArgs struct { - Addr st `arg:"-l,--listen" default:":https" help:"address to listen at"` - Conf st `arg:"-m,--map" default:"mapping.txt" help:"file with host/backend mapping"` - Cache st `arg:"-c,--cachedir" default:"/var/cache/letsencrypt" help:"path to directory to cache key and certificates"` - HSTS bo `arg:"-h,--hsts" help:"add Strict-Transport-Security header"` - Email st `arg:"-e,--email" help:"contact email address presented to letsencrypt CA"` - HTTP st `arg:"--http" default:":http" help:"optional address to serve http-to-https redirects and ACME http-01 challenge responses"` + Addr string `arg:"-l,--listen" default:":https" help:"address to listen at"` + Conf string `arg:"-m,--map" default:"mapping.txt" help:"file with host/backend mapping"` + Cache string `arg:"-c,--cachedir" default:"/var/cache/letsencrypt" help:"path to directory to cache key and certificates"` + HSTS bool `arg:"-h,--hsts" help:"add Strict-Transport-Security header"` + Email string `arg:"-e,--email" help:"contact email address presented to letsencrypt CA"` + HTTP string `arg:"--http" default:":http" help:"optional address to serve http-to-https redirects and ACME http-01 challenge responses"` RTO time.Duration `arg:"-r,--rto" default:"1m" help:"maximum duration before timing out read of the request"` WTO time.Duration `arg:"-w,--wto" default:"5m" help:"maximum duration before timing out write of the response"` Idle time.Duration `arg:"-i,--idle" help:"how long idle connection is kept before closing (set rto, wto to 0 to use this)"` - Certs []st `arg:"--cert,separate" help:"certificates and the domain they match: eg: realy.lol:/path/to/cert - this will indicate to load two, one with extension .key and one with .crt, each expected to be PEM encoded TLS private and public keys, respectively"` - // Rewrites st `arg:"-r,--rewrites" default:"rewrites.txt"` + Certs []string `arg:"--cert,separate" help:"certificates and the domain they match: eg: realy.lol:/path/to/cert - this will indicate to load two, one with extension .key and one with .crt, each expected to be PEM encoded TLS private and public keys, respectively"` + // Rewrites string `arg:"-r,--rewrites" default:"rewrites.txt"` } var args runArgs @@ -59,7 +61,7 @@ func main() { } } -func run(c cx, args runArgs) (err er) { +func run(c context.T, args runArgs) (err error) { if args.Cache == "" { err = log.E.Err("no cache specified") @@ -86,11 +88,11 @@ func run(c cx, args runArgs) (err er) { ReadTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second, } - group.Go(func() (err er) { + group.Go(func() (err error) { chk.E(httpServer.ListenAndServe()) return }) - group.Go(func() er { + group.Go(func() error { <-ctx.Done() ctx, cancel := context.Timeout(context.Bg(), time.Second) @@ -99,12 +101,12 @@ func run(c cx, args runArgs) (err er) { }) } if srv.ReadTimeout != 0 || srv.WriteTimeout != 0 || args.Idle == 0 { - group.Go(func() (err er) { + group.Go(func() (err error) { chk.E(srv.ListenAndServeTLS("", "")) return }) } else { - group.Go(func() (err er) { + group.Go(func() (err error) { var ln net.Listener if ln, err = net.Listen("tcp", srv.Addr); chk.E(err) { return @@ -119,7 +121,7 @@ func run(c cx, args runArgs) (err er) { return }) } - group.Go(func() er { + group.Go(func() error { <-ctx.Done() ctx, cancel := context.Timeout(context.Bg(), time.Second) defer cancel() @@ -132,8 +134,8 @@ func run(c cx, args runArgs) (err er) { // as any provided .pem certificates from providers. // // The certs are provided in the form "example.com:/path/to/cert.pem" -func TLSConfig(m *autocert.Manager, certs ...st) (tc *tls.Config) { - certMap := make(map[st]*tls.Certificate) +func TLSConfig(m *autocert.Manager, certs ...string) (tc *tls.Config) { + certMap := make(map[string]*tls.Certificate) var mx sync.Mutex for _, cert := range certs { split := strings.Split(cert, ":") @@ -141,7 +143,7 @@ func TLSConfig(m *autocert.Manager, certs ...st) (tc *tls.Config) { log.E.F("invalid certificate parameter format: `%s`", cert) continue } - var err er + var err error var c tls.Certificate if c, err = tls.LoadX509KeyPair(split[1]+".crt", split[1]+".key"); chk.E(err) { continue @@ -149,9 +151,9 @@ func TLSConfig(m *autocert.Manager, certs ...st) (tc *tls.Config) { certMap[split[0]] = &c } tc = m.TLSConfig() - tc.GetCertificate = func(helo *tls.ClientHelloInfo) (cert *tls.Certificate, err er) { + tc.GetCertificate = func(helo *tls.ClientHelloInfo) (cert *tls.Certificate, err error) { mx.Lock() - var own st + var own string for i := range certMap { // to also handle explicit subdomain certs, prioritize over a root wildcard. if helo.ServerName == i { @@ -175,8 +177,8 @@ func TLSConfig(m *autocert.Manager, certs ...st) (tc *tls.Config) { return } -func setupServer(a runArgs) (s *http.Server, h http.Handler, err er) { - var mapping map[st]st +func setupServer(a runArgs) (s *http.Server, h http.Handler, err error) { + var mapping map[string]string if mapping, err = readMapping(a.Conf); chk.E(err) { return } @@ -209,11 +211,11 @@ func setupServer(a runArgs) (s *http.Server, h http.Handler, err er) { } type NostrJSON struct { - Names map[st]st `json:"names"` - Relays map[st][]st `json:"relays"` + Names map[string]string `json:"names"` + Relays map[string][]string `json:"relays"` } -func setProxy(mapping map[st]st) (h http.Handler, err er) { +func setProxy(mapping map[string]string) (h http.Handler, err error) { if len(mapping) == 0 { return nil, fmt.Errorf("empty mapping") } @@ -228,7 +230,7 @@ func setProxy(mapping map[st]st) (h http.Handler, err er) { if ba != "" && ba[0] == '@' && runtime.GOOS == "linux" { // append \0 to address so addrlen for connect(2) is calculated in a // way compatible with some other implementations (i.e. uwsgi) - network, ba = "unix", ba+st(byte(0)) + network, ba = "unix", ba+string(byte(0)) } else if strings.HasPrefix(ba, "git+") { split := strings.Split(ba, "git+") if len(split) != 2 { @@ -251,7 +253,7 @@ func setProxy(mapping map[st]st) (h http.Handler, err er) { } else if filepath.IsAbs(ba) { network = "unix" switch { - case strings.HasSuffix(ba, st(os.PathSeparator)): + case strings.HasSuffix(ba, string(os.PathSeparator)): // path specified as directory with explicit trailing slash; add // this path as static site fs := http.FileServer(http.Dir(ba)) @@ -259,7 +261,7 @@ func setProxy(mapping map[st]st) (h http.Handler, err er) { continue case strings.HasSuffix(ba, "nostr.json"): log.I.Ln(hn, ba) - var fb by + var fb []byte if fb, err = os.ReadFile(ba); chk.E(err) { continue } @@ -267,11 +269,11 @@ func setProxy(mapping map[st]st) (h http.Handler, err er) { if err = json.Unmarshal(fb, &v); chk.E(err) { continue } - var jb by + var jb []byte if jb, err = json.Marshal(v); chk.E(err) { continue } - nostrJSON := st(jb) + nostrJSON := string(jb) mux.HandleFunc(hn+"/.well-known/nostr.json", func(writer http.ResponseWriter, request *http.Request) { log.I.Ln("serving nostr json to", hn) @@ -290,7 +292,7 @@ func setProxy(mapping map[st]st) (h http.Handler, err er) { switch u.Scheme { case "http", "https": rp := reverse.NewSingleHostReverseProxy(u) - modifyCORSResponse := func(res *http.Response) er { + modifyCORSResponse := func(res *http.Response) error { res.Header.Set("Access-Control-Allow-Methods", "GET,HEAD,PUT,PATCH,POST,DELETE") // res.Header.Set("Access-Control-Allow-Credentials", "true") @@ -316,7 +318,7 @@ func setProxy(mapping map[st]st) (h http.Handler, err er) { log.D.Ln(req.URL, req.RemoteAddr) }, Transport: &http.Transport{ - DialContext: func(c cx, n, addr st) (net.Conn, er) { + DialContext: func(c context.T, n, addr string) (net.Conn, error) { return net.DialTimeout(network, ba, 5*time.Second) }, }, @@ -328,12 +330,12 @@ func setProxy(mapping map[st]st) (h http.Handler, err er) { return mux, nil } -func readMapping(file st) (m map[st]st, err er) { +func readMapping(file string) (m map[string]string, err error) { var f *os.File if f, err = os.Open(file); chk.E(err) { return } - m = make(map[st]st) + m = make(map[string]string) sc := bufio.NewScanner(f) for sc.Scan() { if b := sc.Bytes(); len(b) == 0 || b[0] == '#' { diff --git a/cmd/lerproxy/reverse/proxy.go b/cmd/lerproxy/reverse/proxy.go index dbd9601..224e5d0 100644 --- a/cmd/lerproxy/reverse/proxy.go +++ b/cmd/lerproxy/reverse/proxy.go @@ -8,6 +8,7 @@ import ( "net/url" "realy.mleku.dev/cmd/lerproxy/util" + "realy.mleku.dev/log" ) // NewSingleHostReverseProxy is a copy of httputil.NewSingleHostReverseProxy diff --git a/cmd/lerproxy/reverse/util.go b/cmd/lerproxy/reverse/util.go deleted file mode 100644 index eec81d0..0000000 --- a/cmd/lerproxy/reverse/util.go +++ /dev/null @@ -1,22 +0,0 @@ -package reverse - -import ( - "bytes" - - "realy.mleku.dev/context" - "realy.mleku.dev/lol" -) - -type ( - bo = bool - by = []byte - st = string - er = error - no = int - cx = context.T -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf - equals = bytes.Equal -) diff --git a/cmd/lerproxy/tcpkeepalive/listener.go b/cmd/lerproxy/tcpkeepalive/listener.go index f7733be..4cc8c47 100644 --- a/cmd/lerproxy/tcpkeepalive/listener.go +++ b/cmd/lerproxy/tcpkeepalive/listener.go @@ -6,6 +6,7 @@ import ( "net" "time" + "realy.mleku.dev/chk" "realy.mleku.dev/cmd/lerproxy/timeout" ) @@ -21,7 +22,7 @@ type Listener struct { *net.TCPListener } -func (ln Listener) Accept() (conn net.Conn, e er) { +func (ln Listener) Accept() (conn net.Conn, e error) { var tc *net.TCPConn if tc, e = ln.AcceptTCP(); chk.E(e) { return diff --git a/cmd/lerproxy/tcpkeepalive/util.go b/cmd/lerproxy/tcpkeepalive/util.go deleted file mode 100644 index 1fb3b78..0000000 --- a/cmd/lerproxy/tcpkeepalive/util.go +++ /dev/null @@ -1,22 +0,0 @@ -package tcpkeepalive - -import ( - "bytes" - - "realy.mleku.dev/context" - "realy.mleku.dev/lol" -) - -type ( - bo = bool - by = []byte - st = string - er = error - no = int - cx = context.T -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf - equals = bytes.Equal -) diff --git a/cmd/lerproxy/timeout/conn.go b/cmd/lerproxy/timeout/conn.go index d314a1d..fbe5a29 100644 --- a/cmd/lerproxy/timeout/conn.go +++ b/cmd/lerproxy/timeout/conn.go @@ -5,6 +5,8 @@ package timeout import ( "net" "time" + + "realy.mleku.dev/chk" ) // Conn extends deadline after successful read or write operations @@ -13,7 +15,7 @@ type Conn struct { *net.TCPConn } -func (c Conn) Read(b by) (n no, e er) { +func (c Conn) Read(b []byte) (n int, e error) { if n, e = c.TCPConn.Read(b); !chk.E(e) { if e = c.SetDeadline(c.getTimeout()); chk.E(e) { } @@ -21,7 +23,7 @@ func (c Conn) Read(b by) (n no, e er) { return } -func (c Conn) Write(b by) (n no, e er) { +func (c Conn) Write(b []byte) (n int, e error) { if n, e = c.TCPConn.Write(b); !chk.E(e) { if e = c.SetDeadline(c.getTimeout()); chk.E(e) { } diff --git a/cmd/lerproxy/timeout/util.go b/cmd/lerproxy/timeout/util.go deleted file mode 100644 index 5ce4818..0000000 --- a/cmd/lerproxy/timeout/util.go +++ /dev/null @@ -1,22 +0,0 @@ -package timeout - -import ( - "bytes" - - "realy.mleku.dev/context" - "realy.mleku.dev/lol" -) - -type ( - bo = bool - by = []byte - st = string - er = error - no = int - cx = context.T -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf - equals = bytes.Equal -) diff --git a/cmd/lerproxy/util.go b/cmd/lerproxy/util.go deleted file mode 100644 index 8680a90..0000000 --- a/cmd/lerproxy/util.go +++ /dev/null @@ -1,22 +0,0 @@ -package main - -import ( - "bytes" - - "realy.mleku.dev/context" - "realy.mleku.dev/lol" -) - -type ( - bo = bool - by = []byte - st = string - er = error - no = int - cx = context.T -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf - equals = bytes.Equal -) diff --git a/cmd/lerproxy/util/u.go b/cmd/lerproxy/util/u.go index dfb55da..9a333ce 100644 --- a/cmd/lerproxy/util/u.go +++ b/cmd/lerproxy/util/u.go @@ -5,15 +5,15 @@ package util import "strings" -func GetKeys(m map[st]st) []st { - out := make([]st, 0, len(m)) +func GetKeys(m map[string]string) []string { + out := make([]string, 0, len(m)) for k := range m { out = append(out, k) } return out } -func SingleJoiningSlash(a, b st) st { +func SingleJoiningSlash(a, b string) string { suffixSlash := strings.HasSuffix(a, "/") prefixSlash := strings.HasPrefix(b, "/") switch { diff --git a/cmd/lerproxy/util/util.go b/cmd/lerproxy/util/util.go deleted file mode 100644 index 2eed3cd..0000000 --- a/cmd/lerproxy/util/util.go +++ /dev/null @@ -1,22 +0,0 @@ -package util - -import ( - "bytes" - - "realy.mleku.dev/context" - "realy.mleku.dev/lol" -) - -type ( - bo = bool - by = []byte - st = string - er = error - no = int - cx = context.T -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf - equals = bytes.Equal -) diff --git a/cmd/nauth/main.go b/cmd/nauth/main.go index 7f4027a..1cdd050 100644 --- a/cmd/nauth/main.go +++ b/cmd/nauth/main.go @@ -7,7 +7,10 @@ import ( "time" "realy.mleku.dev/bech32encoding" + "realy.mleku.dev/chk" + "realy.mleku.dev/errorf" "realy.mleku.dev/httpauth" + "realy.mleku.dev/log" "realy.mleku.dev/p256k" "realy.mleku.dev/signer" ) diff --git a/cmd/nauth/util.go b/cmd/nauth/util.go deleted file mode 100644 index a689ecc..0000000 --- a/cmd/nauth/util.go +++ /dev/null @@ -1,12 +0,0 @@ -package main - -import ( - "bytes" - - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf - equals = bytes.Equal -) diff --git a/cmd/nurl/main.go b/cmd/nurl/main.go index be93454..18e4240 100644 --- a/cmd/nurl/main.go +++ b/cmd/nurl/main.go @@ -12,8 +12,11 @@ import ( realy_lol "realy.mleku.dev" "realy.mleku.dev/bech32encoding" + "realy.mleku.dev/chk" + "realy.mleku.dev/errorf" "realy.mleku.dev/hex" "realy.mleku.dev/httpauth" + "realy.mleku.dev/log" "realy.mleku.dev/p256k" "realy.mleku.dev/sha256" "realy.mleku.dev/signer" diff --git a/cmd/nurl/util.go b/cmd/nurl/util.go deleted file mode 100644 index a689ecc..0000000 --- a/cmd/nurl/util.go +++ /dev/null @@ -1,12 +0,0 @@ -package main - -import ( - "bytes" - - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf - equals = bytes.Equal -) diff --git a/cmd/realy/app/main.go b/cmd/realy/app/main.go index 106491f..ec35401 100644 --- a/cmd/realy/app/main.go +++ b/cmd/realy/app/main.go @@ -10,6 +10,7 @@ import ( "sync" "realy.mleku.dev/bech32encoding" + "realy.mleku.dev/chk" "realy.mleku.dev/context" "realy.mleku.dev/ec/schnorr" "realy.mleku.dev/event" @@ -18,6 +19,7 @@ import ( "realy.mleku.dev/hex" "realy.mleku.dev/kind" "realy.mleku.dev/kinds" + "realy.mleku.dev/log" "realy.mleku.dev/realy/config" "realy.mleku.dev/store" "realy.mleku.dev/tag" diff --git a/cmd/realy/app/resources.go b/cmd/realy/app/resources.go index c3acf6d..6c851f2 100644 --- a/cmd/realy/app/resources.go +++ b/cmd/realy/app/resources.go @@ -6,6 +6,7 @@ import ( "time" "realy.mleku.dev/context" + "realy.mleku.dev/log" ) func MonitorResources(c context.T) { diff --git a/cmd/realy/app/util.go b/cmd/realy/app/util.go deleted file mode 100644 index fd3aca9..0000000 --- a/cmd/realy/app/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package app - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/cmd/realy/main.go b/cmd/realy/main.go index be6cbaf..84b25d7 100644 --- a/cmd/realy/main.go +++ b/cmd/realy/main.go @@ -17,10 +17,12 @@ import ( realy_lol "realy.mleku.dev" "realy.mleku.dev/bech32encoding" + "realy.mleku.dev/chk" "realy.mleku.dev/cmd/realy/app" "realy.mleku.dev/context" "realy.mleku.dev/hex" "realy.mleku.dev/interrupt" + "realy.mleku.dev/log" "realy.mleku.dev/lol" "realy.mleku.dev/p256k" "realy.mleku.dev/ratel" diff --git a/cmd/realy/util.go b/cmd/realy/util.go deleted file mode 100644 index 83efce8..0000000 --- a/cmd/realy/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package main - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/cmd/vainstr/LICENSE b/cmd/vainstr/LICENSE deleted file mode 100644 index 0e259d4..0000000 --- a/cmd/vainstr/LICENSE +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/cmd/vainstr/main.go b/cmd/vainstr/main.go index dd8d557..c0b6ec1 100644 --- a/cmd/vainstr/main.go +++ b/cmd/vainstr/main.go @@ -14,13 +14,16 @@ import ( "github.com/alexflint/go-arg" + "realy.mleku.dev/qu" + "realy.mleku.dev/atomic" "realy.mleku.dev/bech32encoding" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/bech32" "realy.mleku.dev/ec/schnorr" "realy.mleku.dev/ec/secp256k1" "realy.mleku.dev/interrupt" - "realy.mleku.dev/qu" + "realy.mleku.dev/log" ) var prefix = append(bech32encoding.PubHRP, '1') diff --git a/cmd/vainstr/util.go b/cmd/vainstr/util.go deleted file mode 100644 index 83efce8..0000000 --- a/cmd/vainstr/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package main - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/codec/util.go b/codec/util.go deleted file mode 100644 index 13fb7a9..0000000 --- a/codec/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package codec - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/config/config.go b/config/config.go index ddd62c7..dc3f2f2 100644 --- a/config/config.go +++ b/config/config.go @@ -5,6 +5,8 @@ package config import ( "os" "strings" + + "realy.mleku.dev/chk" ) // Env is a key/value map used to represent environment variables. This is diff --git a/config/util.go b/config/util.go deleted file mode 100644 index 995d47a..0000000 --- a/config/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package config - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/dns/nip05.go b/dns/nip05.go index 06e461b..59c6d0d 100644 --- a/dns/nip05.go +++ b/dns/nip05.go @@ -10,7 +10,9 @@ import ( "strings" "realy.mleku.dev/bech32encoding/pointers" + "realy.mleku.dev/chk" "realy.mleku.dev/context" + "realy.mleku.dev/errorf" "realy.mleku.dev/keys" ) diff --git a/dns/nip05_test.go b/dns/nip05_test.go index 487736b..e39ce50 100644 --- a/dns/nip05_test.go +++ b/dns/nip05_test.go @@ -6,6 +6,7 @@ import ( "testing" "realy.mleku.dev/bech32encoding/pointers" + "realy.mleku.dev/chk" "realy.mleku.dev/keys" ) diff --git a/dns/util.go b/dns/util.go deleted file mode 100644 index 4900358..0000000 --- a/dns/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package dns - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ec/base58/util.go b/ec/base58/util.go deleted file mode 100644 index 0ff07cb..0000000 --- a/ec/base58/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package base58 - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ec/base58/util_test.go b/ec/base58/util_test.go deleted file mode 100644 index 4c3dd9a..0000000 --- a/ec/base58/util_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package base58_test - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ec/bech32/util.go b/ec/bech32/util.go deleted file mode 100644 index 25f2002..0000000 --- a/ec/bech32/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package bech32 - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ec/chaincfg/util.go b/ec/chaincfg/util.go deleted file mode 100644 index 6ccee71..0000000 --- a/ec/chaincfg/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package chaincfg - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ec/chainhash/util.go b/ec/chainhash/util.go deleted file mode 100644 index 1313ca9..0000000 --- a/ec/chainhash/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package chainhash - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ec/ecdsa/signature_test.go b/ec/ecdsa/signature_test.go index 1176f31..493dfd4 100644 --- a/ec/ecdsa/signature_test.go +++ b/ec/ecdsa/signature_test.go @@ -15,6 +15,7 @@ import ( "testing" "time" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/secp256k1" "realy.mleku.dev/hex" ) diff --git a/ec/ecdsa/util.go b/ec/ecdsa/util.go deleted file mode 100644 index 1da0a5f..0000000 --- a/ec/ecdsa/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package ecdsa - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ec/ecdsa/util_test.go b/ec/ecdsa/util_test.go deleted file mode 100644 index 9cf8fba..0000000 --- a/ec/ecdsa/util_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package ecdsa_test - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ec/field_test.go b/ec/field_test.go index 68638f0..51015a1 100644 --- a/ec/field_test.go +++ b/ec/field_test.go @@ -9,6 +9,7 @@ import ( "math/rand" "testing" + "realy.mleku.dev/chk" "realy.mleku.dev/hex" ) diff --git a/ec/musig2/context.go b/ec/musig2/context.go index 318aa63..9873bae 100644 --- a/ec/musig2/context.go +++ b/ec/musig2/context.go @@ -5,6 +5,7 @@ package musig2 import ( "fmt" + "realy.mleku.dev/chk" "realy.mleku.dev/ec" "realy.mleku.dev/ec/schnorr" ) diff --git a/ec/musig2/nonces.go b/ec/musig2/nonces.go index 7f33f1d..6bf7bc2 100644 --- a/ec/musig2/nonces.go +++ b/ec/musig2/nonces.go @@ -9,6 +9,7 @@ import ( "errors" "io" + "realy.mleku.dev/chk" "realy.mleku.dev/ec" "realy.mleku.dev/ec/chainhash" "realy.mleku.dev/ec/schnorr" diff --git a/ec/musig2/sign.go b/ec/musig2/sign.go index 53d65bb..c917d8f 100644 --- a/ec/musig2/sign.go +++ b/ec/musig2/sign.go @@ -7,6 +7,7 @@ import ( "fmt" "io" + "realy.mleku.dev/chk" "realy.mleku.dev/ec" "realy.mleku.dev/ec/chainhash" "realy.mleku.dev/ec/schnorr" diff --git a/ec/musig2/util.go b/ec/musig2/util.go deleted file mode 100644 index 5b240ad..0000000 --- a/ec/musig2/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package musig2 - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ec/schnorr/signature.go b/ec/schnorr/signature.go index 46471c5..020d8e4 100644 --- a/ec/schnorr/signature.go +++ b/ec/schnorr/signature.go @@ -5,6 +5,7 @@ package schnorr import ( "fmt" + "realy.mleku.dev/chk" "realy.mleku.dev/ec" "realy.mleku.dev/ec/chainhash" "realy.mleku.dev/ec/secp256k1" diff --git a/ec/schnorr/signature_test.go b/ec/schnorr/signature_test.go index a0dd424..f1ddc21 100644 --- a/ec/schnorr/signature_test.go +++ b/ec/schnorr/signature_test.go @@ -13,6 +13,7 @@ import ( "github.com/davecgh/go-spew/spew" + "realy.mleku.dev/chk" "realy.mleku.dev/ec" "realy.mleku.dev/ec/secp256k1" "realy.mleku.dev/hex" diff --git a/ec/schnorr/util.go b/ec/schnorr/util.go deleted file mode 100644 index 9493da5..0000000 --- a/ec/schnorr/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package schnorr - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ec/secp256k1/modnscalar_test.go b/ec/secp256k1/modnscalar_test.go index 8a27dcf..296af95 100644 --- a/ec/secp256k1/modnscalar_test.go +++ b/ec/secp256k1/modnscalar_test.go @@ -13,6 +13,7 @@ import ( "testing" "time" + "realy.mleku.dev/chk" "realy.mleku.dev/hex" ) diff --git a/ec/secp256k1/precomps/genprecomps.go b/ec/secp256k1/precomps/genprecomps.go index 5d31539..d0adc3f 100644 --- a/ec/secp256k1/precomps/genprecomps.go +++ b/ec/secp256k1/precomps/genprecomps.go @@ -13,7 +13,9 @@ import ( "math/big" "os" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/secp256k1" + "realy.mleku.dev/log" ) // curveParams houses the secp256k1 curve parameters for convenient access. diff --git a/ec/secp256k1/precomps/util.go b/ec/secp256k1/precomps/util.go deleted file mode 100644 index 83efce8..0000000 --- a/ec/secp256k1/precomps/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package main - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ec/secp256k1/seckey.go b/ec/secp256k1/seckey.go index 29c9cbc..efdf6a0 100644 --- a/ec/secp256k1/seckey.go +++ b/ec/secp256k1/seckey.go @@ -8,6 +8,8 @@ package secp256k1 import ( "crypto/rand" "io" + + "realy.mleku.dev/chk" ) // SecretKey provides facilities for working with secp256k1 secret keys within diff --git a/ec/secp256k1/util.go b/ec/secp256k1/util.go deleted file mode 100644 index 59884f4..0000000 --- a/ec/secp256k1/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package secp256k1 - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ec/secp256k1/util_test.go b/ec/secp256k1/util_test.go deleted file mode 100644 index be442d2..0000000 --- a/ec/secp256k1/util_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package secp256k1_test - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ec/taproot/taproot.go b/ec/taproot/taproot.go index 7f181a8..a9e4a3a 100644 --- a/ec/taproot/taproot.go +++ b/ec/taproot/taproot.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/bech32" "realy.mleku.dev/ec/chaincfg" ) diff --git a/ec/taproot/util.go b/ec/taproot/util.go deleted file mode 100644 index a2768bd..0000000 --- a/ec/taproot/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package taproot - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ec/util.go b/ec/util.go deleted file mode 100644 index 4d33afb..0000000 --- a/ec/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package btcec - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ec/util_test.go b/ec/util_test.go deleted file mode 100644 index 11d5515..0000000 --- a/ec/util_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package btcec_test - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ec/wire/util.go b/ec/wire/util.go deleted file mode 100644 index cafcf52..0000000 --- a/ec/wire/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package wire - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/encryption/nip4.go b/encryption/nip4.go index 6eec630..a2eac00 100644 --- a/encryption/nip4.go +++ b/encryption/nip4.go @@ -9,6 +9,8 @@ import ( "lukechampine.com/frand" + "realy.mleku.dev/chk" + "realy.mleku.dev/errorf" "realy.mleku.dev/hex" "realy.mleku.dev/p256k" ) diff --git a/encryption/nip44.go b/encryption/nip44.go index ba21bd8..faefdfd 100644 --- a/encryption/nip44.go +++ b/encryption/nip44.go @@ -12,6 +12,8 @@ import ( "golang.org/x/crypto/chacha20" "golang.org/x/crypto/hkdf" + "realy.mleku.dev/chk" + "realy.mleku.dev/errorf" "realy.mleku.dev/sha256" ) diff --git a/encryption/nip44_test.go b/encryption/nip44_test.go index 84d80c1..e737cda 100644 --- a/encryption/nip44_test.go +++ b/encryption/nip44_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/assert" + "realy.mleku.dev/chk" "realy.mleku.dev/hex" "realy.mleku.dev/keys" "realy.mleku.dev/sha256" diff --git a/encryption/util.go b/encryption/util.go deleted file mode 100644 index f757d9e..0000000 --- a/encryption/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package encryption - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/envelopes/authenvelope/authenvelope.go b/envelopes/authenvelope/authenvelope.go index cce5578..f5837a2 100644 --- a/envelopes/authenvelope/authenvelope.go +++ b/envelopes/authenvelope/authenvelope.go @@ -5,9 +5,12 @@ package authenvelope import ( "io" + "realy.mleku.dev/chk" "realy.mleku.dev/codec" envs "realy.mleku.dev/envelopes" + "realy.mleku.dev/errorf" "realy.mleku.dev/event" + "realy.mleku.dev/log" "realy.mleku.dev/text" ) diff --git a/envelopes/authenvelope/authenvelope_test.go b/envelopes/authenvelope/authenvelope_test.go index e286644..ff2777f 100644 --- a/envelopes/authenvelope/authenvelope_test.go +++ b/envelopes/authenvelope/authenvelope_test.go @@ -5,6 +5,7 @@ import ( "testing" "realy.mleku.dev/auth" + "realy.mleku.dev/chk" "realy.mleku.dev/envelopes" "realy.mleku.dev/p256k" ) @@ -26,7 +27,7 @@ func TestAuth(t *testing.T) { copy(oChal, b1) var rem []byte var l string - if l, b1, err = envelopes.Identify(b1); chk.E(err) { + if l, b1 = envelopes.Identify(b1); chk.E(err) { t.Fatal(err) } if l != L { @@ -55,7 +56,7 @@ func TestAuth(t *testing.T) { b3 = resp.Marshal(b3) oResp := make([]byte, len(b3)) copy(oResp, b3) - if l, b3, err = envelopes.Identify(b3); chk.E(err) { + if l, b3 = envelopes.Identify(b3); chk.E(err) { t.Fatal(err) } if l != L { diff --git a/envelopes/authenvelope/util.go b/envelopes/authenvelope/util.go deleted file mode 100644 index f98fd1e..0000000 --- a/envelopes/authenvelope/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package authenvelope - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/envelopes/closedenvelope/closedenvelope.go b/envelopes/closedenvelope/closedenvelope.go index 10ea1db..083c11f 100644 --- a/envelopes/closedenvelope/closedenvelope.go +++ b/envelopes/closedenvelope/closedenvelope.go @@ -6,6 +6,7 @@ package closedenvelope import ( "io" + "realy.mleku.dev/chk" "realy.mleku.dev/codec" "realy.mleku.dev/envelopes" "realy.mleku.dev/subscription" diff --git a/envelopes/closedenvelope/closedenvelope_test.go b/envelopes/closedenvelope/closedenvelope_test.go index b53331a..4ee3470 100644 --- a/envelopes/closedenvelope/closedenvelope_test.go +++ b/envelopes/closedenvelope/closedenvelope_test.go @@ -6,6 +6,7 @@ import ( "lukechampine.com/frand" + "realy.mleku.dev/chk" "realy.mleku.dev/envelopes" "realy.mleku.dev/subscription" ) @@ -40,7 +41,7 @@ func TestMarshalUnmarshal(t *testing.T) { copy(rb1, rb) var rem []byte var l string - if l, rb, err = envelopes.Identify(rb); chk.E(err) { + if l, rb = envelopes.Identify(rb); chk.E(err) { t.Fatal(err) } if l != L { diff --git a/envelopes/closedenvelope/util.go b/envelopes/closedenvelope/util.go deleted file mode 100644 index 6fa21f9..0000000 --- a/envelopes/closedenvelope/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package closedenvelope - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/envelopes/closeenvelope/closeenvelope.go b/envelopes/closeenvelope/closeenvelope.go index d2efeaa..cc65cae 100644 --- a/envelopes/closeenvelope/closeenvelope.go +++ b/envelopes/closeenvelope/closeenvelope.go @@ -5,6 +5,7 @@ package closeenvelope import ( "io" + "realy.mleku.dev/chk" "realy.mleku.dev/codec" "realy.mleku.dev/envelopes" "realy.mleku.dev/subscription" diff --git a/envelopes/closeenvelope/closeenvelope_test.go b/envelopes/closeenvelope/closeenvelope_test.go index 21019c3..b73342c 100644 --- a/envelopes/closeenvelope/closeenvelope_test.go +++ b/envelopes/closeenvelope/closeenvelope_test.go @@ -4,6 +4,7 @@ import ( "bytes" "testing" + "realy.mleku.dev/chk" "realy.mleku.dev/envelopes" "realy.mleku.dev/subscription" ) @@ -22,7 +23,7 @@ func TestMarshalUnmarshal(t *testing.T) { copy(rb1, rb) var rem []byte var l string - if l, rb, err = envelopes.Identify(rb); chk.E(err) { + if l, rb = envelopes.Identify(rb); chk.E(err) { t.Fatal(err) } if l != L { diff --git a/envelopes/closeenvelope/util.go b/envelopes/closeenvelope/util.go deleted file mode 100644 index 11f81f3..0000000 --- a/envelopes/closeenvelope/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package closeenvelope - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/envelopes/countenvelope/countenvelope.go b/envelopes/countenvelope/countenvelope.go index 0792df3..3367c95 100644 --- a/envelopes/countenvelope/countenvelope.go +++ b/envelopes/countenvelope/countenvelope.go @@ -6,8 +6,10 @@ import ( "bytes" "io" + "realy.mleku.dev/chk" "realy.mleku.dev/codec" "realy.mleku.dev/envelopes" + "realy.mleku.dev/errorf" "realy.mleku.dev/filters" "realy.mleku.dev/ints" "realy.mleku.dev/subscription" diff --git a/envelopes/countenvelope/countenvelope_test.go b/envelopes/countenvelope/countenvelope_test.go index 068d994..3accbce 100644 --- a/envelopes/countenvelope/countenvelope_test.go +++ b/envelopes/countenvelope/countenvelope_test.go @@ -4,6 +4,7 @@ import ( "bytes" "testing" + "realy.mleku.dev/chk" "realy.mleku.dev/envelopes" "realy.mleku.dev/filters" "realy.mleku.dev/subscription" @@ -27,7 +28,7 @@ func TestRequest(t *testing.T) { copy(rb1, rb) var rem []byte var l string - if l, rb, err = envelopes.Identify(rb); chk.E(err) { + if l, rb = envelopes.Identify(rb); chk.E(err) { t.Fatal(err) } if l != L { diff --git a/envelopes/countenvelope/util.go b/envelopes/countenvelope/util.go deleted file mode 100644 index a2dac01..0000000 --- a/envelopes/countenvelope/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package countenvelope - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/envelopes/eoseenvelope/eoseenvelope.go b/envelopes/eoseenvelope/eoseenvelope.go index 6c35d10..47a11e1 100644 --- a/envelopes/eoseenvelope/eoseenvelope.go +++ b/envelopes/eoseenvelope/eoseenvelope.go @@ -7,6 +7,7 @@ package eoseenvelope import ( "io" + "realy.mleku.dev/chk" "realy.mleku.dev/codec" "realy.mleku.dev/envelopes" "realy.mleku.dev/subscription" diff --git a/envelopes/eoseenvelope/eoseenvelope_test.go b/envelopes/eoseenvelope/eoseenvelope_test.go index f44464e..397c614 100644 --- a/envelopes/eoseenvelope/eoseenvelope_test.go +++ b/envelopes/eoseenvelope/eoseenvelope_test.go @@ -4,6 +4,7 @@ import ( "bytes" "testing" + "realy.mleku.dev/chk" "realy.mleku.dev/envelopes" "realy.mleku.dev/subscription" ) @@ -23,7 +24,7 @@ func TestMarshalUnmarshal(t *testing.T) { copy(rb1, rb) var rem []byte var l string - if l, rb, err = envelopes.Identify(rb); chk.E(err) { + if l, rb = envelopes.Identify(rb); chk.E(err) { t.Fatal(err) } if l != L { diff --git a/envelopes/eoseenvelope/util.go b/envelopes/eoseenvelope/util.go deleted file mode 100644 index 13fe40c..0000000 --- a/envelopes/eoseenvelope/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package eoseenvelope - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/envelopes/eventenvelope/eventenvelope.go b/envelopes/eventenvelope/eventenvelope.go index a25661a..581adde 100644 --- a/envelopes/eventenvelope/eventenvelope.go +++ b/envelopes/eventenvelope/eventenvelope.go @@ -5,8 +5,10 @@ package eventenvelope import ( "io" + "realy.mleku.dev/chk" "realy.mleku.dev/codec" "realy.mleku.dev/envelopes" + "realy.mleku.dev/errorf" "realy.mleku.dev/event" "realy.mleku.dev/subscription" ) diff --git a/envelopes/eventenvelope/eventenvelope_test.go b/envelopes/eventenvelope/eventenvelope_test.go index 6f67775..94743ca 100644 --- a/envelopes/eventenvelope/eventenvelope_test.go +++ b/envelopes/eventenvelope/eventenvelope_test.go @@ -5,6 +5,7 @@ import ( "bytes" "testing" + "realy.mleku.dev/chk" "realy.mleku.dev/envelopes" "realy.mleku.dev/event" "realy.mleku.dev/event/examples" @@ -30,7 +31,7 @@ func TestSubmission(t *testing.T) { rem = ea.Marshal(rem) c = append(c, rem...) var l string - if l, rem, err = envelopes.Identify(rem); chk.E(err) { + if l, rem = envelopes.Identify(rem); chk.E(err) { t.Fatal(err) } if l != L { @@ -72,7 +73,7 @@ func TestResult(t *testing.T) { rem = ea.Marshal(rem) c = append(c, rem...) var l string - if l, rem, err = envelopes.Identify(rem); chk.E(err) { + if l, rem = envelopes.Identify(rem); chk.E(err) { t.Fatal(err) } if l != L { diff --git a/envelopes/eventenvelope/util.go b/envelopes/eventenvelope/util.go deleted file mode 100644 index 4574c51..0000000 --- a/envelopes/eventenvelope/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package eventenvelope - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/envelopes/identify.go b/envelopes/identify.go index 435aa81..813cdd0 100644 --- a/envelopes/identify.go +++ b/envelopes/identify.go @@ -5,7 +5,7 @@ package envelopes // is not sufficient because the same labels are used on several codec.Envelope // types in the nostr specification. The rest of the context is in whether this // is a client or a relay receiving it. -func Identify(b []byte) (t string, rem []byte, err error) { +func Identify(b []byte) (t string, rem []byte) { var openBrackets, openQuotes, afterQuotes bool var label []byte rem = b diff --git a/envelopes/messages/util.go b/envelopes/messages/util.go deleted file mode 100644 index 506989f..0000000 --- a/envelopes/messages/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package messages - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/envelopes/noticeenvelope/noticeenvelope.go b/envelopes/noticeenvelope/noticeenvelope.go index 31d42ef..cf1e797 100644 --- a/envelopes/noticeenvelope/noticeenvelope.go +++ b/envelopes/noticeenvelope/noticeenvelope.go @@ -6,6 +6,7 @@ package noticeenvelope import ( "io" + "realy.mleku.dev/chk" "realy.mleku.dev/codec" "realy.mleku.dev/envelopes" "realy.mleku.dev/text" diff --git a/envelopes/noticeenvelope/noticeenvelope_test.go b/envelopes/noticeenvelope/noticeenvelope_test.go index fe512ea..0471877 100644 --- a/envelopes/noticeenvelope/noticeenvelope_test.go +++ b/envelopes/noticeenvelope/noticeenvelope_test.go @@ -4,6 +4,7 @@ import ( "bytes" "testing" + "realy.mleku.dev/chk" "realy.mleku.dev/envelopes" "realy.mleku.dev/envelopes/messages" ) @@ -18,7 +19,7 @@ func TestMarshalUnmarshal(t *testing.T) { copy(rb1, rb) var rem []byte var l string - if l, rb, err = envelopes.Identify(rb); chk.E(err) { + if l, rb = envelopes.Identify(rb); chk.E(err) { t.Fatal(err) } if l != L { diff --git a/envelopes/noticeenvelope/util.go b/envelopes/noticeenvelope/util.go deleted file mode 100644 index 5183353..0000000 --- a/envelopes/noticeenvelope/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package noticeenvelope - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/envelopes/okenvelope/okenvelope.go b/envelopes/okenvelope/okenvelope.go index 8685104..d53307f 100644 --- a/envelopes/okenvelope/okenvelope.go +++ b/envelopes/okenvelope/okenvelope.go @@ -6,9 +6,12 @@ package okenvelope import ( "io" + "realy.mleku.dev/chk" "realy.mleku.dev/codec" "realy.mleku.dev/envelopes" + "realy.mleku.dev/errorf" "realy.mleku.dev/eventid" + "realy.mleku.dev/log" "realy.mleku.dev/sha256" "realy.mleku.dev/text" ) diff --git a/envelopes/okenvelope/okenvelope_test.go b/envelopes/okenvelope/okenvelope_test.go index 31e5981..0ea8fd8 100644 --- a/envelopes/okenvelope/okenvelope_test.go +++ b/envelopes/okenvelope/okenvelope_test.go @@ -4,6 +4,7 @@ import ( "bytes" "testing" + "realy.mleku.dev/chk" "realy.mleku.dev/envelopes" "realy.mleku.dev/envelopes/messages" "realy.mleku.dev/eventid" @@ -20,7 +21,7 @@ func TestMarshalUnmarshal(t *testing.T) { copy(rb1, rb) var rem []byte var l string - if l, rb, err = envelopes.Identify(rb); chk.E(err) { + if l, rb = envelopes.Identify(rb); chk.E(err) { t.Fatal(err) } if l != L { diff --git a/envelopes/okenvelope/util.go b/envelopes/okenvelope/util.go deleted file mode 100644 index 1062dfb..0000000 --- a/envelopes/okenvelope/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package okenvelope - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/envelopes/reqenvelope/reqenvelope_test.go b/envelopes/reqenvelope/reqenvelope_test.go index 3349518..b591f23 100644 --- a/envelopes/reqenvelope/reqenvelope_test.go +++ b/envelopes/reqenvelope/reqenvelope_test.go @@ -27,7 +27,7 @@ func TestMarshalUnmarshal(t *testing.T) { copy(rb1, rb) var rem []byte var l string - if l, rb, err = envelopes.Identify(rb); chk.E(err) { + if l, rb = envelopes.Identify(rb); chk.E(err) { t.Fatal(err) } if l != L { diff --git a/envelopes/util.go b/envelopes/util.go deleted file mode 100644 index 63bac92..0000000 --- a/envelopes/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package envelopes - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/errorf/errorf.go b/errorf/errorf.go new file mode 100644 index 0000000..cb45781 --- /dev/null +++ b/errorf/errorf.go @@ -0,0 +1,12 @@ +// Package errorf is a convenience shortcut to use shorter names to access the lol.Logger. +package errorf + +import ( + "realy.mleku.dev/lol" +) + +var F, E, W, I, D, T lol.Err + +func init() { + F, E, W, I, D, T = lol.Main.Errorf.F, lol.Main.Errorf.E, lol.Main.Errorf.W, lol.Main.Errorf.I, lol.Main.Errorf.D, lol.Main.Errorf.T +} diff --git a/event/canonical.go b/event/canonical.go index ca289cd..270d9b9 100644 --- a/event/canonical.go +++ b/event/canonical.go @@ -3,10 +3,13 @@ package event import ( "reflect" + "realy.mleku.dev/chk" "realy.mleku.dev/codec" + "realy.mleku.dev/errorf" "realy.mleku.dev/hex" "realy.mleku.dev/json" "realy.mleku.dev/kind" + "realy.mleku.dev/log" "realy.mleku.dev/tags" "realy.mleku.dev/text" "realy.mleku.dev/timestamp" diff --git a/event/canonical_test.go b/event/canonical_test.go index 6e04945..f6e605b 100644 --- a/event/canonical_test.go +++ b/event/canonical_test.go @@ -5,6 +5,7 @@ import ( "bytes" "testing" + "realy.mleku.dev/chk" "realy.mleku.dev/event/examples" ) diff --git a/event/codectester/divider/main.go b/event/codectester/divider/main.go index 8e652a9..14da557 100644 --- a/event/codectester/divider/main.go +++ b/event/codectester/divider/main.go @@ -10,8 +10,10 @@ import ( "os" "strings" + "realy.mleku.dev/chk" "realy.mleku.dev/event" "realy.mleku.dev/interrupt" + "realy.mleku.dev/log" "realy.mleku.dev/units" ) diff --git a/event/codectester/divider/util.go b/event/codectester/divider/util.go deleted file mode 100644 index 83efce8..0000000 --- a/event/codectester/divider/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package main - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/event/compact.go b/event/compact.go index 1bacba0..914b336 100644 --- a/event/compact.go +++ b/event/compact.go @@ -1,6 +1,7 @@ package event import ( + "realy.mleku.dev/chk" "realy.mleku.dev/ec/schnorr" ) diff --git a/event/compact_test.go b/event/compact_test.go index c009185..b591085 100644 --- a/event/compact_test.go +++ b/event/compact_test.go @@ -5,6 +5,7 @@ import ( "bytes" "testing" + "realy.mleku.dev/chk" "realy.mleku.dev/event/examples" ) diff --git a/event/event.go b/event/event.go index 3c48dc3..1444bf6 100644 --- a/event/event.go +++ b/event/event.go @@ -7,7 +7,9 @@ package event import ( "lukechampine.com/frand" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/schnorr" + "realy.mleku.dev/errorf" "realy.mleku.dev/eventid" "realy.mleku.dev/hex" "realy.mleku.dev/kind" diff --git a/event/event_test.go b/event/event_test.go index 4acdda9..935d803 100644 --- a/event/event_test.go +++ b/event/event_test.go @@ -6,6 +6,7 @@ import ( _ "embed" "testing" + "realy.mleku.dev/chk" "realy.mleku.dev/event/examples" "realy.mleku.dev/p256k" ) diff --git a/event/examples/util.go b/event/examples/util.go deleted file mode 100644 index 986b1b8..0000000 --- a/event/examples/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package examples - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/event/json.go b/event/json.go index 8564257..95744aa 100644 --- a/event/json.go +++ b/event/json.go @@ -5,7 +5,9 @@ import ( "encoding/json" "io" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/schnorr" + "realy.mleku.dev/errorf" "realy.mleku.dev/hex" "realy.mleku.dev/kind" "realy.mleku.dev/sha256" diff --git a/event/signatures.go b/event/signatures.go index 1eb8bb4..a0f26f3 100644 --- a/event/signatures.go +++ b/event/signatures.go @@ -3,8 +3,11 @@ package event import ( "bytes" + "realy.mleku.dev/chk" sch "realy.mleku.dev/ec/schnorr" k1 "realy.mleku.dev/ec/secp256k1" + "realy.mleku.dev/errorf" + "realy.mleku.dev/log" "realy.mleku.dev/p256k" "realy.mleku.dev/signer" ) diff --git a/event/util.go b/event/util.go deleted file mode 100644 index e6a0046..0000000 --- a/event/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package event - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/event/wirecompact.go b/event/wirecompact.go index 446516c..be84a3c 100644 --- a/event/wirecompact.go +++ b/event/wirecompact.go @@ -2,6 +2,8 @@ package event import ( "encoding/base64" + + "realy.mleku.dev/chk" ) // MarshalWireCompact encodes an event as the canonical form wrapped in an array diff --git a/event/wirecompact_test.go b/event/wirecompact_test.go index 7f8f6bc..2916a21 100644 --- a/event/wirecompact_test.go +++ b/event/wirecompact_test.go @@ -5,6 +5,9 @@ import ( "bytes" _ "embed" "testing" + + "realy.mleku.dev/chk" + "realy.mleku.dev/log" ) //go:embed test.jsonl diff --git a/eventid/eventid.go b/eventid/eventid.go index cdc3501..cc06b22 100644 --- a/eventid/eventid.go +++ b/eventid/eventid.go @@ -5,7 +5,10 @@ package eventid import ( "lukechampine.com/frand" + "realy.mleku.dev/chk" + "realy.mleku.dev/errorf" "realy.mleku.dev/hex" + "realy.mleku.dev/log" "realy.mleku.dev/sha256" ) diff --git a/eventid/util.go b/eventid/util.go deleted file mode 100644 index 80ae6b2..0000000 --- a/eventid/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package eventid - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/filter/filter.go b/filter/filter.go index deaaaed..4c1365f 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -11,8 +11,10 @@ import ( "lukechampine.com/frand" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/schnorr" "realy.mleku.dev/ec/secp256k1" + "realy.mleku.dev/errorf" "realy.mleku.dev/event" "realy.mleku.dev/hex" "realy.mleku.dev/ints" diff --git a/filter/filter_test.go b/filter/filter_test.go index b85303a..03d2662 100644 --- a/filter/filter_test.go +++ b/filter/filter_test.go @@ -3,6 +3,8 @@ package filter import ( "bytes" "testing" + + "realy.mleku.dev/chk" ) func TestT_MarshalUnmarshal(t *testing.T) { diff --git a/filter/simple.go b/filter/simple.go index 16eeb1e..40b8bf3 100644 --- a/filter/simple.go +++ b/filter/simple.go @@ -4,7 +4,9 @@ import ( "encoding/binary" "sort" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/schnorr" + "realy.mleku.dev/errorf" "realy.mleku.dev/event" "realy.mleku.dev/hex" "realy.mleku.dev/ints" diff --git a/filter/util.go b/filter/util.go deleted file mode 100644 index 5e776e0..0000000 --- a/filter/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package filter - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/filters/filters.go b/filters/filters.go index 3417a69..24e03b4 100644 --- a/filters/filters.go +++ b/filters/filters.go @@ -2,6 +2,8 @@ package filters import ( + "realy.mleku.dev/chk" + "realy.mleku.dev/errorf" "realy.mleku.dev/event" "realy.mleku.dev/filter" ) diff --git a/filters/filters_test.go b/filters/filters_test.go index b984b81..7a5df01 100644 --- a/filters/filters_test.go +++ b/filters/filters_test.go @@ -3,6 +3,8 @@ package filters import ( "bytes" "testing" + + "realy.mleku.dev/chk" ) func TestT_MarshalUnmarshal(t *testing.T) { diff --git a/filters/util.go b/filters/util.go deleted file mode 100644 index 537d499..0000000 --- a/filters/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package filters - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/hex/aliases.go b/hex/aliases.go index a4bd79b..696869b 100644 --- a/hex/aliases.go +++ b/hex/aliases.go @@ -6,6 +6,9 @@ import ( "encoding/hex" "github.com/templexxx/xhex" + + "realy.mleku.dev/chk" + "realy.mleku.dev/errorf" ) var Enc = hex.EncodeToString diff --git a/hex/util.go b/hex/util.go deleted file mode 100644 index 73087d6..0000000 --- a/hex/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package hex - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/httpauth/nip98auth.go b/httpauth/nip98auth.go index ea8dd06..d24731b 100644 --- a/httpauth/nip98auth.go +++ b/httpauth/nip98auth.go @@ -6,8 +6,10 @@ import ( "net/url" "strings" + "realy.mleku.dev/chk" "realy.mleku.dev/event" "realy.mleku.dev/kind" + "realy.mleku.dev/log" "realy.mleku.dev/signer" "realy.mleku.dev/tag" "realy.mleku.dev/tags" diff --git a/httpauth/util.go b/httpauth/util.go deleted file mode 100644 index ed58bdc..0000000 --- a/httpauth/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package httpauth - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/httpauth/validate.go b/httpauth/validate.go index c565185..547979b 100644 --- a/httpauth/validate.go +++ b/httpauth/validate.go @@ -7,10 +7,14 @@ import ( "strings" "time" + "realy.mleku.dev/chk" + "realy.mleku.dev/errorf" "realy.mleku.dev/event" "realy.mleku.dev/ints" "realy.mleku.dev/kind" "realy.mleku.dev/tag" + + "realy.mleku.dev/log" ) var ErrMissingKey = fmt.Errorf( diff --git a/interrupt/main.go b/interrupt/main.go index 7169fc2..ec8e199 100644 --- a/interrupt/main.go +++ b/interrupt/main.go @@ -10,7 +10,7 @@ import ( "runtime" "realy.mleku.dev/atomic" - "realy.mleku.dev/qu" + "realy.mleku.dev/log" ) // HandlerWithSource is an interrupt handling closure and the source location that it was sent @@ -32,7 +32,7 @@ var ( signals = []os.Signal{os.Interrupt} // ShutdownRequestChan is a channel that can receive shutdown requests - ShutdownRequestChan = qu.T() + ShutdownRequestChan = make(chan struct{}) // addHandlerChan is used to add an interrupt handler to the list of handlers to be invoked // on SIGINT (Ctrl+C) signals. @@ -40,7 +40,7 @@ var ( // HandlersDone is closed after all interrupt handlers run the first time an interrupt is // signaled. - HandlersDone = make(qu.C) + HandlersDone = make(chan struct{}) interruptCallbacks []func() interruptCallbackSources []string @@ -57,7 +57,7 @@ func Listener() { interruptCallbacks[idx]() } log.D.Ln("interrupt handlers finished") - HandlersDone.Q() + close(HandlersDone) if RestartRequested { Restart() } @@ -71,7 +71,7 @@ out: invokeCallbacks() break out - case <-ShutdownRequestChan.Wait(): + case <-ShutdownRequestChan: log.W.Ln("received shutdown request - shutting down...") requested.Store(true) invokeCallbacks() @@ -82,7 +82,7 @@ out: interruptCallbackSources = append(interruptCallbackSources, handler.Source) - case <-HandlersDone.Wait(): + case <-HandlersDone: break out } } @@ -113,7 +113,7 @@ func Request() { return } requested.Store(true) - ShutdownRequestChan.Q() + close(ShutdownRequestChan) var ok bool select { case _, ok = <-ShutdownRequestChan: diff --git a/interrupt/restart.go b/interrupt/restart.go index 2259587..bfc2627 100644 --- a/interrupt/restart.go +++ b/interrupt/restart.go @@ -7,6 +7,8 @@ import ( "syscall" "github.com/kardianos/osext" + + "realy.mleku.dev/log" ) // Restart uses syscall.Exec to restart the process. MacOS and Windows are not implemented, diff --git a/interrupt/util.go b/interrupt/util.go deleted file mode 100644 index 1050b15..0000000 --- a/interrupt/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package interrupt - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ints/gen/pregen.go b/ints/gen/pregen.go index 38b6d98..6db0a3e 100644 --- a/ints/gen/pregen.go +++ b/ints/gen/pregen.go @@ -5,6 +5,8 @@ package main import ( "fmt" "os" + + "realy.mleku.dev/chk" ) func main() { diff --git a/ints/gen/util.go b/ints/gen/util.go deleted file mode 100644 index 83efce8..0000000 --- a/ints/gen/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package main - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ints/ints.go b/ints/ints.go index 0fec1a8..45ce836 100644 --- a/ints/ints.go +++ b/ints/ints.go @@ -9,6 +9,8 @@ import ( "io" "golang.org/x/exp/constraints" + + "realy.mleku.dev/errorf" ) // run this to regenerate (pointlessly) the base 10 array of 4 places per entry diff --git a/ints/ints_test.go b/ints/ints_test.go index 54ac094..5a2f871 100644 --- a/ints/ints_test.go +++ b/ints/ints_test.go @@ -6,6 +6,8 @@ import ( "testing" "lukechampine.com/frand" + + "realy.mleku.dev/chk" ) func TestMarshalUnmarshal(t *testing.T) { diff --git a/ints/util.go b/ints/util.go deleted file mode 100644 index 6ad9e8a..0000000 --- a/ints/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package ints - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/json/array.go b/json/array.go index ef683db..d9e122e 100644 --- a/json/array.go +++ b/json/array.go @@ -3,6 +3,7 @@ package json import ( "io" + "realy.mleku.dev/chk" "realy.mleku.dev/codec" ) diff --git a/json/base64.go b/json/base64.go index cc816c5..ac4204e 100644 --- a/json/base64.go +++ b/json/base64.go @@ -4,6 +4,8 @@ import ( "bytes" "encoding/base64" + "realy.mleku.dev/chk" + "realy.mleku.dev/errorf" "realy.mleku.dev/text" ) diff --git a/json/bech32.go b/json/bech32.go index 4465a1f..9b3d700 100644 --- a/json/bech32.go +++ b/json/bech32.go @@ -4,7 +4,9 @@ import ( "bytes" "realy.mleku.dev/bech32encoding" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/bech32" + "realy.mleku.dev/errorf" "realy.mleku.dev/text" ) diff --git a/json/examples_test.go b/json/examples_test.go index 2a85541..c5b3827 100644 --- a/json/examples_test.go +++ b/json/examples_test.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" + "realy.mleku.dev/chk" "realy.mleku.dev/hex" ) diff --git a/json/hex.go b/json/hex.go index 2e8c9a3..e0eccd9 100644 --- a/json/hex.go +++ b/json/hex.go @@ -1,6 +1,8 @@ package json import ( + "realy.mleku.dev/chk" + "realy.mleku.dev/errorf" "realy.mleku.dev/hex" "realy.mleku.dev/text" ) diff --git a/json/keyvalue.go b/json/keyvalue.go index a57f433..15d2214 100644 --- a/json/keyvalue.go +++ b/json/keyvalue.go @@ -3,6 +3,7 @@ package json import ( "io" + "realy.mleku.dev/chk" "realy.mleku.dev/codec" ) diff --git a/json/signed.go b/json/signed.go index 792d994..f762400 100644 --- a/json/signed.go +++ b/json/signed.go @@ -3,6 +3,7 @@ package json import ( "golang.org/x/exp/constraints" + "realy.mleku.dev/chk" "realy.mleku.dev/ints" ) diff --git a/json/string.go b/json/string.go index 96f8200..0cbc77e 100644 --- a/json/string.go +++ b/json/string.go @@ -1,6 +1,7 @@ package json import ( + "realy.mleku.dev/chk" "realy.mleku.dev/text" ) diff --git a/json/unsigned.go b/json/unsigned.go index d0d2667..b96d5a0 100644 --- a/json/unsigned.go +++ b/json/unsigned.go @@ -3,6 +3,7 @@ package json import ( "golang.org/x/exp/constraints" + "realy.mleku.dev/chk" "realy.mleku.dev/ints" ) diff --git a/json/util.go b/json/util.go deleted file mode 100644 index a96bacb..0000000 --- a/json/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package json - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/keys/keys.go b/keys/keys.go index ca19e3b..1a5d57a 100644 --- a/keys/keys.go +++ b/keys/keys.go @@ -5,6 +5,7 @@ package keys import ( "bytes" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/schnorr" "realy.mleku.dev/hex" "realy.mleku.dev/p256k" diff --git a/keys/util.go b/keys/util.go deleted file mode 100644 index fcd4be4..0000000 --- a/keys/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package keys - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/kind/kind.go b/kind/kind.go index 55411bf..4c69f12 100644 --- a/kind/kind.go +++ b/kind/kind.go @@ -8,6 +8,7 @@ import ( "golang.org/x/exp/constraints" + "realy.mleku.dev/chk" "realy.mleku.dev/ints" ) diff --git a/kind/kind_test.go b/kind/kind_test.go index dbd742c..096c8f6 100644 --- a/kind/kind_test.go +++ b/kind/kind_test.go @@ -4,6 +4,8 @@ import ( "testing" "lukechampine.com/frand" + + "realy.mleku.dev/chk" ) func TestMarshalUnmarshal(t *testing.T) { diff --git a/kind/util.go b/kind/util.go deleted file mode 100644 index b2edb63..0000000 --- a/kind/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package kind - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/kinds/kinds.go b/kinds/kinds.go index 1e1a1b8..2cfe825 100644 --- a/kinds/kinds.go +++ b/kinds/kinds.go @@ -3,8 +3,11 @@ package kinds import ( + "realy.mleku.dev/chk" + "realy.mleku.dev/errorf" "realy.mleku.dev/ints" "realy.mleku.dev/kind" + "realy.mleku.dev/log" ) // T is an array of kind.T, used in filter.T and filter.S for searches. diff --git a/kinds/kinds_test.go b/kinds/kinds_test.go index f14251f..92c1c33 100644 --- a/kinds/kinds_test.go +++ b/kinds/kinds_test.go @@ -5,6 +5,7 @@ import ( "lukechampine.com/frand" + "realy.mleku.dev/chk" "realy.mleku.dev/kind" ) diff --git a/kinds/util.go b/kinds/util.go deleted file mode 100644 index d9529b5..0000000 --- a/kinds/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package kinds - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/layer2/badgerbadger/util.go b/layer2/badgerbadger/util.go deleted file mode 100644 index ea2d05b..0000000 --- a/layer2/badgerbadger/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package badgerbadger - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/layer2/layer2.go b/layer2/layer2.go index 75a7744..12d7b33 100644 --- a/layer2/layer2.go +++ b/layer2/layer2.go @@ -11,10 +11,12 @@ import ( "sync" "time" + "realy.mleku.dev/chk" "realy.mleku.dev/context" "realy.mleku.dev/event" "realy.mleku.dev/eventid" "realy.mleku.dev/filter" + "realy.mleku.dev/log" "realy.mleku.dev/store" "realy.mleku.dev/tag" "realy.mleku.dev/timestamp" diff --git a/layer2/util.go b/layer2/util.go deleted file mode 100644 index 942cb21..0000000 --- a/layer2/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package layer2 - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/log/log.go b/log/log.go new file mode 100644 index 0000000..e5b8021 --- /dev/null +++ b/log/log.go @@ -0,0 +1,12 @@ +// Package log is a convenience shortcut to use shorter names to access the lol.Logger. +package log + +import ( + "realy.mleku.dev/lol" +) + +var F, E, W, I, D, T lol.LevelPrinter + +func init() { + F, E, W, I, D, T = lol.Main.Log.F, lol.Main.Log.E, lol.Main.Log.W, lol.Main.Log.I, lol.Main.Log.D, lol.Main.Log.T +} diff --git a/normalize/normalize.go b/normalize/normalize.go index 9ef1004..d49ec5c 100644 --- a/normalize/normalize.go +++ b/normalize/normalize.go @@ -7,7 +7,9 @@ import ( "fmt" "net/url" + "realy.mleku.dev/chk" "realy.mleku.dev/ints" + "realy.mleku.dev/log" ) var ( diff --git a/normalize/util.go b/normalize/util.go deleted file mode 100644 index e37fcbb..0000000 --- a/normalize/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package normalize - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/number/util.go b/number/util.go deleted file mode 100644 index 8d4a032..0000000 --- a/number/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package number - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/nwc/pay_invoice_test.go b/nwc/pay_invoice_test.go index 0eaa4f7..f70bd8c 100644 --- a/nwc/pay_invoice_test.go +++ b/nwc/pay_invoice_test.go @@ -2,6 +2,8 @@ package nwc import ( "fmt" + + "realy.mleku.dev/chk" ) func ExamplePayInvoiceRequest_Marshal() { diff --git a/nwc/util.go b/nwc/util.go deleted file mode 100644 index a037d97..0000000 --- a/nwc/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package nwc - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/openapi/http-configuration.go b/openapi/http-configuration.go index 28012d4..73191b2 100644 --- a/openapi/http-configuration.go +++ b/openapi/http-configuration.go @@ -5,7 +5,9 @@ import ( "github.com/danielgtaylor/huma/v2" + "realy.mleku.dev/chk" "realy.mleku.dev/context" + "realy.mleku.dev/log" "realy.mleku.dev/realy/helpers" "realy.mleku.dev/store" ) diff --git a/openapi/http-event.go b/openapi/http-event.go index 9595199..89f7d57 100644 --- a/openapi/http-event.go +++ b/openapi/http-event.go @@ -8,6 +8,7 @@ import ( "github.com/danielgtaylor/huma/v2" + "realy.mleku.dev/chk" "realy.mleku.dev/context" "realy.mleku.dev/event" "realy.mleku.dev/filter" @@ -15,6 +16,7 @@ import ( "realy.mleku.dev/httpauth" "realy.mleku.dev/ints" "realy.mleku.dev/kind" + "realy.mleku.dev/log" "realy.mleku.dev/realy/helpers" "realy.mleku.dev/relay" "realy.mleku.dev/sha256" diff --git a/openapi/http-events.go b/openapi/http-events.go index 888eafe..92264ba 100644 --- a/openapi/http-events.go +++ b/openapi/http-events.go @@ -7,6 +7,7 @@ import ( "github.com/danielgtaylor/huma/v2" + "realy.mleku.dev/chk" "realy.mleku.dev/cmd/realy/app" "realy.mleku.dev/context" "realy.mleku.dev/ec/schnorr" diff --git a/openapi/http-export.go b/openapi/http-export.go index 3bc38f4..e9488ff 100644 --- a/openapi/http-export.go +++ b/openapi/http-export.go @@ -6,6 +6,7 @@ import ( "github.com/danielgtaylor/huma/v2" "realy.mleku.dev/context" + "realy.mleku.dev/log" "realy.mleku.dev/realy/helpers" ) diff --git a/openapi/http-filter.go b/openapi/http-filter.go index 8bffcf4..a2e9506 100644 --- a/openapi/http-filter.go +++ b/openapi/http-filter.go @@ -9,6 +9,7 @@ import ( "github.com/danielgtaylor/huma/v2" + "realy.mleku.dev/chk" "realy.mleku.dev/context" "realy.mleku.dev/event" "realy.mleku.dev/filter" @@ -17,6 +18,7 @@ import ( "realy.mleku.dev/httpauth" "realy.mleku.dev/kind" "realy.mleku.dev/kinds" + "realy.mleku.dev/log" "realy.mleku.dev/realy/helpers" "realy.mleku.dev/relay" "realy.mleku.dev/store" diff --git a/openapi/http-import.go b/openapi/http-import.go index 4a3d086..2a6c3c8 100644 --- a/openapi/http-import.go +++ b/openapi/http-import.go @@ -11,6 +11,7 @@ import ( "realy.mleku.dev/cmd/realy/app" "realy.mleku.dev/context" + "realy.mleku.dev/log" "realy.mleku.dev/realy/helpers" ) diff --git a/openapi/http-nuke.go b/openapi/http-nuke.go index 6760f7f..9313f7c 100644 --- a/openapi/http-nuke.go +++ b/openapi/http-nuke.go @@ -6,7 +6,9 @@ import ( "github.com/danielgtaylor/huma/v2" + "realy.mleku.dev/chk" "realy.mleku.dev/context" + "realy.mleku.dev/log" "realy.mleku.dev/realy/helpers" "realy.mleku.dev/store" ) diff --git a/openapi/http-relay.go b/openapi/http-relay.go index e7ded82..d645d5f 100644 --- a/openapi/http-relay.go +++ b/openapi/http-relay.go @@ -7,9 +7,11 @@ import ( "github.com/danielgtaylor/huma/v2" + "realy.mleku.dev/chk" "realy.mleku.dev/context" "realy.mleku.dev/event" "realy.mleku.dev/httpauth" + "realy.mleku.dev/log" "realy.mleku.dev/realy/helpers" "realy.mleku.dev/relay" ) diff --git a/openapi/http-rescan.go b/openapi/http-rescan.go index 0ad653d..636ca8d 100644 --- a/openapi/http-rescan.go +++ b/openapi/http-rescan.go @@ -5,7 +5,9 @@ import ( "github.com/danielgtaylor/huma/v2" + "realy.mleku.dev/chk" "realy.mleku.dev/context" + "realy.mleku.dev/log" "realy.mleku.dev/realy/helpers" "realy.mleku.dev/store" ) diff --git a/openapi/http-subscribe.go b/openapi/http-subscribe.go index d1bfbe6..6bfe44e 100644 --- a/openapi/http-subscribe.go +++ b/openapi/http-subscribe.go @@ -8,6 +8,7 @@ import ( "github.com/danielgtaylor/huma/v2" "github.com/danielgtaylor/huma/v2/sse" + "realy.mleku.dev/chk" "realy.mleku.dev/context" "realy.mleku.dev/event" "realy.mleku.dev/filter" @@ -16,6 +17,7 @@ import ( "realy.mleku.dev/httpauth" "realy.mleku.dev/kind" "realy.mleku.dev/kinds" + "realy.mleku.dev/log" "realy.mleku.dev/realy/helpers" "realy.mleku.dev/relay" "realy.mleku.dev/tag" diff --git a/openapi/util.go b/openapi/util.go deleted file mode 100644 index 15949c9..0000000 --- a/openapi/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package openapi - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/p256k/btcec/btcec.go b/p256k/btcec/btcec.go index 61f75af..9fd3ad6 100644 --- a/p256k/btcec/btcec.go +++ b/p256k/btcec/btcec.go @@ -2,9 +2,11 @@ package btcec import ( + "realy.mleku.dev/chk" ec "realy.mleku.dev/ec" "realy.mleku.dev/ec/schnorr" "realy.mleku.dev/ec/secp256k1" + "realy.mleku.dev/errorf" "realy.mleku.dev/signer" ) diff --git a/p256k/btcec/btcec_test.go b/p256k/btcec/btcec_test.go index c2e273f..1c18cbb 100644 --- a/p256k/btcec/btcec_test.go +++ b/p256k/btcec/btcec_test.go @@ -6,9 +6,11 @@ import ( "testing" "time" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/schnorr" "realy.mleku.dev/event" "realy.mleku.dev/event/examples" + "realy.mleku.dev/log" "realy.mleku.dev/p256k/btcec" "realy.mleku.dev/sha256" ) diff --git a/p256k/btcec/util.go b/p256k/btcec/util.go deleted file mode 100644 index 4d33afb..0000000 --- a/p256k/btcec/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package btcec - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/p256k/btcec/util_test.go b/p256k/btcec/util_test.go deleted file mode 100644 index 11d5515..0000000 --- a/p256k/btcec/util_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package btcec_test - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/p256k/p256k.go b/p256k/p256k.go index 2074e5f..03515c3 100644 --- a/p256k/p256k.go +++ b/p256k/p256k.go @@ -4,8 +4,11 @@ package p256k import "C" import ( + "realy.mleku.dev/chk" btcec "realy.mleku.dev/ec" "realy.mleku.dev/ec/secp256k1" + "realy.mleku.dev/errorf" + "realy.mleku.dev/log" realy "realy.mleku.dev/signer" ) diff --git a/p256k/p256k_test.go b/p256k/p256k_test.go index 88aee56..e6ff645 100644 --- a/p256k/p256k_test.go +++ b/p256k/p256k_test.go @@ -9,9 +9,11 @@ import ( "testing" "time" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/schnorr" "realy.mleku.dev/event" "realy.mleku.dev/event/examples" + "realy.mleku.dev/log" "realy.mleku.dev/p256k" realy "realy.mleku.dev/signer" ) diff --git a/p256k/secp256k1.go b/p256k/secp256k1.go index 3b86d5f..08209c8 100644 --- a/p256k/secp256k1.go +++ b/p256k/secp256k1.go @@ -6,8 +6,11 @@ import ( "crypto/rand" "unsafe" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/schnorr" "realy.mleku.dev/ec/secp256k1" + "realy.mleku.dev/errorf" + "realy.mleku.dev/log" "realy.mleku.dev/sha256" ) diff --git a/p256k/secp256k1_test.go b/p256k/secp256k1_test.go index cd9eab5..06c0ece 100644 --- a/p256k/secp256k1_test.go +++ b/p256k/secp256k1_test.go @@ -7,6 +7,7 @@ import ( "bytes" "testing" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/schnorr" "realy.mleku.dev/event" "realy.mleku.dev/event/examples" diff --git a/p256k/util.go b/p256k/util.go deleted file mode 100644 index 624b3b2..0000000 --- a/p256k/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package p256k - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/p256k/util_test.go b/p256k/util_test.go deleted file mode 100644 index 78a7c23..0000000 --- a/p256k/util_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package p256k_test - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/qu/README.adoc b/qu/README.adoc deleted file mode 100644 index 0ad2e8a..0000000 --- a/qu/README.adoc +++ /dev/null @@ -1,60 +0,0 @@ -= qu - -===== observable signal channels - -simple channels that act as breakers or momentary one-shot triggers. - -can enable logging to get detailed information on channel state, and channels do -not panic if closed channels are attempted to be closed or signalled with. - -provides a neat function based syntax for usage. - -wait function does require use of the `<-` receive operator prefix to be used in -a select statement. - -== usage - -=== creating channels: - -==== unbuffered - ----- -newSigChan := qu.T() ----- - -==== buffered - ----- -newBufferedSigChan := qu.Ts(5) ----- - -==== closing - ----- -newSigChan.Q() ----- - -==== signalling - ----- -newBufferedSigChan.Signal() ----- - -==== logging features - ----- -numberOpenUnbufferedChannels := GetOpenUnbufferedChanCount() - -numberOpenBufferedChannels := GetOpenBufferedChanCount() ----- - -print a list of closed and open channels known by qu: - ----- -PrintChanState() ----- - -== garbage collection - -this library automatically cleans up closed channels once a minute to free -resources that have become unused. \ No newline at end of file diff --git a/qu/qu.go b/qu/qu.go deleted file mode 100644 index b564b09..0000000 --- a/qu/qu.go +++ /dev/null @@ -1,234 +0,0 @@ -// Package qu is a library for making handling signal (chan struct{}) channels -// simpler, as well as monitoring the state of the signal channels in an -// application. -package qu - -import ( - "fmt" - "strings" - "sync" - "time" - - "realy.mleku.dev/atomic" - "realy.mleku.dev/lol" -) - -// C is your basic empty struct signalling channel -type C chan struct{} - -var ( - createdList []string - createdChannels []C - createdChannelBufferCounts []int - mx sync.Mutex - logEnabled = atomic.NewBool(false) -) - -// SetLogging switches on and off the channel logging -func SetLogging(on bool) { - logEnabled.Store(on) -} - -func l(a ...interface{}) { - if logEnabled.Load() { - log.D.Ln(a...) - } -} - -func lc(cl func() string) { - if logEnabled.Load() { - log.D.Ln(cl()) - } -} - -// T creates an unbuffered chan struct{} for trigger and quit signalling (momentary and breaker -// switches) -func T() C { - mx.Lock() - defer mx.Unlock() - msg := fmt.Sprintf("chan from %s", lol.GetLoc(1)) - l("created", msg) - createdList = append(createdList, msg) - o := make(C) - createdChannels = append(createdChannels, o) - createdChannelBufferCounts = append(createdChannelBufferCounts, 0) - return o -} - -// Ts creates a buffered chan struct{} which is specifically intended for signalling without -// blocking, generally one is the size of buffer to be used, though there might be conceivable -// cases where the channel should accept more signals without blocking the caller -func Ts(n int) C { - mx.Lock() - defer mx.Unlock() - msg := fmt.Sprintf("buffered chan (%d) from %s", n, lol.GetLoc(1)) - l("created", msg) - createdList = append(createdList, msg) - o := make(C, n) - createdChannels = append(createdChannels, o) - createdChannelBufferCounts = append(createdChannelBufferCounts, n) - return o -} - -// Q closes the channel, which makes it emit a nil every time it is selected. -func (c C) Q() { - open := !testChanIsClosed(c) - lc(func() (o string) { - lo := getLocForChan(c) - mx.Lock() - defer mx.Unlock() - if open { - return "closing chan from " + lo + "\n" + strings.Repeat(" ", - 48) + "from" + lol.GetLoc(1) - } else { - return "from" + lol.GetLoc(1) + "\n" + strings.Repeat(" ", 48) + - "channel " + lo + " was already closed" - } - }, - ) - if open { - close(c) - } -} - -// Signal sends struct{}{} on the channel which functions as a momentary switch, -// useful in pairs for stop/start -func (c C) Signal() { - lc(func() (o string) { return "signalling " + getLocForChan(c) }) - if !testChanIsClosed(c) { - c <- struct{}{} - } -} - -// Wait should be placed with a `<-` in a select case in addition to the channel -// variable name -func (c C) Wait() <-chan struct{} { - lc(func() (o string) { - return fmt.Sprint("waiting on "+getLocForChan(c)+"at", - lol.GetLoc(1)) - }) - return c -} - -// IsClosed exposes a test to see if the channel is closed -func (c C) IsClosed() bool { - return testChanIsClosed(c) -} - -// testChanIsClosed allows you to see whether the channel has been closed so you -// can avoid a panic by trying to close or signal on it -func testChanIsClosed(ch C) (o bool) { - if ch == nil { - return true - } - select { - case <-ch: - o = true - default: - } - return -} - -// getLocForChan finds which record connects to the channel in question -func getLocForChan(c C) (s string) { - s = "not found" - mx.Lock() - for i := range createdList { - if i >= len(createdChannels) { - break - } - if createdChannels[i] == c { - s = createdList[i] - } - } - mx.Unlock() - return -} - -// once a minute clean up the channel cache to remove closed channels no longer -// in use -func init() { - go func() { - for { - <-time.After(time.Minute) - l("cleaning up closed channels") - var c []C - var ll []string - mx.Lock() - for i := range createdChannels { - if i >= len(createdList) { - break - } - if testChanIsClosed(createdChannels[i]) { - } else { - c = append(c, createdChannels[i]) - ll = append(ll, createdList[i]) - } - } - createdChannels = c - createdList = ll - mx.Unlock() - } - }() -} - -// PrintChanState creates an output showing the current state of the channels -// being monitored This is a function for use by the programmer while debugging -func PrintChanState() { - mx.Lock() - for i := range createdChannels { - if i >= len(createdList) { - break - } - if testChanIsClosed(createdChannels[i]) { - log.T.Ln(">>> closed", createdList[i]) - } else { - log.T.Ln("<<< open", createdList[i]) - } - } - mx.Unlock() -} - -// GetOpenUnbufferedChanCount returns the number of qu channels that are still open -func GetOpenUnbufferedChanCount() (o int) { - mx.Lock() - var c int - for i := range createdChannels { - if i >= len(createdChannels) { - break - } - // skip buffered channels - if createdChannelBufferCounts[i] > 0 { - continue - } - if testChanIsClosed(createdChannels[i]) { - c++ - } else { - o++ - } - } - mx.Unlock() - return -} - -// GetOpenBufferedChanCount returns the number of qu channels that are still open -func GetOpenBufferedChanCount() (o int) { - mx.Lock() - var c int - for i := range createdChannels { - if i >= len(createdChannels) { - break - } - // skip unbuffered channels - if createdChannelBufferCounts[i] < 1 { - continue - } - if testChanIsClosed(createdChannels[i]) { - c++ - } else { - o++ - } - } - mx.Unlock() - return -} diff --git a/qu/util.go b/qu/util.go deleted file mode 100644 index 4ee89cf..0000000 --- a/qu/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package qu - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ratel/close.go b/ratel/close.go index a862f30..bf1ef43 100644 --- a/ratel/close.go +++ b/ratel/close.go @@ -1,5 +1,10 @@ package ratel +import ( + "realy.mleku.dev/chk" + "realy.mleku.dev/log" +) + // Close the database. If the Flatten flag was set, then trigger the flattening of tables before // shutting down. func (r *T) Close() (err error) { diff --git a/ratel/compact.go b/ratel/compact.go index dd9c97b..66fb3b7 100644 --- a/ratel/compact.go +++ b/ratel/compact.go @@ -1,6 +1,7 @@ package ratel import ( + "realy.mleku.dev/chk" "realy.mleku.dev/event" ) diff --git a/ratel/configuration.go b/ratel/configuration.go index c9f763b..5abc08d 100644 --- a/ratel/configuration.go +++ b/ratel/configuration.go @@ -5,6 +5,8 @@ import ( "github.com/dgraph-io/badger/v4" + "realy.mleku.dev/chk" + "realy.mleku.dev/log" "realy.mleku.dev/ratel/prefixes" "realy.mleku.dev/store" ) diff --git a/ratel/create-a-tag.go b/ratel/create-a-tag.go index 03219d7..0dc21fe 100644 --- a/ratel/create-a-tag.go +++ b/ratel/create-a-tag.go @@ -3,8 +3,10 @@ package ratel import ( "strings" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/schnorr" "realy.mleku.dev/hex" + "realy.mleku.dev/log" "realy.mleku.dev/ratel/keys" "realy.mleku.dev/ratel/keys/arb" "realy.mleku.dev/ratel/keys/createdat" diff --git a/ratel/del/util.go b/ratel/del/util.go deleted file mode 100644 index b1d41fd..0000000 --- a/ratel/del/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package del - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ratel/deleteevent.go b/ratel/deleteevent.go index 1e4e3d2..6fab717 100644 --- a/ratel/deleteevent.go +++ b/ratel/deleteevent.go @@ -3,9 +3,11 @@ package ratel import ( "github.com/dgraph-io/badger/v4" + "realy.mleku.dev/chk" "realy.mleku.dev/context" "realy.mleku.dev/event" "realy.mleku.dev/eventid" + "realy.mleku.dev/log" "realy.mleku.dev/ratel/keys" "realy.mleku.dev/ratel/keys/createdat" "realy.mleku.dev/ratel/keys/id" diff --git a/ratel/export.go b/ratel/export.go index ea593ff..8f67839 100644 --- a/ratel/export.go +++ b/ratel/export.go @@ -7,11 +7,12 @@ import ( "github.com/dgraph-io/badger/v4" + "realy.mleku.dev/chk" "realy.mleku.dev/context" "realy.mleku.dev/event" "realy.mleku.dev/filter" "realy.mleku.dev/hex" - "realy.mleku.dev/qu" + "realy.mleku.dev/log" "realy.mleku.dev/ratel/keys/serial" "realy.mleku.dev/ratel/prefixes" "realy.mleku.dev/sha256" @@ -51,7 +52,7 @@ func (r *T) Export(c context.T, w io.Writer, pubkeys ...[]byte) { } queries = append(queries, queries2...) // start up writer loop - quit := qu.T() + quit := make(chan struct{}) go func() { for { select { @@ -101,7 +102,7 @@ func (r *T) Export(c context.T, w io.Writer, pubkeys ...[]byte) { } }() // stop the writer loop - defer quit.Q() + defer close(quit) for _, q := range queries { select { case <-r.Ctx.Done(): diff --git a/ratel/fetch-ids.go b/ratel/fetch-ids.go index 780385e..c6560e3 100644 --- a/ratel/fetch-ids.go +++ b/ratel/fetch-ids.go @@ -5,8 +5,10 @@ import ( "github.com/dgraph-io/badger/v4" + "realy.mleku.dev/chk" "realy.mleku.dev/context" "realy.mleku.dev/event" + "realy.mleku.dev/log" "realy.mleku.dev/ratel/keys/id" "realy.mleku.dev/ratel/keys/serial" "realy.mleku.dev/ratel/prefixes" diff --git a/ratel/garbagecollector.go b/ratel/garbagecollector.go index 1a2dc10..205223c 100644 --- a/ratel/garbagecollector.go +++ b/ratel/garbagecollector.go @@ -3,6 +3,8 @@ package ratel import ( "time" + "realy.mleku.dev/chk" + "realy.mleku.dev/log" "realy.mleku.dev/units" ) diff --git a/ratel/gccount.go b/ratel/gccount.go index c616cd8..6b6c307 100644 --- a/ratel/gccount.go +++ b/ratel/gccount.go @@ -9,6 +9,8 @@ import ( "github.com/dgraph-io/badger/v4" + "realy.mleku.dev/chk" + "realy.mleku.dev/log" "realy.mleku.dev/ratel/keys/count" "realy.mleku.dev/ratel/keys/createdat" "realy.mleku.dev/ratel/keys/index" diff --git a/ratel/gcmark.go b/ratel/gcmark.go index 8c7feee..d43f8b5 100644 --- a/ratel/gcmark.go +++ b/ratel/gcmark.go @@ -3,6 +3,8 @@ package ratel import ( "sort" + "realy.mleku.dev/chk" + "realy.mleku.dev/log" "realy.mleku.dev/ratel/keys/count" "realy.mleku.dev/units" ) diff --git a/ratel/gcsweep.go b/ratel/gcsweep.go index 8bf51d0..8f00663 100644 --- a/ratel/gcsweep.go +++ b/ratel/gcsweep.go @@ -5,7 +5,9 @@ import ( "github.com/dgraph-io/badger/v4" + "realy.mleku.dev/chk" "realy.mleku.dev/event" + "realy.mleku.dev/log" "realy.mleku.dev/ratel/keys/serial" "realy.mleku.dev/ratel/prefixes" "realy.mleku.dev/sha256" diff --git a/ratel/getindexkeysforevent.go b/ratel/getindexkeysforevent.go index 4f4b303..f201723 100644 --- a/ratel/getindexkeysforevent.go +++ b/ratel/getindexkeysforevent.go @@ -3,8 +3,10 @@ package ratel import ( "bytes" + "realy.mleku.dev/chk" "realy.mleku.dev/event" "realy.mleku.dev/eventid" + "realy.mleku.dev/log" "realy.mleku.dev/ratel/keys" "realy.mleku.dev/ratel/keys/createdat" "realy.mleku.dev/ratel/keys/fullid" diff --git a/ratel/gettagkeyprefix.go b/ratel/gettagkeyprefix.go index 54f734b..d564f7c 100644 --- a/ratel/gettagkeyprefix.go +++ b/ratel/gettagkeyprefix.go @@ -2,6 +2,7 @@ package ratel import ( eventstore "realy.mleku.dev/addresstag" + "realy.mleku.dev/chk" "realy.mleku.dev/hex" "realy.mleku.dev/ratel/keys" "realy.mleku.dev/ratel/keys/arb" diff --git a/ratel/import.go b/ratel/import.go index e8271d1..2007982 100644 --- a/ratel/import.go +++ b/ratel/import.go @@ -4,7 +4,9 @@ import ( "bufio" "io" + "realy.mleku.dev/chk" "realy.mleku.dev/event" + "realy.mleku.dev/log" ) const maxLen = 500000000 diff --git a/ratel/init.go b/ratel/init.go index 92d1930..a4f4440 100644 --- a/ratel/init.go +++ b/ratel/init.go @@ -8,6 +8,8 @@ import ( "github.com/dgraph-io/badger/v4" "github.com/dgraph-io/badger/v4/options" + "realy.mleku.dev/chk" + "realy.mleku.dev/log" "realy.mleku.dev/ratel/prefixes" "realy.mleku.dev/units" ) diff --git a/ratel/keys/arb/arb.go b/ratel/keys/arb/arb.go index 2d821e5..fec07c1 100644 --- a/ratel/keys/arb/arb.go +++ b/ratel/keys/arb/arb.go @@ -7,6 +7,8 @@ import ( "bytes" "io" + "realy.mleku.dev/chk" + "realy.mleku.dev/log" "realy.mleku.dev/ratel/keys" ) diff --git a/ratel/keys/arb/util.go b/ratel/keys/arb/util.go deleted file mode 100644 index 75590e0..0000000 --- a/ratel/keys/arb/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package arb - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ratel/keys/count/util.go b/ratel/keys/count/util.go deleted file mode 100644 index 3ae6554..0000000 --- a/ratel/keys/count/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package count - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ratel/keys/createdat/createdat.go b/ratel/keys/createdat/createdat.go index 40e50d5..12d326c 100644 --- a/ratel/keys/createdat/createdat.go +++ b/ratel/keys/createdat/createdat.go @@ -5,6 +5,8 @@ import ( "encoding/binary" "io" + "realy.mleku.dev/chk" + "realy.mleku.dev/errorf" "realy.mleku.dev/ratel/keys" "realy.mleku.dev/ratel/keys/serial" "realy.mleku.dev/timestamp" diff --git a/ratel/keys/createdat/util.go b/ratel/keys/createdat/util.go deleted file mode 100644 index 5f6cba9..0000000 --- a/ratel/keys/createdat/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package createdat - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ratel/keys/fullid/fullid.go b/ratel/keys/fullid/fullid.go index 9b4ea45..bbb417c 100644 --- a/ratel/keys/fullid/fullid.go +++ b/ratel/keys/fullid/fullid.go @@ -5,6 +5,7 @@ import ( "fmt" "io" + "realy.mleku.dev/chk" "realy.mleku.dev/ratel/keys" "realy.mleku.dev/sha256" diff --git a/ratel/keys/fullid/util.go b/ratel/keys/fullid/util.go deleted file mode 100644 index dfb534f..0000000 --- a/ratel/keys/fullid/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package fullid - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ratel/keys/fullpubkey/fullpubkey.go b/ratel/keys/fullpubkey/fullpubkey.go index bb0f1e6..46dc2c0 100644 --- a/ratel/keys/fullpubkey/fullpubkey.go +++ b/ratel/keys/fullpubkey/fullpubkey.go @@ -6,6 +6,7 @@ import ( "fmt" "io" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/schnorr" "realy.mleku.dev/ratel/keys" ) diff --git a/ratel/keys/fullpubkey/util.go b/ratel/keys/fullpubkey/util.go deleted file mode 100644 index cd7cbff..0000000 --- a/ratel/keys/fullpubkey/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package fullpubkey - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ratel/keys/id/id.go b/ratel/keys/id/id.go index 1450a90..197cb0d 100644 --- a/ratel/keys/id/id.go +++ b/ratel/keys/id/id.go @@ -7,6 +7,8 @@ import ( "io" "strings" + "realy.mleku.dev/chk" + "realy.mleku.dev/errorf" "realy.mleku.dev/ratel/keys" "realy.mleku.dev/sha256" diff --git a/ratel/keys/id/id_test.go b/ratel/keys/id/id_test.go index ec427e9..809d754 100644 --- a/ratel/keys/id/id_test.go +++ b/ratel/keys/id/id_test.go @@ -5,6 +5,7 @@ import ( "testing" "lukechampine.com/frand" + "realy.mleku.dev/eventid" "realy.mleku.dev/sha256" ) diff --git a/ratel/keys/id/util.go b/ratel/keys/id/util.go deleted file mode 100644 index 11bd378..0000000 --- a/ratel/keys/id/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package id - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ratel/keys/index/index.go b/ratel/keys/index/index.go index f616457..0f4716f 100644 --- a/ratel/keys/index/index.go +++ b/ratel/keys/index/index.go @@ -7,6 +7,7 @@ import ( "fmt" "io" + "realy.mleku.dev/chk" "realy.mleku.dev/ratel/keys" ) diff --git a/ratel/keys/index/util.go b/ratel/keys/index/util.go deleted file mode 100644 index c62b717..0000000 --- a/ratel/keys/index/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package index - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ratel/keys/kinder/kind.go b/ratel/keys/kinder/kind.go index 58391f3..a503a6d 100644 --- a/ratel/keys/kinder/kind.go +++ b/ratel/keys/kinder/kind.go @@ -6,6 +6,7 @@ import ( "encoding/binary" "io" + "realy.mleku.dev/chk" "realy.mleku.dev/kind" "realy.mleku.dev/ratel/keys" ) diff --git a/ratel/keys/kinder/util.go b/ratel/keys/kinder/util.go deleted file mode 100644 index cedfa8b..0000000 --- a/ratel/keys/kinder/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package kinder - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ratel/keys/pubkey/pubkey.go b/ratel/keys/pubkey/pubkey.go index a2b785d..35c669c 100644 --- a/ratel/keys/pubkey/pubkey.go +++ b/ratel/keys/pubkey/pubkey.go @@ -6,7 +6,9 @@ import ( "fmt" "io" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/schnorr" + "realy.mleku.dev/log" "realy.mleku.dev/ratel/keys" ) diff --git a/ratel/keys/pubkey/pubkey_test.go b/ratel/keys/pubkey/pubkey_test.go index 020ed31..56e1d1e 100644 --- a/ratel/keys/pubkey/pubkey_test.go +++ b/ratel/keys/pubkey/pubkey_test.go @@ -6,6 +6,7 @@ import ( "lukechampine.com/frand" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/schnorr" ) diff --git a/ratel/keys/pubkey/util.go b/ratel/keys/pubkey/util.go deleted file mode 100644 index e77d95f..0000000 --- a/ratel/keys/pubkey/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package pubkey - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ratel/keys/serial/serial.go b/ratel/keys/serial/serial.go index 2732098..f196a2b 100644 --- a/ratel/keys/serial/serial.go +++ b/ratel/keys/serial/serial.go @@ -8,6 +8,7 @@ import ( "fmt" "io" + "realy.mleku.dev/chk" "realy.mleku.dev/ratel/keys" ) diff --git a/ratel/keys/serial/util.go b/ratel/keys/serial/util.go deleted file mode 100644 index 563841b..0000000 --- a/ratel/keys/serial/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package serial - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ratel/keys/tombstone/tombstone.go b/ratel/keys/tombstone/tombstone.go index 1408823..cea4de3 100644 --- a/ratel/keys/tombstone/tombstone.go +++ b/ratel/keys/tombstone/tombstone.go @@ -5,7 +5,9 @@ package tombstone import ( "io" + "realy.mleku.dev/chk" "realy.mleku.dev/eventid" + "realy.mleku.dev/log" "realy.mleku.dev/ratel/keys" ) diff --git a/ratel/keys/tombstone/util.go b/ratel/keys/tombstone/util.go deleted file mode 100644 index 6106878..0000000 --- a/ratel/keys/tombstone/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package tombstone - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ratel/keys/util.go b/ratel/keys/util.go deleted file mode 100644 index fcd4be4..0000000 --- a/ratel/keys/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package keys - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ratel/keys/util_test.go b/ratel/keys/util_test.go deleted file mode 100644 index bc7fcea..0000000 --- a/ratel/keys/util_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package keys_test - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ratel/log.go b/ratel/log.go index 10e59fa..ddd6429 100644 --- a/ratel/log.go +++ b/ratel/log.go @@ -6,6 +6,7 @@ import ( "strings" "realy.mleku.dev/atomic" + "realy.mleku.dev/log" "realy.mleku.dev/lol" ) diff --git a/ratel/main.go b/ratel/main.go index fbed0d9..86bfbdd 100644 --- a/ratel/main.go +++ b/ratel/main.go @@ -10,6 +10,7 @@ import ( "github.com/dgraph-io/badger/v4" + "realy.mleku.dev/chk" "realy.mleku.dev/context" "realy.mleku.dev/ratel/keys/serial" "realy.mleku.dev/ratel/prefixes" diff --git a/ratel/nuke.go b/ratel/nuke.go index cb5c4f4..1a6ca51 100644 --- a/ratel/nuke.go +++ b/ratel/nuke.go @@ -1,6 +1,8 @@ package ratel import ( + "realy.mleku.dev/chk" + "realy.mleku.dev/log" "realy.mleku.dev/ratel/prefixes" ) diff --git a/ratel/prefixes/util.go b/ratel/prefixes/util.go deleted file mode 100644 index b1d715e..0000000 --- a/ratel/prefixes/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package prefixes - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ratel/preparequeries.go b/ratel/preparequeries.go index 1f6a258..4841bbd 100644 --- a/ratel/preparequeries.go +++ b/ratel/preparequeries.go @@ -5,9 +5,12 @@ import ( "fmt" "math" + "realy.mleku.dev/chk" + "realy.mleku.dev/errorf" "realy.mleku.dev/event" "realy.mleku.dev/eventid" "realy.mleku.dev/filter" + "realy.mleku.dev/log" "realy.mleku.dev/ratel/keys/id" "realy.mleku.dev/ratel/keys/kinder" "realy.mleku.dev/ratel/keys/pubkey" diff --git a/ratel/queryevents.go b/ratel/queryevents.go index d80950b..de07474 100644 --- a/ratel/queryevents.go +++ b/ratel/queryevents.go @@ -8,11 +8,13 @@ import ( "github.com/dgraph-io/badger/v4" + "realy.mleku.dev/chk" "realy.mleku.dev/context" "realy.mleku.dev/event" "realy.mleku.dev/eventid" "realy.mleku.dev/filter" "realy.mleku.dev/hex" + "realy.mleku.dev/log" "realy.mleku.dev/ratel/keys/createdat" "realy.mleku.dev/ratel/keys/serial" "realy.mleku.dev/ratel/prefixes" diff --git a/ratel/queryforids.go b/ratel/queryforids.go index ae29b72..44c38b0 100644 --- a/ratel/queryforids.go +++ b/ratel/queryforids.go @@ -7,11 +7,13 @@ import ( "github.com/dgraph-io/badger/v4" + "realy.mleku.dev/chk" "realy.mleku.dev/context" "realy.mleku.dev/event" "realy.mleku.dev/eventid" "realy.mleku.dev/filter" "realy.mleku.dev/hex" + "realy.mleku.dev/log" "realy.mleku.dev/ratel/keys" "realy.mleku.dev/ratel/keys/createdat" "realy.mleku.dev/ratel/keys/fullid" diff --git a/ratel/rescan.go b/ratel/rescan.go index 695e9c0..8baabf4 100644 --- a/ratel/rescan.go +++ b/ratel/rescan.go @@ -3,7 +3,9 @@ package ratel import ( "github.com/dgraph-io/badger/v4" + "realy.mleku.dev/chk" "realy.mleku.dev/event" + "realy.mleku.dev/log" "realy.mleku.dev/ratel/keys" "realy.mleku.dev/ratel/keys/createdat" "realy.mleku.dev/ratel/keys/serial" diff --git a/ratel/saveevent.go b/ratel/saveevent.go index b38f2bb..c2726e6 100644 --- a/ratel/saveevent.go +++ b/ratel/saveevent.go @@ -3,7 +3,9 @@ package ratel import ( "github.com/dgraph-io/badger/v4" + "realy.mleku.dev/chk" "realy.mleku.dev/context" + "realy.mleku.dev/errorf" "realy.mleku.dev/event" "realy.mleku.dev/eventid" "realy.mleku.dev/ratel/keys" diff --git a/ratel/util.go b/ratel/util.go deleted file mode 100644 index a0e7ebb..0000000 --- a/ratel/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package ratel - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/realy/addEvent.go b/realy/addEvent.go index 17c06ca..597dd55 100644 --- a/realy/addEvent.go +++ b/realy/addEvent.go @@ -9,6 +9,7 @@ import ( "realy.mleku.dev/context" "realy.mleku.dev/event" + "realy.mleku.dev/log" "realy.mleku.dev/normalize" "realy.mleku.dev/relay" "realy.mleku.dev/socketapi" diff --git a/realy/auth.go b/realy/auth.go index 79144e5..827b26f 100644 --- a/realy/auth.go +++ b/realy/auth.go @@ -6,6 +6,7 @@ import ( "net/http" "time" + "realy.mleku.dev/chk" "realy.mleku.dev/httpauth" ) diff --git a/realy/config/config.go b/realy/config/config.go index b705490..174a0e4 100644 --- a/realy/config/config.go +++ b/realy/config/config.go @@ -17,7 +17,9 @@ import ( "realy.mleku.dev" "realy.mleku.dev/apputil" + "realy.mleku.dev/chk" "realy.mleku.dev/config" + "realy.mleku.dev/log" ) // C is the configuration for realy relay. These are read from the environment if present, or if diff --git a/realy/config/util.go b/realy/config/util.go deleted file mode 100644 index 995d47a..0000000 --- a/realy/config/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package config - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/realy/disconnect.go b/realy/disconnect.go index e3b3ffd..dfa9b97 100644 --- a/realy/disconnect.go +++ b/realy/disconnect.go @@ -1,5 +1,9 @@ package realy +import ( + "realy.mleku.dev/log" +) + func (s *Server) disconnect() { for client := range s.clients { log.I.F("closing client %s", client.RemoteAddr()) diff --git a/realy/handleRelayinfo.go b/realy/handleRelayinfo.go index 3492c4c..f97e792 100644 --- a/realy/handleRelayinfo.go +++ b/realy/handleRelayinfo.go @@ -6,6 +6,8 @@ import ( "sort" "realy.mleku.dev" + "realy.mleku.dev/chk" + "realy.mleku.dev/log" "realy.mleku.dev/relay" "realy.mleku.dev/relayinfo" "realy.mleku.dev/store" diff --git a/realy/options/util.go b/realy/options/util.go deleted file mode 100644 index 2323c97..0000000 --- a/realy/options/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package options - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/realy/publish/util.go b/realy/publish/util.go deleted file mode 100644 index e928e7f..0000000 --- a/realy/publish/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package publish - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/realy/server-publish.go b/realy/server-publish.go index c0c96a9..278e5c1 100644 --- a/realy/server-publish.go +++ b/realy/server-publish.go @@ -5,10 +5,13 @@ import ( "errors" "fmt" + "realy.mleku.dev/chk" "realy.mleku.dev/context" + "realy.mleku.dev/errorf" "realy.mleku.dev/event" "realy.mleku.dev/filter" "realy.mleku.dev/kinds" + "realy.mleku.dev/log" "realy.mleku.dev/normalize" "realy.mleku.dev/store" "realy.mleku.dev/tag" diff --git a/realy/server.go b/realy/server.go index 7c55892..7a5c3c6 100644 --- a/realy/server.go +++ b/realy/server.go @@ -16,7 +16,9 @@ import ( "github.com/rs/cors" realy_lol "realy.mleku.dev" + "realy.mleku.dev/chk" "realy.mleku.dev/context" + "realy.mleku.dev/log" "realy.mleku.dev/openapi" "realy.mleku.dev/realy/helpers" "realy.mleku.dev/realy/options" diff --git a/realy/server_test.go b/realy/server_test.go index 414f83c..1cfbee8 100644 --- a/realy/server_test.go +++ b/realy/server_test.go @@ -8,6 +8,7 @@ import ( "github.com/gobwas/ws/wsutil" + "realy.mleku.dev/chk" "realy.mleku.dev/context" "realy.mleku.dev/ratel" "realy.mleku.dev/ws" diff --git a/realy/util.go b/realy/util.go deleted file mode 100644 index 2dc1599..0000000 --- a/realy/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package realy - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/relay/util.go b/relay/util.go deleted file mode 100644 index c0439d8..0000000 --- a/relay/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package relay - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/relayinfo/fetch.go b/relayinfo/fetch.go index 85bf009..243a9fb 100644 --- a/relayinfo/fetch.go +++ b/relayinfo/fetch.go @@ -6,7 +6,9 @@ import ( "net/http" "time" + "realy.mleku.dev/chk" "realy.mleku.dev/context" + "realy.mleku.dev/errorf" "realy.mleku.dev/normalize" ) diff --git a/relayinfo/types.go b/relayinfo/types.go index d2ca812..b1e3773 100644 --- a/relayinfo/types.go +++ b/relayinfo/types.go @@ -7,7 +7,9 @@ import ( "sort" "sync" + "realy.mleku.dev/chk" "realy.mleku.dev/kinds" + "realy.mleku.dev/log" "realy.mleku.dev/number" "realy.mleku.dev/timestamp" ) diff --git a/relayinfo/util.go b/relayinfo/util.go deleted file mode 100644 index 03054ac..0000000 --- a/relayinfo/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package relayinfo - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/sha256/util.go b/sha256/util.go deleted file mode 100644 index 2821802..0000000 --- a/sha256/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package sha256 - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/signer/util.go b/signer/util.go deleted file mode 100644 index 6b40cd3..0000000 --- a/signer/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package signer - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/socketapi/challenge.go b/socketapi/challenge.go index 9f61601..e2f84d6 100644 --- a/socketapi/challenge.go +++ b/socketapi/challenge.go @@ -7,6 +7,7 @@ import ( "github.com/fasthttp/websocket" "realy.mleku.dev/bech32encoding" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/bech32" "realy.mleku.dev/ws" ) diff --git a/socketapi/handleAuth.go b/socketapi/handleAuth.go index 8cc7a75..2681201 100644 --- a/socketapi/handleAuth.go +++ b/socketapi/handleAuth.go @@ -2,8 +2,10 @@ package socketapi import ( "realy.mleku.dev/auth" + "realy.mleku.dev/chk" "realy.mleku.dev/envelopes/authenvelope" "realy.mleku.dev/envelopes/okenvelope" + "realy.mleku.dev/log" "realy.mleku.dev/normalize" "realy.mleku.dev/realy/interfaces" "realy.mleku.dev/relay" diff --git a/socketapi/handleClose.go b/socketapi/handleClose.go index 8d9e2a9..311b640 100644 --- a/socketapi/handleClose.go +++ b/socketapi/handleClose.go @@ -1,7 +1,9 @@ package socketapi import ( + "realy.mleku.dev/chk" "realy.mleku.dev/envelopes/closeenvelope" + "realy.mleku.dev/log" "realy.mleku.dev/realy/interfaces" ) diff --git a/socketapi/handleEvent.go b/socketapi/handleEvent.go index fff1669..b81340d 100644 --- a/socketapi/handleEvent.go +++ b/socketapi/handleEvent.go @@ -4,6 +4,7 @@ import ( "bytes" "strings" + "realy.mleku.dev/chk" "realy.mleku.dev/context" "realy.mleku.dev/envelopes/authenvelope" "realy.mleku.dev/envelopes/eventenvelope" @@ -13,6 +14,7 @@ import ( "realy.mleku.dev/hex" "realy.mleku.dev/ints" "realy.mleku.dev/kind" + "realy.mleku.dev/log" "realy.mleku.dev/normalize" "realy.mleku.dev/realy/interfaces" "realy.mleku.dev/relay" diff --git a/socketapi/handleMessage.go b/socketapi/handleMessage.go index ed0ae04..a46a101 100644 --- a/socketapi/handleMessage.go +++ b/socketapi/handleMessage.go @@ -3,12 +3,14 @@ package socketapi import ( "fmt" + "realy.mleku.dev/chk" "realy.mleku.dev/envelopes" "realy.mleku.dev/envelopes/authenvelope" "realy.mleku.dev/envelopes/closeenvelope" "realy.mleku.dev/envelopes/eventenvelope" "realy.mleku.dev/envelopes/noticeenvelope" "realy.mleku.dev/envelopes/reqenvelope" + "realy.mleku.dev/log" "realy.mleku.dev/relay" ) @@ -17,7 +19,7 @@ func (a *A) HandleMessage(msg []byte) { var err error var t string var rem []byte - if t, rem, err = envelopes.Identify(msg); chk.E(err) { + if t, rem = envelopes.Identify(msg); chk.E(err) { notice = []byte(err.Error()) } rl := a.Relay() diff --git a/socketapi/handleReq.go b/socketapi/handleReq.go index 39be32e..3fe412e 100644 --- a/socketapi/handleReq.go +++ b/socketapi/handleReq.go @@ -6,6 +6,7 @@ import ( "github.com/dgraph-io/badger/v4" + "realy.mleku.dev/chk" "realy.mleku.dev/context" "realy.mleku.dev/envelopes/authenvelope" "realy.mleku.dev/envelopes/closedenvelope" @@ -17,6 +18,7 @@ import ( "realy.mleku.dev/hex" "realy.mleku.dev/kind" "realy.mleku.dev/kinds" + "realy.mleku.dev/log" "realy.mleku.dev/normalize" "realy.mleku.dev/realy/interfaces" "realy.mleku.dev/realy/options" diff --git a/socketapi/handleWebsocket.go b/socketapi/handleWebsocket.go deleted file mode 100644 index e5f9927..0000000 --- a/socketapi/handleWebsocket.go +++ /dev/null @@ -1 +0,0 @@ -package socketapi diff --git a/socketapi/pinger.go b/socketapi/pinger.go index 312d3d7..a9e716f 100644 --- a/socketapi/pinger.go +++ b/socketapi/pinger.go @@ -6,6 +6,7 @@ import ( "github.com/fasthttp/websocket" "realy.mleku.dev/context" + "realy.mleku.dev/log" "realy.mleku.dev/realy/interfaces" ) diff --git a/socketapi/publisher.go b/socketapi/publisher.go index 26beec3..cebd3ff 100644 --- a/socketapi/publisher.go +++ b/socketapi/publisher.go @@ -5,6 +5,7 @@ import ( "regexp" "sync" + "realy.mleku.dev/chk" "realy.mleku.dev/envelopes/eventenvelope" "realy.mleku.dev/event" "realy.mleku.dev/filters" diff --git a/socketapi/socketapi.go b/socketapi/socketapi.go index ea3b6ff..b9d7c52 100644 --- a/socketapi/socketapi.go +++ b/socketapi/socketapi.go @@ -7,8 +7,10 @@ import ( "github.com/fasthttp/websocket" + "realy.mleku.dev/chk" "realy.mleku.dev/context" "realy.mleku.dev/envelopes/authenvelope" + "realy.mleku.dev/log" "realy.mleku.dev/realy/interfaces" "realy.mleku.dev/units" "realy.mleku.dev/ws" diff --git a/socketapi/util.go b/socketapi/util.go deleted file mode 100644 index 5bd0b4d..0000000 --- a/socketapi/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package socketapi - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/store/util.go b/store/util.go deleted file mode 100644 index 98948dd..0000000 --- a/store/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package store - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/subscription/subscriptionid.go b/subscription/subscriptionid.go index c16b23e..70fc049 100644 --- a/subscription/subscriptionid.go +++ b/subscription/subscriptionid.go @@ -6,7 +6,10 @@ package subscription import ( "crypto/rand" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/bech32" + "realy.mleku.dev/errorf" + "realy.mleku.dev/log" "realy.mleku.dev/text" ) diff --git a/subscription/subscriptionid_test.go b/subscription/subscriptionid_test.go index 5d74f7c..f4a215e 100644 --- a/subscription/subscriptionid_test.go +++ b/subscription/subscriptionid_test.go @@ -5,6 +5,8 @@ import ( "testing" "lukechampine.com/frand" + + "realy.mleku.dev/chk" ) func TestMarshalUnmarshal(t *testing.T) { diff --git a/subscription/util.go b/subscription/util.go deleted file mode 100644 index bf71e0a..0000000 --- a/subscription/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package subscription - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/tag/atag/atag.go b/tag/atag/atag.go index 05b4f5d..ad11850 100644 --- a/tag/atag/atag.go +++ b/tag/atag/atag.go @@ -5,6 +5,7 @@ package atag import ( "bytes" + "realy.mleku.dev/chk" "realy.mleku.dev/hex" "realy.mleku.dev/ints" "realy.mleku.dev/kind" diff --git a/tag/atag/atag_test.go b/tag/atag/atag_test.go index 86f6872..8c00617 100644 --- a/tag/atag/atag_test.go +++ b/tag/atag/atag_test.go @@ -7,9 +7,11 @@ import ( "lukechampine.com/frand" + "realy.mleku.dev/chk" "realy.mleku.dev/ec/schnorr" "realy.mleku.dev/hex" "realy.mleku.dev/kind" + "realy.mleku.dev/log" ) func TestT_Marshal_Unmarshal(t *testing.T) { diff --git a/tag/atag/util.go b/tag/atag/util.go deleted file mode 100644 index a4304ed..0000000 --- a/tag/atag/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package atag - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/tag/tag.go b/tag/tag.go index 407174e..f140e09 100644 --- a/tag/tag.go +++ b/tag/tag.go @@ -6,6 +6,8 @@ package tag import ( "bytes" + "realy.mleku.dev/errorf" + "realy.mleku.dev/log" "realy.mleku.dev/normalize" "realy.mleku.dev/text" ) diff --git a/tag/tag_test.go b/tag/tag_test.go index 9ee40be..55aeff8 100644 --- a/tag/tag_test.go +++ b/tag/tag_test.go @@ -5,6 +5,9 @@ import ( "testing" "lukechampine.com/frand" + + "realy.mleku.dev/chk" + "realy.mleku.dev/log" ) func TestMarshalUnmarshal(t *testing.T) { diff --git a/tag/util.go b/tag/util.go deleted file mode 100644 index 5170b5f..0000000 --- a/tag/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package tag - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/tags/tags.go b/tags/tags.go index 5c56da3..0992481 100644 --- a/tags/tags.go +++ b/tags/tags.go @@ -10,6 +10,8 @@ import ( "os" "sort" + "realy.mleku.dev/chk" + "realy.mleku.dev/log" "realy.mleku.dev/lol" "realy.mleku.dev/tag" ) diff --git a/tags/tags_test.go b/tags/tags_test.go index 0c6078d..464f125 100644 --- a/tags/tags_test.go +++ b/tags/tags_test.go @@ -6,7 +6,9 @@ import ( "lukechampine.com/frand" + "realy.mleku.dev/chk" "realy.mleku.dev/hex" + "realy.mleku.dev/log" "realy.mleku.dev/tag" ) diff --git a/tags/util.go b/tags/util.go deleted file mode 100644 index 5be1b8e..0000000 --- a/tags/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package tags - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/tests/generate.go b/tests/generate.go index 03d18be..5b28386 100644 --- a/tests/generate.go +++ b/tests/generate.go @@ -7,6 +7,7 @@ import ( "lukechampine.com/frand" + "realy.mleku.dev/chk" "realy.mleku.dev/event" "realy.mleku.dev/kind" "realy.mleku.dev/p256k" diff --git a/tests/util.go b/tests/util.go deleted file mode 100644 index 02a6020..0000000 --- a/tests/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package tests - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/text/escape_test.go b/text/escape_test.go index c89fd66..6a289f8 100644 --- a/text/escape_test.go +++ b/text/escape_test.go @@ -5,6 +5,7 @@ import ( "lukechampine.com/frand" + "realy.mleku.dev/chk" "realy.mleku.dev/sha256" ) diff --git a/text/helpers.go b/text/helpers.go index addee81..314b436 100644 --- a/text/helpers.go +++ b/text/helpers.go @@ -6,6 +6,8 @@ import ( "github.com/templexxx/xhex" + "realy.mleku.dev/chk" + "realy.mleku.dev/errorf" "realy.mleku.dev/hex" ) diff --git a/text/helpers_test.go b/text/helpers_test.go index fc98a36..d7d985c 100644 --- a/text/helpers_test.go +++ b/text/helpers_test.go @@ -6,6 +6,7 @@ import ( "lukechampine.com/frand" + "realy.mleku.dev/chk" "realy.mleku.dev/hex" "realy.mleku.dev/sha256" ) diff --git a/text/hex.go b/text/hex.go index 4f0a333..17e99d8 100644 --- a/text/hex.go +++ b/text/hex.go @@ -1,6 +1,7 @@ package text import ( + "realy.mleku.dev/chk" "realy.mleku.dev/hex" ) diff --git a/text/util.go b/text/util.go deleted file mode 100644 index c708727..0000000 --- a/text/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package text - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/timestamp/timestamp.go b/timestamp/timestamp.go index 09bb502..252db0b 100644 --- a/timestamp/timestamp.go +++ b/timestamp/timestamp.go @@ -7,6 +7,8 @@ import ( "time" "unsafe" + "realy.mleku.dev/chk" + "realy.mleku.dev/errorf" "realy.mleku.dev/ints" ) diff --git a/timestamp/util.go b/timestamp/util.go deleted file mode 100644 index 1339726..0000000 --- a/timestamp/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package timestamp - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/units/util.go b/units/util.go deleted file mode 100644 index 6f4b181..0000000 --- a/units/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package units - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -) diff --git a/ws/client.go b/ws/client.go index e708e33..381192b 100644 --- a/ws/client.go +++ b/ws/client.go @@ -13,6 +13,7 @@ import ( "realy.mleku.dev/atomic" "realy.mleku.dev/auth" + "realy.mleku.dev/chk" "realy.mleku.dev/context" "realy.mleku.dev/envelopes" "realy.mleku.dev/envelopes/authenvelope" @@ -22,10 +23,12 @@ import ( "realy.mleku.dev/envelopes/eventenvelope" "realy.mleku.dev/envelopes/noticeenvelope" "realy.mleku.dev/envelopes/okenvelope" + "realy.mleku.dev/errorf" "realy.mleku.dev/event" "realy.mleku.dev/filter" "realy.mleku.dev/filters" "realy.mleku.dev/kind" + "realy.mleku.dev/log" "realy.mleku.dev/normalize" "realy.mleku.dev/signer" ) @@ -211,7 +214,7 @@ func (r *Client) ConnectWithTLS(ctx context.T, tlsConfig *tls.Config) error { log.D.F("{%s} %v\n", r.URL, message) var t string - if t, message, err = envelopes.Identify(message); chk.E(err) { + if t, message = envelopes.Identify(message); chk.E(err) { continue } switch t { diff --git a/ws/client_test.go b/ws/client_test.go index 5ef2f01..4114cdb 100644 --- a/ws/client_test.go +++ b/ws/client_test.go @@ -15,6 +15,7 @@ import ( "golang.org/x/net/websocket" + "realy.mleku.dev/chk" "realy.mleku.dev/envelopes/eventenvelope" "realy.mleku.dev/envelopes/okenvelope" "realy.mleku.dev/event" diff --git a/ws/connection.go b/ws/connection.go index d2d21ef..8197d3b 100644 --- a/ws/connection.go +++ b/ws/connection.go @@ -14,7 +14,10 @@ import ( "github.com/gobwas/ws/wsflate" "github.com/gobwas/ws/wsutil" + "realy.mleku.dev/chk" "realy.mleku.dev/context" + "realy.mleku.dev/errorf" + "realy.mleku.dev/log" ) // Connection is an outbound client -> relay connection. diff --git a/ws/listener.go b/ws/listener.go index da918bc..33ea423 100644 --- a/ws/listener.go +++ b/ws/listener.go @@ -9,6 +9,7 @@ import ( "github.com/fasthttp/websocket" "realy.mleku.dev/atomic" + "realy.mleku.dev/log" ) // Listener is a websocket implementation for a relay listener. diff --git a/ws/pool.go b/ws/pool.go index bde0eb2..e6ef657 100644 --- a/ws/pool.go +++ b/ws/pool.go @@ -10,10 +10,13 @@ import ( "github.com/puzpuzpuz/xsync/v3" + "realy.mleku.dev/chk" "realy.mleku.dev/context" + "realy.mleku.dev/errorf" "realy.mleku.dev/event" "realy.mleku.dev/filter" "realy.mleku.dev/filters" + "realy.mleku.dev/log" "realy.mleku.dev/normalize" "realy.mleku.dev/signer" "realy.mleku.dev/timestamp" diff --git a/ws/subscription.go b/ws/subscription.go index e38d930..1a2269b 100644 --- a/ws/subscription.go +++ b/ws/subscription.go @@ -5,12 +5,15 @@ import ( "sync" "sync/atomic" + "realy.mleku.dev/chk" "realy.mleku.dev/context" "realy.mleku.dev/envelopes/closeenvelope" "realy.mleku.dev/envelopes/countenvelope" "realy.mleku.dev/envelopes/reqenvelope" + "realy.mleku.dev/errorf" "realy.mleku.dev/event" "realy.mleku.dev/filters" + "realy.mleku.dev/log" "realy.mleku.dev/subscription" ) diff --git a/ws/util.go b/ws/util.go deleted file mode 100644 index f9cfd58..0000000 --- a/ws/util.go +++ /dev/null @@ -1,9 +0,0 @@ -package ws - -import ( - "realy.mleku.dev/lol" -) - -var ( - log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf -)