improve error handling

This commit is contained in:
AJ ONeal 2020-06-03 00:35:56 -06:00
parent 077ea2d12d
commit daa152b376
3 changed files with 9 additions and 1 deletions

View File

@ -34,7 +34,7 @@ func NewPacker(header *Header) *Packer {
func splitHeader(header []byte, names []string) (map[string]string, error) {
parts := strings.Split(string(header), ",")
if p, n := len(parts), len(names); p > n {
return nil, fmt.Errorf("Header contains %d extra fields", p-n)
//return nil, fmt.Errorf("Header contains %d extra fields", p-n)
} else if p < n {
return nil, fmt.Errorf("Header missing fields %q", names[p:])
}

View File

@ -257,6 +257,10 @@ func (c *Connection) Reader(ctx context.Context) {
// unpack the message.
p, err := packer.ReadMessage(message)
if nil != err {
fmt.Println("error during msg parse:", err)
continue
}
key := fmt.Sprintf("%s:%d", p.Address(), p.Port())
track, err := connectionTrack.Lookup(key)

View File

@ -89,6 +89,10 @@ func listenAndServeTargets(mx *mplexy.MPlexy, listener net.Listener) error {
log.Println("websocket opening ", r.RemoteAddr, " ", r.Host)
authz, err := mx.AuthorizeTarget(r)
if nil != err {
log.Println("WebSocket authorization failed", err)
return
}
var upgrader = websocket.Upgrader{
ReadBufferSize: 65535,
WriteBufferSize: 65535,