func (a *agent) Start() error {
	go func() {
		if err := a.logListener(); err != nil {
			log.Errorf("Log listener returned err: %v", err)
		}
	}()
	return a.client.Start()
}
Start initiates the local UDP based log listener socket as well as starts the main
agent connection handler loop.
package agent
import (
	"bytes"
	"context"
	"encoding/json"
	"github.com/leighmacdonald/gbans/internal/web/ws"
	"github.com/pkg/errors"
	log "github.com/sirupsen/logrus"
	"io"
	"net"
	"strings"
)
type instance struct {
	Name string
	Secret []byte
}
type InstanceCollection []instance
type Opts struct {
	ServerAddress    string
	LogListenAddress string
	Instances        InstanceCollection
}
type agent struct {
	ctx         context.Context
	messageChan chan string
	opts        Opts
	client      *ws.Client
	l           log.Logger
}
func NewAgent(ctx context.Context, o Opts) (*agent, error) {
	handlers := ws.Handlers{
		ws.Sup: func(payload ws.Payload) error {
			log.Debugf("Got sup.")
			return nil
		},
	}
	c, err := ws.NewClient(o.ServerAddress, handlers)
	if err != nil {
		return nil, err
	}
	return &agent{ctx: ctx, opts: o, messageChan: make(chan string), client: c}, nil
}
var header = []byte{255, 255, 255, 255}
const (
	mbNoSecret = 0x52
	mbSecret   = 0x53
)