mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-02-20 23:47:21 -05:00
Use stopable listener for HTTP
This commit is contained in:
parent
a36582b294
commit
c8cd1320c7
@ -27,6 +27,7 @@ type WSListener struct {
|
|||||||
sync.Mutex
|
sync.Mutex
|
||||||
acccepting bool
|
acccepting bool
|
||||||
awaitingConns chan *ConnectionWithError
|
awaitingConns chan *ConnectionWithError
|
||||||
|
listener *StoppableListener
|
||||||
}
|
}
|
||||||
|
|
||||||
func ListenWS(address v2net.Address, port v2net.Port) (internet.Listener, error) {
|
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)
|
errchan := make(chan error)
|
||||||
|
|
||||||
listenerfunc := func() 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" {
|
if effectiveConfig.Pto == "wss" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user