-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathproxy_blackhole.go
More file actions
31 lines (26 loc) · 1019 Bytes
/
proxy_blackhole.go
File metadata and controls
31 lines (26 loc) · 1019 Bytes
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
29
30
31
package proxyclient
import (
"context"
"errors"
"net"
"net/url"
"time"
)
func init() {
RegisterScheme("BLACKHOLE", newBlackholeProxyClient)
}
func newBlackholeProxyClient(_ *url.URL, _ Dial) (dial Dial, err error) {
dial = func(ctx context.Context, network, address string) (net.Conn, error) {
return blackholeConn{}, nil
}
return
}
type blackholeConn struct{}
func (blackholeConn) Read([]byte) (int, error) { return 0, nil }
func (blackholeConn) Write(buffer []byte) (int, error) { return len(buffer), nil }
func (blackholeConn) Close() error { return nil }
func (blackholeConn) LocalAddr() net.Addr { return nil }
func (blackholeConn) RemoteAddr() net.Addr { return nil }
func (blackholeConn) SetDeadline(time.Time) error { return errors.New("unsupported") }
func (blackholeConn) SetReadDeadline(time.Time) error { return errors.New("unsupported") }
func (blackholeConn) SetWriteDeadline(time.Time) error { return errors.New("unsupported") }