Browse Source

Fix: keep probeInterval consistent for the same outbound (#1230)

朱聖黎 (Zhu Sheng Li) 4 years ago
parent
commit
67cd3ac40e
1 changed files with 4 additions and 2 deletions
  1. 4 2
      app/observatory/observer.go

+ 4 - 2
app/observatory/observer.go

@@ -8,6 +8,7 @@ import (
 	"net"
 	"net"
 	"net/http"
 	"net/http"
 	"net/url"
 	"net/url"
+	"sort"
 	"sync"
 	"sync"
 	"time"
 	"time"
 
 
@@ -68,6 +69,7 @@ func (o *Observer) background() {
 		}
 		}
 
 
 		outbounds := hs.Select(o.config.SubjectSelector)
 		outbounds := hs.Select(o.config.SubjectSelector)
+		sort.Strings(outbounds)
 
 
 		o.updateStatus(outbounds)
 		o.updateStatus(outbounds)
 
 
@@ -111,7 +113,7 @@ func (o *Observer) probe(outbound string) ProbeResult {
 				trackedCtx := session.TrackedConnectionError(o.ctx, errorCollectorForRequest)
 				trackedCtx := session.TrackedConnectionError(o.ctx, errorCollectorForRequest)
 				conn, err := tagged.Dialer(trackedCtx, dest, outbound)
 				conn, err := tagged.Dialer(trackedCtx, dest, outbound)
 				if err != nil {
 				if err != nil {
-					return newError("cannot dial remote address", dest).Base(err)
+					return newError("cannot dial remote address ", dest).Base(err)
 				}
 				}
 				connection = conn
 				connection = conn
 				return nil
 				return nil
@@ -158,7 +160,7 @@ func (o *Observer) probe(outbound string) ProbeResult {
 		fullerr.WriteToLog()
 		fullerr.WriteToLog()
 		return ProbeResult{Alive: false, LastErrorReason: fullerr.Error()}
 		return ProbeResult{Alive: false, LastErrorReason: fullerr.Error()}
 	}
 	}
-	newError("the outbound ", outbound, "is alive:", GETTime.Seconds()).AtInfo().WriteToLog()
+	newError("the outbound ", outbound, " is alive:", GETTime.Seconds()).AtInfo().WriteToLog()
 	return ProbeResult{Alive: true, Delay: GETTime.Milliseconds()}
 	return ProbeResult{Alive: true, Delay: GETTime.Milliseconds()}
 }
 }