blob: 362dbd429b3d849fcfd4f3c7f6c98e6eed9215fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package hook
import (
"encoding/hex"
"tunnel/pkg/server/queue"
)
type hexPipe struct{}
func (hexPipe) Send(rq, wq queue.Q) error {
enc := hex.NewEncoder(wq.Writer())
for b := range rq {
enc.Write(b)
}
return nil
}
func (hexPipe) Recv(rq, wq queue.Q) error {
r := hex.NewDecoder(rq.Reader())
return queue.IoCopy(r, wq.Writer())
}
func init() {
registerPipe("hex", hexPipe{})
}
|