diff --git a/lib/bouncer/bouncers/v1/bctx/context.go b/lib/bouncer/bouncers/v1/bctx/context.go index d19c50ea9de798f21bf7c4349c56cdb81a3c8f24..43aa2827589b6ad2b6c01c5b534862983e578d82 100644 --- a/lib/bouncer/bouncers/v1/bctx/context.go +++ b/lib/bouncer/bouncers/v1/bctx/context.go @@ -68,6 +68,14 @@ func (T *Context) ServerRead() (zap.In, berr.Error) { return in, nil } +func (T *Context) ClientWrite() zap.Out { + return T.client.Write() +} + +func (T *Context) ServerWrite() zap.Out { + return T.server.Write() +} + func (T *Context) ClientSend(out zap.Out) berr.Error { err := T.client.Send(out) if err != nil { diff --git a/lib/bouncer/bouncers/v1/bouncer.go b/lib/bouncer/bouncers/v1/bouncer.go index dd44bd4e7e2c89cf126d2b10d4d7de8c7e7eea4e..ef810e584acf79fd467577b985e9a9e2eb7c9223 100644 --- a/lib/bouncer/bouncers/v1/bouncer.go +++ b/lib/bouncer/bouncers/v1/bouncer.go @@ -263,6 +263,17 @@ func Bounce(client, server zap.ReadWriter) { defer ctx.Done() err := transaction(&ctx) if err != nil { - log.Println("error", err) + switch e := err.(type) { + case berr.Client: + // send to client + out := client.Write() + packets.WriteErrorResponse(out, e.Error) + _ = client.Send(out) + case berr.Server: + log.Println("server error", e.Error) + default: + // unhandled error + panic(err) + } } }