2 goircd -- minimalistic simple Internet Relay Chat (IRC) server
3 Copyright (C) 2014-2022 Sergey Matveev <stargrave@stargrave.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, version 3 of the License.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 type TestingConn struct {
32 func NewTestingConn() *TestingConn {
34 inbound: make(chan string, 8),
35 outbound: make(chan string, 8),
36 closed: make(chan struct{}),
40 func (conn TestingConn) Error() string {
41 return "i am finished"
44 func (conn *TestingConn) Read(b []byte) (n int, err error) {
46 case msg := <-conn.inbound:
50 for n, bt := range append([]byte(msg), CRLF...) {
53 return len(msg) + 2, nil
61 func (a MyAddr) String() string {
64 func (a MyAddr) Network() string {
68 func (conn *TestingConn) Write(b []byte) (n int, err error) {
69 conn.outbound <- string(b)
73 func (conn *TestingConn) Close() error {
79 func (conn TestingConn) LocalAddr() net.Addr {
83 func (conn TestingConn) RemoteAddr() net.Addr {
87 func (conn TestingConn) SetDeadline(t time.Time) error {
91 func (conn TestingConn) SetReadDeadline(t time.Time) error {
95 func (conn TestingConn) SetWriteDeadline(t time.Time) error {