MCPcopy Create free account
hub / github.com/eventure/hide.client.linux / FetchCategoryList

Method FetchCategoryList

rest/client.go:292–314  ·  view source on GitHub ↗
( ctx context.Context )

Source from the content-addressed store, hash-verified

290}
291
292func ( c *Client ) FetchCategoryList( ctx context.Context ) ( err error ) {
293 c.Config.Port = 443
294 c.Config.CA = ""
295
296 if err = c.Init(); err != nil { log.Println( "Cats: [ERR] REST Client setup failed:", err ); return }
297 c.client.Transport.(*http.Transport).Protocols.SetHTTP1( true )
298 if err = c.Resolve( ctx ); err != nil { log.Println( "Cats: [ERR] DNS failed:", err ); return }
299
300 response, _, err := c.get( ctx, "https://" + c.remote.String() + "/categorization/categories.json" )
301 if err != nil { return }
302
303 type Category struct {
304 Name string
305 Description string
306 }
307 cats := []Category{}
308 if err = json.Unmarshal( response, &cats ); err != nil { return }
309
310 log.Printf( "%40s | %s\n", "CATEGORY", "DESCRIPTION" )
311 log.Printf( "%40s | %s\n", "--------", "-----------" )
312 for _, cat := range cats { log.Printf( "%40s | %s\n", cat.Name, cat.Description ) }
313 return
314}
315
316// FetchServerList fetches the server list from api.hide.me. It has to use system-wide CA store, has to relax PIN checks, use api.hide.me SAN and may use HTTP2
317func ( c *Client ) FetchServerList( ctx context.Context ) ( response []byte, headers http.Header, err error ) {

Callers 1

categoriesFunction · 0.80

Calls 4

InitMethod · 0.95
ResolveMethod · 0.95
getMethod · 0.95
StringMethod · 0.80

Tested by

no test coverage detected