Initial commit

This commit is contained in:
nxshock 2023-12-28 16:00:04 +05:00
commit 0b430973c9
14 changed files with 460 additions and 0 deletions

34
listener.go Normal file
View file

@ -0,0 +1,34 @@
package main
import (
"net"
)
// Listener implements net.Listener and additional Add(net.Conn) method.
type Listener struct {
c chan net.Conn
}
func NewListener() *Listener {
c := make(chan net.Conn)
return &Listener{c: c}
}
func (m *Listener) Add(conn net.Conn) {
m.c <- conn
}
func (m *Listener) Accept() (net.Conn, error) {
return <-m.c, nil
}
func (m *Listener) Close() error {
close(m.c)
return nil
}
func (m *Listener) Addr() net.Addr {
return nil
}