mirror of https://github.com/v2ray/v2ray-core
parent
3be6c72211
commit
5ec3fe093d
@ -1,30 +0,0 @@
|
||||
package websocket
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"v2ray.com/core/common/errors"
|
||||
)
|
||||
|
||||
type StoppableListener struct {
|
||||
net.Listener //Wrapped listener
|
||||
}
|
||||
|
||||
func NewStoppableListener(l net.Listener) (*StoppableListener, error) {
|
||||
|
||||
retval := &StoppableListener{}
|
||||
retval.Listener = l
|
||||
return retval, nil
|
||||
}
|
||||
|
||||
var StoppedError = errors.New("Listener stopped")
|
||||
|
||||
func (sl *StoppableListener) Accept() (net.Conn, error) {
|
||||
newConn, err := sl.Listener.Accept()
|
||||
return newConn, err
|
||||
|
||||
}
|
||||
|
||||
func (sl *StoppableListener) Stop() {
|
||||
sl.Listener.Close()
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package websocket
|
||||
|
||||
import "crypto/tls"
|
||||
|
||||
func getstopableTLSlistener(tlsConfig *tls.Config, listenaddr string) (*StoppableListener, error) {
|
||||
ln, err := tls.Listen("tcp", listenaddr, tlsConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
lns, err := NewStoppableListener(ln)
|
||||
return lns, err
|
||||
}
|
Loading…
Reference in new issue