@@ -156,9 +156,11 @@ func (c *CmdServers) Run() error {
156
156
157
157
firstHostStr := ""
158
158
firstHostLoadStr := ""
159
+ firstHostIspStr := ""
159
160
if c .hosts {
160
161
firstHostStr = "\t "
161
162
if len (s .hosts ) > 0 {
163
+ firstHostIspStr = s .hosts [0 ].isp
162
164
firstHostStr = s .hosts [0 ].hostname + "\t "
163
165
if c .load {
164
166
@@ -167,7 +169,21 @@ func (c *CmdServers) Run() error {
167
169
}
168
170
}
169
171
170
- str = fmt .Sprintf ("%s\t %s\t %s (%s)\t %s\t %s\t %s\t %s%s%s" , s .protocol , s .gateway , s .city , s .countryCode , s .country , s .isp , IPvInfo , pingStr , firstHostStr , firstHostLoadStr )
172
+ // Get ISP for first host (as it represent the server when we don't show hosts)
173
+ // if all hosts have the same ISP, show it, otherwise show "<multiple ISPs>"
174
+ if ! c .hosts {
175
+ for i , h := range s .hosts {
176
+ if i == 0 {
177
+ firstHostIspStr = h .isp
178
+ }
179
+ if strings .Compare (firstHostIspStr , h .isp ) != 0 {
180
+ firstHostIspStr = "<multiple ISPs>"
181
+ break
182
+ }
183
+ }
184
+ }
185
+
186
+ str = fmt .Sprintf ("%s\t %s\t %s (%s)\t %s\t %s\t %s\t %s%s%s" , s .protocol , s .gateway , s .city , s .countryCode , s .country , firstHostIspStr , IPvInfo , pingStr , firstHostStr , firstHostLoadStr )
171
187
fmt .Fprintln (w , str )
172
188
173
189
if c .hosts && len (s .hosts ) > 1 {
@@ -183,7 +199,7 @@ func (c *CmdServers) Run() error {
183
199
if c .load {
184
200
loadStr = fmt .Sprintf ("%d" , int (h .load + 0.5 )) + "%\t "
185
201
}
186
- str = fmt .Sprintf ("%s\t %s\t %s %s\t %s\t %s\t %s\t %s%s%s" , "" , "" , "" , "" , "" , "" , "" , pingStr , h .hostname + "\t " , loadStr )
202
+ str = fmt .Sprintf ("%s\t %s\t %s %s\t %s\t %s\t %s\t %s%s%s" , "" , "" , "" , "" , "" , h . isp , "" , pingStr , h .hostname + "\t " , loadStr )
187
203
fmt .Fprintln (w , str )
188
204
}
189
205
}
@@ -242,7 +258,7 @@ func serversListByVpnType(servers apitypes.ServersInfoResponse, t vpn.Type) []se
242
258
if len (h .IPv6 .LocalIP ) > 0 {
243
259
isIPv6Tunnel = true
244
260
}
245
- hosts = append (hosts , hostDesc {host : strings .TrimSpace (h .Host ), hostname : strings .TrimSpace (h .Hostname ), load : h .Load })
261
+ hosts = append (hosts , hostDesc {host : strings .TrimSpace (h .Host ), hostname : strings .TrimSpace (h .Hostname ), load : h .Load , isp : h . ISP })
246
262
}
247
263
ret = append (ret , serverDesc {protocol : ProtoName_WireGuard , gateway : s .Gateway , city : s .City , countryCode : s .CountryCode , country : s .Country , isp : s .ISP , hosts : hosts , isIPv6Tunnel : isIPv6Tunnel })
248
264
}
@@ -253,7 +269,7 @@ func serversListByVpnType(servers apitypes.ServersInfoResponse, t vpn.Type) []se
253
269
hosts := make ([]hostDesc , 0 , len (s .Hosts ))
254
270
255
271
for _ , h := range s .Hosts {
256
- hosts = append (hosts , hostDesc {host : strings .TrimSpace (h .Host ), hostname : strings .TrimSpace (h .Hostname ), load : h .Load })
272
+ hosts = append (hosts , hostDesc {host : strings .TrimSpace (h .Host ), hostname : strings .TrimSpace (h .Hostname ), load : h .Load , isp : h . ISP })
257
273
}
258
274
ret = append (ret , serverDesc {protocol : ProtoName_OpenVPN , gateway : s .Gateway , city : s .City , countryCode : s .CountryCode , country : s .Country , isp : s .ISP , hosts : hosts })
259
275
}
@@ -381,6 +397,7 @@ type hostDesc struct {
381
397
host string // ip
382
398
pingMs int
383
399
load float32
400
+ isp string
384
401
}
385
402
386
403
type serverDesc struct {
0 commit comments