File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,11 @@ import (
1414)
1515
1616func ICMPPing (target string , interval float64 ) {
17+ if PoP == "" {
18+ log .Error ().Msg ("PoP is empty, skipping ICMP ping" )
19+ return
20+ }
21+
1722 ctx , cancel := context .WithTimeout (context .Background (), sessionDuration )
1823 defer cancel ()
1924
@@ -116,6 +121,11 @@ func ICMPPing(target string, interval float64) {
116121}
117122
118123func IRTTPing () {
124+ if PoP == "" {
125+ log .Error ().Msg ("PoP is empty, skipping IRTT ping" )
126+ return
127+ }
128+
119129 ctx , cancel := context .WithTimeout (context .Background (), sessionDuration + time .Minute * 10 )
120130
121131 today := checkDirectory ()
@@ -127,7 +137,7 @@ func IRTTPing() {
127137 defer cancel ()
128138
129139 var local string
130- if IPVersion == 6 {
140+ if IPVersion == 6 && len ( externalIPv6 ) > 0 {
131141 local = fmt .Sprintf ("--local=[%s]" , externalIPv6 )
132142 } else {
133143 local = fmt .Sprintf ("--local=%s" , IRTTLocalIP )
Original file line number Diff line number Diff line change @@ -143,7 +143,12 @@ func getExternalIP(version int) string {
143143 log .Error ().Err (err ).Msgf ("get external IP%d addresses failed: %s" , version , string (output ))
144144 return ""
145145 }
146- return strings .Trim (string (output ), "\n " )
146+ ip := strings .Trim (string (output ), "\n " )
147+ if net .ParseIP (ip ) == nil {
148+ log .Error ().Msgf ("get external IP%d addresses failed: invalid IP %s" , version , ip )
149+ return ""
150+ }
151+ return ip
147152}
148153
149154func getStarlinkPoP (ip string ) string {
@@ -243,6 +248,7 @@ func getStarlinkIPv6ActiveGateway() string {
243248func getGateway () string {
244249 gatewayIP := ""
245250 externalIP := ""
251+ PoP = ""
246252
247253 if ManualSpecifiedGateway != "" {
248254 if net .ParseIP (ManualSpecifiedGateway ).To4 () != nil {
@@ -326,8 +332,6 @@ func getGateway() string {
326332
327333 if externalIP != "" {
328334 PoP = getStarlinkPoP (externalIP )
329- } else {
330- PoP = ""
331335 }
332336 StarlinkGateway = gatewayIP
333337
You can’t perform that action at this time.
0 commit comments