mirror of
https://github.com/cbeuw/Cloak.git
synced 2024-11-11 13:11:03 +00:00
42 lines
918 B
Go
42 lines
918 B
Go
package multiplex
|
|
|
|
import (
|
|
"bufio"
|
|
"io"
|
|
"io/ioutil"
|
|
"net"
|
|
"time"
|
|
)
|
|
|
|
type blackhole struct {
|
|
hole *bufio.Writer
|
|
closer chan int
|
|
}
|
|
|
|
func newBlackHole() *blackhole {
|
|
return &blackhole{
|
|
hole: bufio.NewWriter(ioutil.Discard),
|
|
closer: make(chan int),
|
|
}
|
|
}
|
|
func (b *blackhole) Read([]byte) (int, error) {
|
|
<-b.closer
|
|
return 0, io.EOF
|
|
}
|
|
func (b *blackhole) Write(in []byte) (int, error) { return b.hole.Write(in) }
|
|
func (b *blackhole) Close() error {
|
|
b.closer <- 1
|
|
return nil
|
|
}
|
|
func (b *blackhole) LocalAddr() net.Addr {
|
|
ret, _ := net.ResolveTCPAddr("tcp", "127.0.0.1")
|
|
return ret
|
|
}
|
|
func (b *blackhole) RemoteAddr() net.Addr {
|
|
ret, _ := net.ResolveTCPAddr("tcp", "127.0.0.1")
|
|
return ret
|
|
}
|
|
func (b *blackhole) SetDeadline(t time.Time) error { return nil }
|
|
func (b *blackhole) SetReadDeadline(t time.Time) error { return nil }
|
|
func (b *blackhole) SetWriteDeadline(t time.Time) error { return nil }
|