package module import ( "encoding/hex" "tunnel/pkg/server/queue" ) func hexEncoder(rq, wq queue.Q) error { enc := hex.NewEncoder(wq.Writer()) for b := range rq { enc.Write(b) } return nil } func hexDecoder(rq, wq queue.Q) error { r := hex.NewDecoder(rq.Reader()) w := wq.Writer() return queue.IoCopy(r, w) } func init() { registerPipe("hex", Pipe(hexEncoder)) registerPipe("unhex", Pipe(hexDecoder)) }