-
Notifications
You must be signed in to change notification settings - Fork 0
/
mock.go
40 lines (33 loc) · 1.46 KB
/
mock.go
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
32
33
34
35
36
37
38
39
40
/*
* Snitch is a SNI proxy library.
* Copyright (C) 2022 İrem Kuyucu <siren@kernal.eu>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package snitch
import (
"io"
"net"
"time"
)
// Mock io.Reader to satisfy the net.Conn interface
// https://www.agwa.name/blog/post/writing_an_sni_proxy_in_go
type mockConn struct {
reader io.Reader
}
func (conn mockConn) Read(p []byte) (int, error) { return conn.reader.Read(p) }
func (conn mockConn) Write(p []byte) (int, error) { return 0, nil }
func (conn mockConn) Close() error { return nil }
func (conn mockConn) LocalAddr() net.Addr { return nil }
func (conn mockConn) RemoteAddr() net.Addr { return nil }
func (conn mockConn) SetDeadline(t time.Time) error { return nil }
func (conn mockConn) SetReadDeadline(t time.Time) error { return nil }
func (conn mockConn) SetWriteDeadline(t time.Time) error { return nil }