Proxy is working in a simple mode now

This commit is contained in:
9seconds
2021-03-23 15:14:36 +03:00
parent 66c45dc83b
commit a3362c7ea4
9 changed files with 220 additions and 26 deletions
+33
View File
@@ -0,0 +1,33 @@
package relay
import "io"
type conn struct {
io.ReadWriteCloser
relay *Relay
}
func (c conn) Read(p []byte) (int, error) {
ctx := c.relay.ctx
n, err := c.ReadWriteCloser.Read(p)
select {
case <-ctx.Done():
case c.relay.tickChannel <- struct{}{}:
}
return n, err // nolint: wrapcheck
}
func (c conn) Write(p []byte) (int, error) {
ctx := c.relay.ctx
n, err := c.ReadWriteCloser.Write(p)
select {
case <-ctx.Done():
case c.relay.tickChannel <- struct{}{}:
}
return n, err // nolint: wrapcheck
}