improve error handling
This commit is contained in:
parent
077ea2d12d
commit
daa152b376
|
@ -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:])
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue