mirror of
https://github.com/amigan/aim-oscar-server.git
synced 2024-11-21 20:19:47 -05:00
make our own Buffer, add sql, add test
This commit is contained in:
parent
e057e83599
commit
9bebf7c6c3
15 changed files with 531 additions and 75 deletions
|
@ -1,16 +1,34 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"context"
|
||||||
|
"crypto/rand"
|
||||||
|
"encoding/base32"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/uptrace/bun"
|
||||||
|
|
||||||
|
"aim-oscar/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const CIPHER_LENGTH = 64
|
||||||
|
|
||||||
type AuthorizationRegistrationService struct{}
|
type AuthorizationRegistrationService struct{}
|
||||||
|
|
||||||
func (a *AuthorizationRegistrationService) HandleSNAC(session *Session, snac *SNAC) error {
|
func (a *AuthorizationRegistrationService) GenerateCipher() string {
|
||||||
|
randomBytes := make([]byte, 64)
|
||||||
|
_, err := rand.Read(randomBytes)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return base32.StdEncoding.EncodeToString(randomBytes)[:CIPHER_LENGTH]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AuthorizationRegistrationService) HandleSNAC(db *bun.DB, session *Session, snac *SNAC) error {
|
||||||
switch snac.Header.Subtype {
|
switch snac.Header.Subtype {
|
||||||
// Request MD5 Auth Key
|
// Request MD5 Auth Key
|
||||||
case 0x06:
|
case 0x06:
|
||||||
tlvs, err := UnmarshalTLVs(snac.Data)
|
tlvs, err := UnmarshalTLVs(snac.Data.Bytes())
|
||||||
panicIfError(err)
|
panicIfError(err)
|
||||||
|
|
||||||
usernameTLV := FindTLV(tlvs, 1)
|
usernameTLV := FindTLV(tlvs, 1)
|
||||||
|
@ -18,16 +36,64 @@ func (a *AuthorizationRegistrationService) HandleSNAC(session *Session, snac *SN
|
||||||
return errors.New("missing username TLV")
|
return errors.New("missing username TLV")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create cipher for this user
|
// Fetch the user
|
||||||
cipher := "howdy"
|
ctx := context.Background()
|
||||||
db.Set("cipher-"+string(usernameTLV.Data), cipher)
|
user, err := models.UserByUsername(ctx, db, string(usernameTLV.Data))
|
||||||
cipherData := []byte(cipher)
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if user == nil {
|
||||||
|
snac := NewSNAC(0x17, 0x03)
|
||||||
|
snac.Data.WriteBinary(usernameTLV)
|
||||||
|
snac.Data.WriteBinary(NewTLV(0x08, []byte{0, 4}))
|
||||||
|
resp := NewFLAP(session, 2)
|
||||||
|
resp.Data.WriteBinary(snac)
|
||||||
|
return session.Send(resp)
|
||||||
|
}
|
||||||
|
|
||||||
snac := NewSNAC(0x17, 0x07, cipherData)
|
// Create cipher for this user
|
||||||
snacBytes, err := snac.MarshalBinary()
|
user.Cipher = a.GenerateCipher()
|
||||||
|
if err = user.Update(ctx, db); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
snac := NewSNAC(0x17, 0x07)
|
||||||
|
snac.Data.WriteUint16(uint16(len(user.Cipher)))
|
||||||
|
snac.Data.WriteString(user.Cipher)
|
||||||
|
|
||||||
|
resp := NewFLAP(session, 2)
|
||||||
|
resp.Data.WriteBinary(snac)
|
||||||
|
return session.Send(resp)
|
||||||
|
|
||||||
|
// Client Authorization Request
|
||||||
|
case 0x02:
|
||||||
|
tlvs, err := UnmarshalTLVs(snac.Data.Bytes())
|
||||||
panicIfError(err)
|
panicIfError(err)
|
||||||
|
|
||||||
resp := NewFLAP(session, 2, snacBytes)
|
usernameTLV := FindTLV(tlvs, 1)
|
||||||
|
if usernameTLV == nil {
|
||||||
|
return errors.New("missing username TLV")
|
||||||
|
}
|
||||||
|
|
||||||
|
username := string(usernameTLV.Data)
|
||||||
|
ctx := context.Background()
|
||||||
|
user, err := models.UserByUsername(ctx, db, username)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if user == nil {
|
||||||
|
snac := NewSNAC(0x17, 0x03)
|
||||||
|
snac.Data.WriteBinary(usernameTLV)
|
||||||
|
snac.Data.WriteBinary(NewTLV(0x08, []byte{0, 4}))
|
||||||
|
resp := NewFLAP(session, 2)
|
||||||
|
resp.Data.WriteBinary(snac)
|
||||||
|
return session.Send(resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
snac := NewSNAC(0x17, 0x03)
|
||||||
|
resp := NewFLAP(session, 2)
|
||||||
|
resp.Data.WriteBinary(snac)
|
||||||
return session.Send(resp)
|
return session.Send(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
BIN
aim-oscar
Executable file
BIN
aim-oscar
Executable file
Binary file not shown.
48
buf.go
Normal file
48
buf.go
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding"
|
||||||
|
"encoding/binary"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Buffer struct {
|
||||||
|
d []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Buffer) WriteUint8(x uint8) {
|
||||||
|
b.d = append(b.d, x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Buffer) WriteUint16(x uint16) {
|
||||||
|
b.d = append(b.d, 0, 0)
|
||||||
|
binary.BigEndian.PutUint16(b.d[len(b.d)-2:], x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Buffer) WriteUint32(x uint32) {
|
||||||
|
b.d = append(b.d, 0, 0, 0, 0)
|
||||||
|
binary.BigEndian.PutUint32(b.d[len(b.d)-4:], x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Buffer) WriteUint64(x uint64) {
|
||||||
|
b.d = append(b.d, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||||
|
binary.BigEndian.PutUint64(b.d[len(b.d)-8:], x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Buffer) WriteString(x string) {
|
||||||
|
b.d = append(b.d, []byte(x)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Buffer) Write(x []byte) (int, error) {
|
||||||
|
b.d = append(b.d, x...)
|
||||||
|
return len(x), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Buffer) WriteBinary(e encoding.BinaryMarshaler) {
|
||||||
|
d, err := e.MarshalBinary()
|
||||||
|
panicIfError(err)
|
||||||
|
b.d = append(b.d, d...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Buffer) Bytes() []byte {
|
||||||
|
return b.d
|
||||||
|
}
|
19
db.go
19
db.go
|
@ -1,19 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
type DB struct {
|
|
||||||
data map[string]string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *DB) Init() {
|
|
||||||
d.data = make(map[string]string)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *DB) Get(key string) (data string, ok bool) {
|
|
||||||
data, ok = d.data[key]
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *DB) Set(key string, value string) error {
|
|
||||||
d.data[key] = value
|
|
||||||
return nil
|
|
||||||
}
|
|
19
flap.go
19
flap.go
|
@ -18,27 +18,28 @@ type FLAPHeader struct {
|
||||||
|
|
||||||
type FLAP struct {
|
type FLAP struct {
|
||||||
Header FLAPHeader
|
Header FLAPHeader
|
||||||
Data []byte
|
Data Buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFLAP(session *Session, channel uint8, data []byte) *FLAP {
|
func NewFLAP(session *Session, channel uint8) *FLAP {
|
||||||
session.SequenceNumber += 1
|
session.SequenceNumber += 1
|
||||||
|
|
||||||
return &FLAP{
|
return &FLAP{
|
||||||
Header: FLAPHeader{
|
Header: FLAPHeader{
|
||||||
Channel: channel,
|
Channel: channel,
|
||||||
SequenceNumber: uint16(session.SequenceNumber),
|
SequenceNumber: uint16(session.SequenceNumber),
|
||||||
DataLength: uint16(len(data)),
|
|
||||||
},
|
},
|
||||||
Data: data,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FLAP) MarshalBinary() ([]byte, error) {
|
func (f *FLAP) MarshalBinary() ([]byte, error) {
|
||||||
var buf bytes.Buffer
|
buf := Buffer{}
|
||||||
buf.WriteByte(0x2a)
|
buf.WriteUint8(0x2a)
|
||||||
|
|
||||||
|
f.Header.DataLength = uint16(len(f.Data.Bytes()))
|
||||||
|
|
||||||
binary.Write(&buf, binary.BigEndian, f.Header)
|
binary.Write(&buf, binary.BigEndian, f.Header)
|
||||||
n, err := buf.Write(f.Data)
|
n, err := buf.Write(f.Data.Bytes())
|
||||||
if n != int(f.Header.DataLength) {
|
if n != int(f.Header.DataLength) {
|
||||||
return nil, fmt.Errorf("needed to write %d bytes to buffer but wrote %d", f.Header.DataLength, n)
|
return nil, fmt.Errorf("needed to write %d bytes to buffer but wrote %d", f.Header.DataLength, n)
|
||||||
}
|
}
|
||||||
|
@ -63,7 +64,7 @@ func (f *FLAP) UnmarshalBinary(data []byte) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
f.Data = buf.Bytes()
|
f.Data.Write(buf.Bytes())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,5 +73,5 @@ func (f *FLAP) Len() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FLAP) String() string {
|
func (f *FLAP) String() string {
|
||||||
return fmt.Sprintf("FLAP(CH:%d, SEQ:%d):\n%s", f.Header.Channel, f.Header.SequenceNumber, prettyBytes(f.Data))
|
return fmt.Sprintf("FLAP(CH:%d, SEQ:%d):\n%s", f.Header.Channel, f.Header.SequenceNumber, prettyBytes(f.Data.Bytes()))
|
||||||
}
|
}
|
||||||
|
|
44
flap_test.go
Normal file
44
flap_test.go
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestFLAP(t *testing.T) {
|
||||||
|
session := Session{}
|
||||||
|
hello := NewFLAP(&session, 1)
|
||||||
|
hello.Data.Write([]byte{0, 0, 0, 1})
|
||||||
|
|
||||||
|
b, err := hello.MarshalBinary()
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("FLAP failed to marshal: %x", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
expected := []byte{0x2a, 1, 0, 1, 0, 4, 0, 0, 0, 1}
|
||||||
|
if !reflect.DeepEqual(b, expected) {
|
||||||
|
t.Errorf("unexpected marshaled bytes. expected: %v, got: %v", expected, b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUnmarshalFLAP(t *testing.T) {
|
||||||
|
b := []byte{0x2a, 1, 0, 1, 0, 4, 0, 0, 0, 1}
|
||||||
|
|
||||||
|
hello := FLAP{}
|
||||||
|
if err := hello.UnmarshalBinary(b); err != nil {
|
||||||
|
t.Errorf("FLAP failed to unmarshal from bytes: %x", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if hello.Header.Channel != 1 {
|
||||||
|
t.Errorf("FLAP channel should be %d, got %d", 1, hello.Header.Channel)
|
||||||
|
}
|
||||||
|
if hello.Header.SequenceNumber != 1 {
|
||||||
|
t.Errorf("FLAP sequence number should be %d, got %d", 1, hello.Header.SequenceNumber)
|
||||||
|
}
|
||||||
|
if hello.Header.DataLength != 4 {
|
||||||
|
t.Errorf("FLAP data length should be %d, got %d", 4, hello.Header.DataLength)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(hello.Data.Bytes(), b[6:]) {
|
||||||
|
t.Errorf("FLAP body should be %x, got %x", b[6:], hello.Data.Bytes())
|
||||||
|
}
|
||||||
|
}
|
10
go.mod
10
go.mod
|
@ -3,7 +3,15 @@ module aim-oscar
|
||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/ghostiam/binstruct v1.0.1 // indirect
|
github.com/ghostiam/binstruct v1.0.1 // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/xhebox/bstruct v0.0.0-20210125172452-c36e1006cf29 // indirect
|
github.com/uptrace/bun v1.0.19 // indirect
|
||||||
|
github.com/uptrace/bun/dbfixture v1.0.19 // indirect
|
||||||
|
github.com/uptrace/bun/dialect/sqlitedialect v1.0.19 // indirect
|
||||||
|
github.com/uptrace/bun/driver/sqliteshim v1.0.19 // indirect
|
||||||
|
github.com/uptrace/bun/extra/bundebug v1.0.19 // indirect
|
||||||
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
|
||||||
|
golang.org/x/tools v0.1.8 // indirect
|
||||||
|
modernc.org/sqlite v1.14.3 // indirect
|
||||||
)
|
)
|
||||||
|
|
218
go.sum
218
go.sum
|
@ -1,13 +1,231 @@
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||||
|
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
|
||||||
|
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||||
github.com/ghostiam/binstruct v1.0.1 h1:sg7Hi5c5b0noCDfRQpx3K2x9HLJYRafKnQRif7Orkek=
|
github.com/ghostiam/binstruct v1.0.1 h1:sg7Hi5c5b0noCDfRQpx3K2x9HLJYRafKnQRif7Orkek=
|
||||||
github.com/ghostiam/binstruct v1.0.1/go.mod h1:+NZwEDbcfME8MhF7nQRjAZV4U00c6XpNuk+nkvOxzvo=
|
github.com/ghostiam/binstruct v1.0.1/go.mod h1:+NZwEDbcfME8MhF7nQRjAZV4U00c6XpNuk+nkvOxzvo=
|
||||||
|
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||||
|
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||||
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||||
|
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
|
||||||
|
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
|
||||||
|
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||||
|
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
|
||||||
|
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||||
|
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||||
|
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||||
|
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.9 h1:10HX2Td0ocZpYEjhilsuo6WWtUqttj2Kb0KtD86/KYA=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
|
||||||
|
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo=
|
||||||
|
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs=
|
||||||
|
github.com/uptrace/bun v1.0.19 h1:Jl5GbcnLqeo4mHLVbF+LvzVXiXTrwQOdIVvuMO+5zXI=
|
||||||
|
github.com/uptrace/bun v1.0.19/go.mod h1:Uv7z0z+7dXnUS9P5hMF0hdiM/4M+xOUHQCrZpyDrpRc=
|
||||||
|
github.com/uptrace/bun/dbfixture v1.0.19 h1:1jKjs6vluS4e5F0U5kF3RW5SPCGbTj+64WiCbVIy09U=
|
||||||
|
github.com/uptrace/bun/dbfixture v1.0.19/go.mod h1:1mHn2Np4I3vDrGDWb6zzce+4D4StFwpMXBdtCxizRt8=
|
||||||
|
github.com/uptrace/bun/dialect/sqlitedialect v1.0.19 h1:Oy0scO7sXbVBk9k6xc2yFF/X1maW5UU6uqO6coX/5/8=
|
||||||
|
github.com/uptrace/bun/dialect/sqlitedialect v1.0.19/go.mod h1:KXvO5WJYf+JNrabpLR9CdflPjOqbkIjoBalxePvoysU=
|
||||||
|
github.com/uptrace/bun/driver/sqliteshim v1.0.19 h1:nW7dfsEgAJ0Xv9HmRuRyeC3FOiINZSr6VZAHKv6sY5c=
|
||||||
|
github.com/uptrace/bun/driver/sqliteshim v1.0.19/go.mod h1:qeC2X9mnTDJzVHf30Ef4xsUp9k3yQOkp7+adAnBt4/w=
|
||||||
|
github.com/uptrace/bun/extra/bundebug v1.0.19 h1:PBajhIUkeHk3ZOpH9ZLPhfGxiZlBS70nV/Nmufk4B7s=
|
||||||
|
github.com/uptrace/bun/extra/bundebug v1.0.19/go.mod h1:SkanLrdjmx7P88mir9ls7X4mfQesJKgW++sKbbhdJ2c=
|
||||||
|
github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=
|
||||||
|
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
|
||||||
|
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
|
||||||
|
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
|
||||||
github.com/xhebox/bstruct v0.0.0-20210125172452-c36e1006cf29 h1:lMx3E/urZ0wDiG27VXTEEq0RG/MHsscHPkYiS5KIjcE=
|
github.com/xhebox/bstruct v0.0.0-20210125172452-c36e1006cf29 h1:lMx3E/urZ0wDiG27VXTEEq0RG/MHsscHPkYiS5KIjcE=
|
||||||
github.com/xhebox/bstruct v0.0.0-20210125172452-c36e1006cf29/go.mod h1:KZ+p86hKYsjjg3oG2RfDFJFGkn85Z60Xhc5E5P58FXY=
|
github.com/xhebox/bstruct v0.0.0-20210125172452-c36e1006cf29/go.mod h1:KZ+p86hKYsjjg3oG2RfDFJFGkn85Z60Xhc5E5P58FXY=
|
||||||
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||||
|
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
|
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
|
golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38=
|
||||||
|
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
||||||
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
|
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20211123173158-ef496fb156ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
|
||||||
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
|
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
|
||||||
|
golang.org/x/tools v0.1.8 h1:P1HhGGuLW4aAclzjtmJdf0mJOjVUZUzOTqkAkWL+l6w=
|
||||||
|
golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
lukechampine.com/uint128 v1.1.1 h1:pnxCASz787iMf+02ssImqk6OLt+Z5QHMoZyUXR4z6JU=
|
||||||
|
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
|
||||||
|
modernc.org/cc/v3 v3.33.6/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
|
modernc.org/cc/v3 v3.33.9/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
|
modernc.org/cc/v3 v3.33.11/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
|
modernc.org/cc/v3 v3.34.0/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
|
modernc.org/cc/v3 v3.35.0/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
|
modernc.org/cc/v3 v3.35.4/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
|
modernc.org/cc/v3 v3.35.5/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
|
modernc.org/cc/v3 v3.35.7/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
|
modernc.org/cc/v3 v3.35.8/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
|
modernc.org/cc/v3 v3.35.10/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
|
modernc.org/cc/v3 v3.35.15/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
|
modernc.org/cc/v3 v3.35.16/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
|
modernc.org/cc/v3 v3.35.17/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
|
modernc.org/cc/v3 v3.35.18 h1:rMZhRcWrba0y3nVmdiQ7kxAgOOSq2m2f2VzjHLgEs6U=
|
||||||
|
modernc.org/cc/v3 v3.35.18/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
|
modernc.org/ccgo/v3 v3.9.5/go.mod h1:umuo2EP2oDSBnD3ckjaVUXMrmeAw8C8OSICVa0iFf60=
|
||||||
|
modernc.org/ccgo/v3 v3.10.0/go.mod h1:c0yBmkRFi7uW4J7fwx/JiijwOjeAeR2NoSaRVFPmjMw=
|
||||||
|
modernc.org/ccgo/v3 v3.11.0/go.mod h1:dGNposbDp9TOZ/1KBxghxtUp/bzErD0/0QW4hhSaBMI=
|
||||||
|
modernc.org/ccgo/v3 v3.11.1/go.mod h1:lWHxfsn13L3f7hgGsGlU28D9eUOf6y3ZYHKoPaKU0ag=
|
||||||
|
modernc.org/ccgo/v3 v3.11.3/go.mod h1:0oHunRBMBiXOKdaglfMlRPBALQqsfrCKXgw9okQ3GEw=
|
||||||
|
modernc.org/ccgo/v3 v3.12.4/go.mod h1:Bk+m6m2tsooJchP/Yk5ji56cClmN6R1cqc9o/YtbgBQ=
|
||||||
|
modernc.org/ccgo/v3 v3.12.6/go.mod h1:0Ji3ruvpFPpz+yu+1m0wk68pdr/LENABhTrDkMDWH6c=
|
||||||
|
modernc.org/ccgo/v3 v3.12.8/go.mod h1:Hq9keM4ZfjCDuDXxaHptpv9N24JhgBZmUG5q60iLgUo=
|
||||||
|
modernc.org/ccgo/v3 v3.12.11/go.mod h1:0jVcmyDwDKDGWbcrzQ+xwJjbhZruHtouiBEvDfoIsdg=
|
||||||
|
modernc.org/ccgo/v3 v3.12.14/go.mod h1:GhTu1k0YCpJSuWwtRAEHAol5W7g1/RRfS4/9hc9vF5I=
|
||||||
|
modernc.org/ccgo/v3 v3.12.18/go.mod h1:jvg/xVdWWmZACSgOiAhpWpwHWylbJaSzayCqNOJKIhs=
|
||||||
|
modernc.org/ccgo/v3 v3.12.20/go.mod h1:aKEdssiu7gVgSy/jjMastnv/q6wWGRbszbheXgWRHc8=
|
||||||
|
modernc.org/ccgo/v3 v3.12.21/go.mod h1:ydgg2tEprnyMn159ZO/N4pLBqpL7NOkJ88GT5zNU2dE=
|
||||||
|
modernc.org/ccgo/v3 v3.12.22/go.mod h1:nyDVFMmMWhMsgQw+5JH6B6o4MnZ+UQNw1pp52XYFPRk=
|
||||||
|
modernc.org/ccgo/v3 v3.12.25/go.mod h1:UaLyWI26TwyIT4+ZFNjkyTbsPsY3plAEB6E7L/vZV3w=
|
||||||
|
modernc.org/ccgo/v3 v3.12.29/go.mod h1:FXVjG7YLf9FetsS2OOYcwNhcdOLGt8S9bQ48+OP75cE=
|
||||||
|
modernc.org/ccgo/v3 v3.12.36/go.mod h1:uP3/Fiezp/Ga8onfvMLpREq+KUjUmYMxXPO8tETHtA8=
|
||||||
|
modernc.org/ccgo/v3 v3.12.38/go.mod h1:93O0G7baRST1vNj4wnZ49b1kLxt0xCW5Hsa2qRaZPqc=
|
||||||
|
modernc.org/ccgo/v3 v3.12.43/go.mod h1:k+DqGXd3o7W+inNujK15S5ZYuPoWYLpF5PYougCmthU=
|
||||||
|
modernc.org/ccgo/v3 v3.12.46/go.mod h1:UZe6EvMSqOxaJ4sznY7b23/k13R8XNlyWsO5bAmSgOE=
|
||||||
|
modernc.org/ccgo/v3 v3.12.47/go.mod h1:m8d6p0zNps187fhBwzY/ii6gxfjob1VxWb919Nk1HUk=
|
||||||
|
modernc.org/ccgo/v3 v3.12.50/go.mod h1:bu9YIwtg+HXQxBhsRDE+cJjQRuINuT9PUK4orOco/JI=
|
||||||
|
modernc.org/ccgo/v3 v3.12.51/go.mod h1:gaIIlx4YpmGO2bLye04/yeblmvWEmE4BBBls4aJXFiE=
|
||||||
|
modernc.org/ccgo/v3 v3.12.53/go.mod h1:8xWGGTFkdFEWBEsUmi+DBjwu/WLy3SSOrqEmKUjMeEg=
|
||||||
|
modernc.org/ccgo/v3 v3.12.54/go.mod h1:yANKFTm9llTFVX1FqNKHE0aMcQb1fuPJx6p8AcUx+74=
|
||||||
|
modernc.org/ccgo/v3 v3.12.55/go.mod h1:rsXiIyJi9psOwiBkplOaHye5L4MOOaCjHg1Fxkj7IeU=
|
||||||
|
modernc.org/ccgo/v3 v3.12.56/go.mod h1:ljeFks3faDseCkr60JMpeDb2GSO3TKAmrzm7q9YOcMU=
|
||||||
|
modernc.org/ccgo/v3 v3.12.57/go.mod h1:hNSF4DNVgBl8wYHpMvPqQWDQx8luqxDnNGCMM4NFNMc=
|
||||||
|
modernc.org/ccgo/v3 v3.12.60/go.mod h1:k/Nn0zdO1xHVWjPYVshDeWKqbRWIfif5dtsIOCUVMqM=
|
||||||
|
modernc.org/ccgo/v3 v3.12.65/go.mod h1:D6hQtKxPNZiY6wDBtehSGKFKmyXn53F8nGTpH+POmS4=
|
||||||
|
modernc.org/ccgo/v3 v3.12.66/go.mod h1:jUuxlCFZTUZLMV08s7B1ekHX5+LIAurKTTaugUr/EhQ=
|
||||||
|
modernc.org/ccgo/v3 v3.12.67/go.mod h1:Bll3KwKvGROizP2Xj17GEGOTrlvB1XcVaBrC90ORO84=
|
||||||
|
modernc.org/ccgo/v3 v3.12.73/go.mod h1:hngkB+nUUqzOf3iqsM48Gf1FZhY599qzVg1iX+BT3cQ=
|
||||||
|
modernc.org/ccgo/v3 v3.12.78/go.mod h1:p2A1duHoBBg1mFtYvnhAnQyI6vL0uw5PGYLSIgF6rYY=
|
||||||
|
modernc.org/ccgo/v3 v3.12.81/go.mod h1:p2A1duHoBBg1mFtYvnhAnQyI6vL0uw5PGYLSIgF6rYY=
|
||||||
|
modernc.org/ccgo/v3 v3.12.84/go.mod h1:ApbflUfa5BKadjHynCficldU1ghjen84tuM5jRynB7w=
|
||||||
|
modernc.org/ccgo/v3 v3.12.86/go.mod h1:dN7S26DLTgVSni1PVA3KxxHTcykyDurf3OgUzNqTSrU=
|
||||||
|
modernc.org/ccgo/v3 v3.12.88/go.mod h1:0MFzUHIuSIthpVZyMWiFYMwjiFnhrN5MkvBrUwON+ZM=
|
||||||
|
modernc.org/ccgo/v3 v3.12.90/go.mod h1:obhSc3CdivCRpYZmrvO88TXlW0NvoSVvdh/ccRjJYko=
|
||||||
|
modernc.org/ccgo/v3 v3.12.92/go.mod h1:5yDdN7ti9KWPi5bRVWPl8UNhpEAtCjuEE7ayQnzzqHA=
|
||||||
|
modernc.org/ccgo/v3 v3.12.95 h1:Ym2JG2G3P4IyZqjTTojHTl7qO0RysXeGSYPSoKPSBxc=
|
||||||
|
modernc.org/ccgo/v3 v3.12.95/go.mod h1:ZcLyvtocXYi8uF+9Ebm3G8EF8HNY5hGomBqthDp4eC8=
|
||||||
|
modernc.org/ccorpus v1.11.1/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ=
|
||||||
|
modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
|
||||||
|
modernc.org/libc v1.9.8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
|
||||||
|
modernc.org/libc v1.9.11/go.mod h1:NyF3tsA5ArIjJ83XB0JlqhjTabTCHm9aX4XMPHyQn0Q=
|
||||||
|
modernc.org/libc v1.11.0/go.mod h1:2lOfPmj7cz+g1MrPNmX65QCzVxgNq2C5o0jdLY2gAYg=
|
||||||
|
modernc.org/libc v1.11.2/go.mod h1:ioIyrl3ETkugDO3SGZ+6EOKvlP3zSOycUETe4XM4n8M=
|
||||||
|
modernc.org/libc v1.11.5/go.mod h1:k3HDCP95A6U111Q5TmG3nAyUcp3kR5YFZTeDS9v8vSU=
|
||||||
|
modernc.org/libc v1.11.6/go.mod h1:ddqmzR6p5i4jIGK1d/EiSw97LBcE3dK24QEwCFvgNgE=
|
||||||
|
modernc.org/libc v1.11.11/go.mod h1:lXEp9QOOk4qAYOtL3BmMve99S5Owz7Qyowzvg6LiZso=
|
||||||
|
modernc.org/libc v1.11.13/go.mod h1:ZYawJWlXIzXy2Pzghaf7YfM8OKacP3eZQI81PDLFdY8=
|
||||||
|
modernc.org/libc v1.11.16/go.mod h1:+DJquzYi+DMRUtWI1YNxrlQO6TcA5+dRRiq8HWBWRC8=
|
||||||
|
modernc.org/libc v1.11.19/go.mod h1:e0dgEame6mkydy19KKaVPBeEnyJB4LGNb0bBH1EtQ3I=
|
||||||
|
modernc.org/libc v1.11.24/go.mod h1:FOSzE0UwookyT1TtCJrRkvsOrX2k38HoInhw+cSCUGk=
|
||||||
|
modernc.org/libc v1.11.26/go.mod h1:SFjnYi9OSd2W7f4ct622o/PAYqk7KHv6GS8NZULIjKY=
|
||||||
|
modernc.org/libc v1.11.27/go.mod h1:zmWm6kcFXt/jpzeCgfvUNswM0qke8qVwxqZrnddlDiE=
|
||||||
|
modernc.org/libc v1.11.28/go.mod h1:Ii4V0fTFcbq3qrv3CNn+OGHAvzqMBvC7dBNyC4vHZlg=
|
||||||
|
modernc.org/libc v1.11.31/go.mod h1:FpBncUkEAtopRNJj8aRo29qUiyx5AvAlAxzlx9GNaVM=
|
||||||
|
modernc.org/libc v1.11.34/go.mod h1:+Tzc4hnb1iaX/SKAutJmfzES6awxfU1BPvrrJO0pYLg=
|
||||||
|
modernc.org/libc v1.11.37/go.mod h1:dCQebOwoO1046yTrfUE5nX1f3YpGZQKNcITUYWlrAWo=
|
||||||
|
modernc.org/libc v1.11.39/go.mod h1:mV8lJMo2S5A31uD0k1cMu7vrJbSA3J3waQJxpV4iqx8=
|
||||||
|
modernc.org/libc v1.11.42/go.mod h1:yzrLDU+sSjLE+D4bIhS7q1L5UwXDOw99PLSX0BlZvSQ=
|
||||||
|
modernc.org/libc v1.11.44/go.mod h1:KFq33jsma7F5WXiYelU8quMJasCCTnHK0mkri4yPHgA=
|
||||||
|
modernc.org/libc v1.11.45/go.mod h1:Y192orvfVQQYFzCNsn+Xt0Hxt4DiO4USpLNXBlXg/tM=
|
||||||
|
modernc.org/libc v1.11.47/go.mod h1:tPkE4PzCTW27E6AIKIR5IwHAQKCAtudEIeAV1/SiyBg=
|
||||||
|
modernc.org/libc v1.11.49/go.mod h1:9JrJuK5WTtoTWIFQ7QjX2Mb/bagYdZdscI3xrvHbXjE=
|
||||||
|
modernc.org/libc v1.11.51/go.mod h1:R9I8u9TS+meaWLdbfQhq2kFknTW0O3aw3kEMqDDxMaM=
|
||||||
|
modernc.org/libc v1.11.53/go.mod h1:5ip5vWYPAoMulkQ5XlSJTy12Sz5U6blOQiYasilVPsU=
|
||||||
|
modernc.org/libc v1.11.54/go.mod h1:S/FVnskbzVUrjfBqlGFIPA5m7UwB3n9fojHhCNfSsnw=
|
||||||
|
modernc.org/libc v1.11.55/go.mod h1:j2A5YBRm6HjNkoSs/fzZrSxCuwWqcMYTDPLNx0URn3M=
|
||||||
|
modernc.org/libc v1.11.56/go.mod h1:pakHkg5JdMLt2OgRadpPOTnyRXm/uzu+Yyg/LSLdi18=
|
||||||
|
modernc.org/libc v1.11.58/go.mod h1:ns94Rxv0OWyoQrDqMFfWwka2BcaF6/61CqJRK9LP7S8=
|
||||||
|
modernc.org/libc v1.11.70/go.mod h1:DUOmMYe+IvKi9n6Mycyx3DbjfzSKrdr/0Vgt3j7P5gw=
|
||||||
|
modernc.org/libc v1.11.71/go.mod h1:DUOmMYe+IvKi9n6Mycyx3DbjfzSKrdr/0Vgt3j7P5gw=
|
||||||
|
modernc.org/libc v1.11.75/go.mod h1:dGRVugT6edz361wmD9gk6ax1AbDSe0x5vji0dGJiPT0=
|
||||||
|
modernc.org/libc v1.11.82/go.mod h1:NF+Ek1BOl2jeC7lw3a7Jj5PWyHPwWD4aq3wVKxqV1fI=
|
||||||
|
modernc.org/libc v1.11.86/go.mod h1:ePuYgoQLmvxdNT06RpGnaDKJmDNEkV7ZPKI2jnsvZoE=
|
||||||
|
modernc.org/libc v1.11.87/go.mod h1:Qvd5iXTeLhI5PS0XSyqMY99282y+3euapQFxM7jYnpY=
|
||||||
|
modernc.org/libc v1.11.88/go.mod h1:h3oIVe8dxmTcchcFuCcJ4nAWaoiwzKCdv82MM0oiIdQ=
|
||||||
|
modernc.org/libc v1.11.90/go.mod h1:ynK5sbjsU77AP+nn61+k+wxUGRx9rOFcIqWYYMaDZ4c=
|
||||||
|
modernc.org/libc v1.11.98/go.mod h1:ynK5sbjsU77AP+nn61+k+wxUGRx9rOFcIqWYYMaDZ4c=
|
||||||
|
modernc.org/libc v1.11.99/go.mod h1:wLLYgEiY2D17NbBOEp+mIJJJBGSiy7fLL4ZrGGZ+8jI=
|
||||||
|
modernc.org/libc v1.11.101/go.mod h1:wLLYgEiY2D17NbBOEp+mIJJJBGSiy7fLL4ZrGGZ+8jI=
|
||||||
|
modernc.org/libc v1.11.104 h1:gxoa5b3HPo7OzD4tKZjgnwXk/w//u1oovvjSMP3Q96Q=
|
||||||
|
modernc.org/libc v1.11.104/go.mod h1:2MH3DaF/gCU8i/UBiVE1VFRos4o523M7zipmwH8SIgQ=
|
||||||
|
modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||||
|
modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||||
|
modernc.org/mathutil v1.4.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||||
|
modernc.org/mathutil v1.4.1 h1:ij3fYGe8zBF4Vu+g0oT7mB06r8sqGWKuJu1yXeR4by8=
|
||||||
|
modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||||
|
modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc=
|
||||||
|
modernc.org/memory v1.0.5 h1:XRch8trV7GgvTec2i7jc33YlUI0RKVDBvZ5eZ5m8y14=
|
||||||
|
modernc.org/memory v1.0.5/go.mod h1:B7OYswTRnfGg+4tDH1t1OeUNnsy2viGTdME4tzd+IjM=
|
||||||
|
modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A=
|
||||||
|
modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
|
||||||
|
modernc.org/sqlite v1.14.1/go.mod h1:04Lqa+3PuAEUhAPAPWeDMljT4UYA31nb2DHTFG47L1g=
|
||||||
|
modernc.org/sqlite v1.14.3 h1:psrTwgpEujgWEP3FNdsC9yNh5tSeA77U0GeWhHH4XmQ=
|
||||||
|
modernc.org/sqlite v1.14.3/go.mod h1:xMpicS1i2MJ4C8+Ap0vYBqTwYfpFvdnPE6brbFOtV2Y=
|
||||||
|
modernc.org/strutil v1.1.1 h1:xv+J1BXY3Opl2ALrBwyfEikFAj8pmqcpnfmuwUwcozs=
|
||||||
|
modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw=
|
||||||
|
modernc.org/tcl v1.8.13/go.mod h1:V+q/Ef0IJaNUSECieLU4o+8IScapxnMyFV6i/7uQlAY=
|
||||||
|
modernc.org/tcl v1.9.2/go.mod h1:aw7OnlIoiuJgu1gwbTZtrKnGpDqH9wyH++jZcxdqNsg=
|
||||||
|
modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk=
|
||||||
|
modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
||||||
|
modernc.org/z v1.2.19/go.mod h1:+ZpP0pc4zz97eukOzW3xagV/lS82IpPN9NGG5pNF9vY=
|
||||||
|
modernc.org/z v1.2.20/go.mod h1:zU9FiF4PbHdOTUxw+IF8j7ArBMRPsHgq10uVPt6xTzo=
|
||||||
|
|
48
main.go
48
main.go
|
@ -1,6 +1,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"aim-oscar/models"
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
@ -10,6 +13,11 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/uptrace/bun"
|
||||||
|
"github.com/uptrace/bun/dbfixture"
|
||||||
|
"github.com/uptrace/bun/dialect/sqlitedialect"
|
||||||
|
"github.com/uptrace/bun/driver/sqliteshim"
|
||||||
|
"github.com/uptrace/bun/extra/bundebug"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -19,15 +27,30 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var services = make(map[uint16]Service)
|
var services = make(map[uint16]Service)
|
||||||
var db *DB = nil
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
db = &DB{}
|
|
||||||
db.Init()
|
|
||||||
services[0x17] = &AuthorizationRegistrationService{}
|
services[0x17] = &AuthorizationRegistrationService{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
// Set up the DB
|
||||||
|
sqldb, err := sql.Open(sqliteshim.ShimName, "file::memory:?cache=shared")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
db := bun.NewDB(sqldb, sqlitedialect.New())
|
||||||
|
|
||||||
|
// Print all queries to stdout.
|
||||||
|
db.AddQueryHook(bundebug.NewQueryHook(bundebug.WithVerbose(true)))
|
||||||
|
|
||||||
|
db.RegisterModel((*models.User)(nil))
|
||||||
|
|
||||||
|
fixture := dbfixture.New(db, dbfixture.WithRecreateTables())
|
||||||
|
err = fixture.Load(context.Background(), os.DirFS("models"), "fixtures.yml")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
listener, err := net.Listen("tcp", SRV_ADDRESS)
|
listener, err := net.Listen("tcp", SRV_ADDRESS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error listening: ", err.Error())
|
fmt.Println("Error listening: ", err.Error())
|
||||||
|
@ -54,11 +77,11 @@ func main() {
|
||||||
session := NewSession(conn)
|
session := NewSession(conn)
|
||||||
log.Printf("Connection from %v", conn.RemoteAddr())
|
log.Printf("Connection from %v", conn.RemoteAddr())
|
||||||
|
|
||||||
go handleTCPConnection(session, conn)
|
go handleTCPConnection(db, session, conn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleTCPConnection(session *Session, conn net.Conn) {
|
func handleTCPConnection(db *bun.DB, session *Session, conn net.Conn) {
|
||||||
// defer (func() {
|
// defer (func() {
|
||||||
// if err := recover(); err != nil {
|
// if err := recover(); err != nil {
|
||||||
// log.Printf("Error handling message: %+v\n", err.(error))
|
// log.Printf("Error handling message: %+v\n", err.(error))
|
||||||
|
@ -71,7 +94,8 @@ func handleTCPConnection(session *Session, conn net.Conn) {
|
||||||
for {
|
for {
|
||||||
if !session.GreetedClient {
|
if !session.GreetedClient {
|
||||||
// send a hello
|
// send a hello
|
||||||
hello := NewFLAP(session, 1, []byte{0, 0, 0, 1})
|
hello := NewFLAP(session, 1)
|
||||||
|
hello.Data.Write([]byte{0, 0, 0, 1})
|
||||||
err := session.Send(hello)
|
err := session.Send(hello)
|
||||||
panicIfError(err)
|
panicIfError(err)
|
||||||
session.GreetedClient = true
|
session.GreetedClient = true
|
||||||
|
@ -103,30 +127,30 @@ func handleTCPConnection(session *Session, conn net.Conn) {
|
||||||
}
|
}
|
||||||
buf = buf[flapLength:]
|
buf = buf[flapLength:]
|
||||||
fmt.Printf("%v ->\n%+v\n", conn.RemoteAddr(), flap)
|
fmt.Printf("%v ->\n%+v\n", conn.RemoteAddr(), flap)
|
||||||
handleMessage(session, flap)
|
handleMessage(db, session, flap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleMessage(session *Session, flap *FLAP) {
|
func handleMessage(db *bun.DB, session *Session, flap *FLAP) {
|
||||||
if flap.Header.Channel == 1 {
|
if flap.Header.Channel == 1 {
|
||||||
|
|
||||||
} else if flap.Header.Channel == 2 {
|
} else if flap.Header.Channel == 2 {
|
||||||
snac := &SNAC{}
|
snac := &SNAC{}
|
||||||
err := snac.UnmarshalBinary(flap.Data)
|
err := snac.UnmarshalBinary(flap.Data.Bytes())
|
||||||
panicIfError(err)
|
panicIfError(err)
|
||||||
|
|
||||||
fmt.Printf("%+v\n", snac)
|
fmt.Printf("%+v\n", snac)
|
||||||
if tlvs, err := UnmarshalTLVs(snac.Data); err == nil {
|
if tlvs, err := UnmarshalTLVs(snac.Data.Bytes()); err == nil {
|
||||||
for _, tlv := range tlvs {
|
for _, tlv := range tlvs {
|
||||||
fmt.Printf("%+v\n", tlv)
|
fmt.Printf("%+v\n", tlv)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("%s\n\n", prettyBytes(snac.Data))
|
fmt.Printf("%s\n\n", prettyBytes(snac.Data.Bytes()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if service, ok := services[snac.Header.Family]; ok {
|
if service, ok := services[snac.Header.Family]; ok {
|
||||||
err = service.HandleSNAC(session, snac)
|
err = service.HandleSNAC(db, session, snac)
|
||||||
panicIfError(err)
|
panicIfError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
35
models/User.go
Normal file
35
models/User.go
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package models
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/uptrace/bun"
|
||||||
|
)
|
||||||
|
|
||||||
|
type User struct {
|
||||||
|
bun.BaseModel `bun:"table:users"`
|
||||||
|
UIN int `bun:",pk,autoincrement"`
|
||||||
|
Username string `bun:",unique"`
|
||||||
|
Password string
|
||||||
|
Cipher string
|
||||||
|
}
|
||||||
|
|
||||||
|
func UserByUsername(ctx context.Context, db *bun.DB, username string) (*User, error) {
|
||||||
|
user := new(User)
|
||||||
|
if err := db.NewSelect().Model(user).Where("username = ?", username).Scan(ctx, user); err != nil {
|
||||||
|
if err == sql.ErrNoRows {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return nil, errors.Wrap(err, "could not fetch user")
|
||||||
|
}
|
||||||
|
return user, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *User) Update(ctx context.Context, db *bun.DB) error {
|
||||||
|
if _, err := db.NewUpdate().Model(u).WherePK("uin").Exec(ctx); err != nil {
|
||||||
|
return errors.Wrap(err, "could not update user")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
4
models/fixtures.yml
Normal file
4
models/fixtures.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
- model: User
|
||||||
|
rows:
|
||||||
|
- username: toof
|
||||||
|
password: bar
|
|
@ -5,7 +5,7 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev:tsc": "tsc --watch",
|
"dev:tsc": "tsc --watch",
|
||||||
"dev:nodemon:auth-go": "nodemon --watch ./ -e go --delay 200ms --exec 'go run *.go || exit 1' --signal SIGTERM",
|
"dev:nodemon:auth-go": "nodemon --watch ./ -e go --ignore '*_test.go' --delay 200ms --exec 'go build && ./aim-oscar || exit 1' --signal SIGTERM",
|
||||||
"dev:nodemon:auth": "nodemon --watch ./dist --delay 200ms dist/src/main-auth.js",
|
"dev:nodemon:auth": "nodemon --watch ./dist --delay 200ms dist/src/main-auth.js",
|
||||||
"dev:nodemon:chat": "nodemon --watch ./dist --delay 200ms dist/src/main-chat.js",
|
"dev:nodemon:chat": "nodemon --watch ./dist --delay 200ms dist/src/main-chat.js",
|
||||||
"start": "tsc && node ./dist/index.js"
|
"start": "tsc && node ./dist/index.js"
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
import "github.com/uptrace/bun"
|
||||||
|
|
||||||
type Service interface {
|
type Service interface {
|
||||||
HandleSNAC(*Session, *SNAC) error
|
HandleSNAC(*bun.DB, *Session, *SNAC) error
|
||||||
}
|
}
|
||||||
|
|
20
snac.go
20
snac.go
|
@ -19,13 +19,10 @@ type SNACHeader struct {
|
||||||
|
|
||||||
type SNAC struct {
|
type SNAC struct {
|
||||||
Header SNACHeader
|
Header SNACHeader
|
||||||
Data []byte
|
Data Buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSNAC(family uint16, subtype uint16, data []byte) *SNAC {
|
func NewSNAC(family uint16, subtype uint16) *SNAC {
|
||||||
d := make([]byte, 0, len(data))
|
|
||||||
copy(d, data)
|
|
||||||
|
|
||||||
return &SNAC{
|
return &SNAC{
|
||||||
Header: SNACHeader{
|
Header: SNACHeader{
|
||||||
Family: family,
|
Family: family,
|
||||||
|
@ -33,17 +30,17 @@ func NewSNAC(family uint16, subtype uint16, data []byte) *SNAC {
|
||||||
Flags: 0,
|
Flags: 0,
|
||||||
RequestID: 0,
|
RequestID: 0,
|
||||||
},
|
},
|
||||||
Data: d,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SNAC) MarshalBinary() ([]byte, error) {
|
func (s *SNAC) MarshalBinary() ([]byte, error) {
|
||||||
var buf bytes.Buffer
|
buf := Buffer{}
|
||||||
|
|
||||||
binary.Write(&buf, binary.BigEndian, s.Header)
|
binary.Write(&buf, binary.BigEndian, s.Header)
|
||||||
n, err := buf.Write(s.Data)
|
b := s.Data.Bytes()
|
||||||
if n != len(s.Data) {
|
n, err := buf.Write(b)
|
||||||
return nil, fmt.Errorf("needed to write %d bytes to buffer but wrote %d", len(s.Data), n)
|
if n != len(b) {
|
||||||
|
return nil, fmt.Errorf("needed to write %d bytes to buffer but wrote %d", len(b), n)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -58,8 +55,7 @@ func (s *SNAC) UnmarshalBinary(data []byte) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
s.Data = make([]byte, buf.Len())
|
s.Data.Write(buf.Bytes())
|
||||||
copy(s.Data, buf.Bytes())
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
49
util.go
49
util.go
|
@ -2,20 +2,49 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func prettyBytes(bytes []byte) string {
|
// splitBy splits string in chunks of n
|
||||||
res := ""
|
// taken from: https://stackoverflow.com/a/69403603
|
||||||
hexStr := hex.EncodeToString(bytes)
|
func splitBy(s string, n int) []string {
|
||||||
for i := 0; i < len(hexStr); i++ {
|
var ss []string
|
||||||
if i > 0 && i%16 == 0 {
|
for i := 1; i < len(s); i++ {
|
||||||
res += "\n"
|
if i%n == 0 {
|
||||||
} else if i > 0 && i%2 == 0 {
|
ss = append(ss, s[:i])
|
||||||
res += " "
|
s = s[i:]
|
||||||
|
i = 1
|
||||||
}
|
}
|
||||||
res += string(hexStr[i])
|
|
||||||
}
|
}
|
||||||
return res
|
ss = append(ss, s)
|
||||||
|
return ss
|
||||||
|
}
|
||||||
|
|
||||||
|
func prettyBytes(bytes []byte) string {
|
||||||
|
hexStr := hex.EncodeToString(bytes)
|
||||||
|
rows := splitBy(hexStr, 16)
|
||||||
|
|
||||||
|
res := ""
|
||||||
|
for _, row := range rows {
|
||||||
|
byteGroups := splitBy(row, 2)
|
||||||
|
// Align string view to full 16 bytes + spaces
|
||||||
|
res += fmt.Sprintf("%-23s", strings.Join(byteGroups, " "))
|
||||||
|
|
||||||
|
res += " |"
|
||||||
|
for _, r := range byteGroups {
|
||||||
|
n, err := strconv.ParseInt(r, 16, 8)
|
||||||
|
if err != nil || (n < 32 || n > 126) {
|
||||||
|
res += "."
|
||||||
|
} else {
|
||||||
|
res += fmt.Sprint(n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res += "|\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.TrimSpace(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func panicIfError(err error) {
|
func panicIfError(err error) {
|
||||||
|
|
Loading…
Reference in a new issue