mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-30 04:21:29 +00:00
platform: Fix clash server reload on android
This commit is contained in:
parent
34f2c32ad1
commit
eaa8e2dc70
|
@ -7,7 +7,9 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/sagernet/sing-box/adapter"
|
"github.com/sagernet/sing-box/adapter"
|
||||||
|
@ -143,7 +145,18 @@ func (s *Server) PreStart() error {
|
||||||
func (s *Server) Start() error {
|
func (s *Server) Start() error {
|
||||||
if s.externalController {
|
if s.externalController {
|
||||||
s.checkAndDownloadExternalUI()
|
s.checkAndDownloadExternalUI()
|
||||||
listener, err := net.Listen("tcp", s.httpServer.Addr)
|
var (
|
||||||
|
listener net.Listener
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
for i := 0; i < 3; i++ {
|
||||||
|
listener, err = net.Listen("tcp", s.httpServer.Addr)
|
||||||
|
if runtime.GOOS == "android" && errors.Is(err, syscall.EADDRINUSE) {
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return E.Cause(err, "external controller listen error")
|
return E.Cause(err, "external controller listen error")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue