refactor logger so things can actually be moved around easily
This commit is contained in:
@@ -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]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package apputil
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -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 (
|
||||
|
||||
@@ -3,6 +3,7 @@ package auth
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"realy.mleku.dev/chk"
|
||||
"realy.mleku.dev/p256k"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -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 (
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package pointers
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package bech32encoding
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -2,6 +2,8 @@ package bin
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
|
||||
"realy.mleku.dev/errorf"
|
||||
)
|
||||
|
||||
// Append is a straight append with length prefix.
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package bin
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
13
chk/chk.go
Normal file
13
chk/chk.go
Normal file
@@ -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
|
||||
}
|
||||
@@ -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) }
|
||||
|
||||
@@ -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
|
||||
)
|
||||
@@ -8,8 +8,7 @@ type Proxy struct {
|
||||
}
|
||||
|
||||
func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().
|
||||
Set("Strict-Transport-Security",
|
||||
w.Header().Set("Strict-Transport-Security",
|
||||
"max-age=31536000; includeSubDomains; preload")
|
||||
p.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
)
|
||||
@@ -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] == '#' {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"net/url"
|
||||
|
||||
"realy.mleku.dev/cmd/lerproxy/util"
|
||||
"realy.mleku.dev/log"
|
||||
)
|
||||
|
||||
// NewSingleHostReverseProxy is a copy of httputil.NewSingleHostReverseProxy
|
||||
|
||||
@@ -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
|
||||
)
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
)
|
||||
@@ -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) {
|
||||
}
|
||||
|
||||
@@ -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
|
||||
)
|
||||
@@ -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
|
||||
)
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
)
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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
|
||||
)
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
)
|
||||
@@ -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"
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"realy.mleku.dev/context"
|
||||
"realy.mleku.dev/log"
|
||||
)
|
||||
|
||||
func MonitorResources(c context.T) {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -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"
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -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.
|
||||
@@ -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')
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -1,9 +0,0 @@
|
||||
package codec
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -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
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"realy.mleku.dev/bech32encoding/pointers"
|
||||
"realy.mleku.dev/chk"
|
||||
"realy.mleku.dev/keys"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package dns
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -1,9 +0,0 @@
|
||||
package base58
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -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
|
||||
)
|
||||
@@ -1,9 +0,0 @@
|
||||
package bech32
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -1,9 +0,0 @@
|
||||
package chaincfg
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -1,9 +0,0 @@
|
||||
package chainhash
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"realy.mleku.dev/chk"
|
||||
"realy.mleku.dev/ec/secp256k1"
|
||||
"realy.mleku.dev/hex"
|
||||
)
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package ecdsa
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -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
|
||||
)
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
"realy.mleku.dev/chk"
|
||||
"realy.mleku.dev/hex"
|
||||
)
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ package musig2
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"realy.mleku.dev/chk"
|
||||
"realy.mleku.dev/ec"
|
||||
"realy.mleku.dev/ec/schnorr"
|
||||
)
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package musig2
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package schnorr
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"realy.mleku.dev/chk"
|
||||
"realy.mleku.dev/hex"
|
||||
)
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -8,6 +8,8 @@ package secp256k1
|
||||
import (
|
||||
"crypto/rand"
|
||||
"io"
|
||||
|
||||
"realy.mleku.dev/chk"
|
||||
)
|
||||
|
||||
// SecretKey provides facilities for working with secp256k1 secret keys within
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package secp256k1
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -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
|
||||
)
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"realy.mleku.dev/chk"
|
||||
"realy.mleku.dev/ec/bech32"
|
||||
"realy.mleku.dev/ec/chaincfg"
|
||||
)
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package taproot
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -1,9 +0,0 @@
|
||||
package btcec
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -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
|
||||
)
|
||||
@@ -1,9 +0,0 @@
|
||||
package wire
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
|
||||
"lukechampine.com/frand"
|
||||
|
||||
"realy.mleku.dev/chk"
|
||||
"realy.mleku.dev/errorf"
|
||||
"realy.mleku.dev/hex"
|
||||
"realy.mleku.dev/p256k"
|
||||
)
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package encryption
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package authenvelope
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -6,6 +6,7 @@ package closedenvelope
|
||||
import (
|
||||
"io"
|
||||
|
||||
"realy.mleku.dev/chk"
|
||||
"realy.mleku.dev/codec"
|
||||
"realy.mleku.dev/envelopes"
|
||||
"realy.mleku.dev/subscription"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package closedenvelope
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -5,6 +5,7 @@ package closeenvelope
|
||||
import (
|
||||
"io"
|
||||
|
||||
"realy.mleku.dev/chk"
|
||||
"realy.mleku.dev/codec"
|
||||
"realy.mleku.dev/envelopes"
|
||||
"realy.mleku.dev/subscription"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package closeenvelope
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -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"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package countenvelope
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -7,6 +7,7 @@ package eoseenvelope
|
||||
import (
|
||||
"io"
|
||||
|
||||
"realy.mleku.dev/chk"
|
||||
"realy.mleku.dev/codec"
|
||||
"realy.mleku.dev/envelopes"
|
||||
"realy.mleku.dev/subscription"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package eoseenvelope
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package eventenvelope
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -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
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package messages
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
@@ -6,6 +6,7 @@ package noticeenvelope
|
||||
import (
|
||||
"io"
|
||||
|
||||
"realy.mleku.dev/chk"
|
||||
"realy.mleku.dev/codec"
|
||||
"realy.mleku.dev/envelopes"
|
||||
"realy.mleku.dev/text"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package noticeenvelope
|
||||
|
||||
import (
|
||||
"realy.mleku.dev/lol"
|
||||
)
|
||||
|
||||
var (
|
||||
log, chk, errorf = lol.Main.Log, lol.Main.Check, lol.Main.Errorf
|
||||
)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user