sing/common/tls/listener.go
2023-02-28 11:10:50 +08:00

25 lines
390 B
Go

package tls
import (
"net"
)
type Listener struct {
net.Listener
config ServerConfig
}
func NewListener(inner net.Listener, config ServerConfig) net.Listener {
l := new(Listener)
l.Listener = inner
l.config = config
return l
}
func (l *Listener) Accept() (net.Conn, error) {
conn, err := l.Listener.Accept()
if err != nil {
return nil, err
}
return l.config.Server(conn)
}