Fix: listener patch diff

This commit is contained in:
Dreamacro
2021-08-01 00:35:37 +08:00
parent 3705996974
commit 1bfebd0d03
9 changed files with 158 additions and 88 deletions

View File

@ -10,9 +10,26 @@ import (
type Listener struct {
listener net.Listener
addr string
closed bool
}
// RawAddress implements C.Listener
func (l *Listener) RawAddress() string {
return l.addr
}
// Address implements C.Listener
func (l *Listener) Address() string {
return l.listener.Addr().String()
}
// Close implements C.Listener
func (l *Listener) Close() error {
l.closed = true
return l.listener.Close()
}
func New(addr string, in chan<- C.ConnContext) (*Listener, error) {
return NewWithAuthenticate(addr, in, true)
}
@ -30,6 +47,7 @@ func NewWithAuthenticate(addr string, in chan<- C.ConnContext, authenticate bool
hl := &Listener{
listener: l,
addr: addr,
}
go func() {
for {
@ -46,12 +64,3 @@ func NewWithAuthenticate(addr string, in chan<- C.ConnContext, authenticate bool
return hl, nil
}
func (l *Listener) Close() {
l.closed = true
l.listener.Close()
}
func (l *Listener) Address() string {
return l.listener.Addr().String()
}