( ctx context.Context, kind string )
| 331 | } |
| 332 | |
| 333 | func ( c *Client ) PrintServerList( ctx context.Context, kind string ) ( err error ) { |
| 334 | response, _, err := c.FetchServerList(ctx) |
| 335 | if err != nil { return } |
| 336 | |
| 337 | all := []locations.Location{} |
| 338 | if err = json.Unmarshal( response, &all ); err != nil { return } |
| 339 | |
| 340 | fmt.Printf( "%-30s | %-20s | %s\n", "Location", "Hostname", "Specs" ) |
| 341 | fmt.Printf( "%-30s | %-20s | %s\n", "--------", "--------", "-----" ) |
| 342 | |
| 343 | var printServers func( locs []locations.Location, k string ) |
| 344 | printServers = func( locs []locations.Location, k string ) { |
| 345 | for _, loc := range locs { |
| 346 | special := []string{} |
| 347 | for _, tag := range loc.Tags { |
| 348 | switch tag { |
| 349 | case "free": special = append(special, "free" ) |
| 350 | case "10g": special = append(special, "10g" ) |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | hostname := strings.TrimSuffix( loc.Hostname, "-v4.hideservers.net" ) |
| 355 | fmt.Printf( "%-30s | %-20s | %s\n", loc.DisplayName, hostname, strings.Join(special, ",") ) |
| 356 | if len(loc.Children) > 0 { printServers( loc.Children, k ) } |
| 357 | } |
| 358 | } |
| 359 | printServers( all, kind ) |
| 360 | return |
| 361 | } |
| 362 | |
| 363 | // ExternalIps fetches external Ips from ipcheck(-v6).hideservers.net |
| 364 | func ( c *Client ) ExternalIps( ctx context.Context, routeFn func( bool, net.IP ) error ) ( ips []net.IP ) { |
no test coverage detected