1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-18 02:16:10 -05:00

Use stopable listener for HTTP

This commit is contained in:
Shelikhoo 2016-08-15 18:17:29 +08:00
parent a36582b294
commit c8cd1320c7
No known key found for this signature in database
GPG Key ID: 7791BDB0709ABD21

View File

@ -27,6 +27,7 @@ type WSListener struct {
sync.Mutex
acccepting bool
awaitingConns chan *ConnectionWithError
listener *StoppableListener
}
func ListenWS(address v2net.Address, port v2net.Port) (internet.Listener, error) {
@ -69,7 +70,15 @@ func (wsl *WSListener) listenws(address v2net.Address, port v2net.Port) error {
errchan := make(chan error)
listenerfunc := func() error {
return http.ListenAndServe(address.String()+":"+strconv.Itoa(int(port.Value())), nil)
ol, err := net.Listen("tcp", address.String()+":"+strconv.Itoa(int(port.Value())))
if err != nil {
return err
}
wsl.listener, err = NewStoppableListener(ol)
if err != nil {
return err
}
return http.Serve(wsl.listener, nil)
}
if effectiveConfig.Pto == "wss" {