Chore: Listener should not expose original net.Listener

This commit is contained in:
Dreamacro
2021-06-13 23:05:22 +08:00
parent 6091fcdfec
commit f231a63e93
7 changed files with 33 additions and 33 deletions

View File

@ -12,10 +12,10 @@ import (
)
type Listener struct {
net.Listener
address string
closed bool
cache *cache.Cache
listener net.Listener
address string
closed bool
cache *cache.Cache
}
func New(addr string, in chan<- C.ConnContext) (*Listener, error) {
@ -27,7 +27,7 @@ func New(addr string, in chan<- C.ConnContext) (*Listener, error) {
ml := &Listener{l, addr, false, cache.New(30 * time.Second)}
go func() {
for {
c, err := ml.Accept()
c, err := ml.listener.Accept()
if err != nil {
if ml.closed {
break
@ -43,7 +43,7 @@ func New(addr string, in chan<- C.ConnContext) (*Listener, error) {
func (l *Listener) Close() {
l.closed = true
l.Listener.Close()
l.listener.Close()
}
func (l *Listener) Address() string {