Documentation
¶
Overview ¶
Package discovery implements the server discovery by contacting disco.eduvpn.org and returning the data as a Go structure
Index ¶
- Variables
- type Discovery
- func (discovery *Discovery) Fill() error
- func (discovery *Discovery) MarkOrganizationsExpired()
- func (discovery *Discovery) MarkServersExpired()
- func (discovery *Discovery) Organizations(ctx context.Context, cache bool) (*Organizations, bool, error)
- func (discovery *Discovery) SecureHomeArgs(orgID string) (*Organization, *Server, error)
- func (discovery *Discovery) SecureLocationList() []string
- func (discovery *Discovery) ServerByCountryCode(countryCode string) (*Server, error)
- func (discovery *Discovery) ServerByURL(baseURL string, srvType string) (*Server, error)
- func (discovery *Discovery) Servers(ctx context.Context, cache bool) (*Servers, bool, error)
- func (discovery *Discovery) UpdateOrganizations(other Organizations)
- func (discovery *Discovery) UpdateServers(other Servers)
- type ErrCountryNotFound
- type Organization
- type Organizations
- type Server
- type Servers
Constants ¶
This section is empty.
Variables ¶
var DiscoURL = "https://disco.eduvpn.org/v2/"
DiscoURL is the URL used for fetching the discovery files and signatures
var HasCache bool
HasCache denotes whether or not we have an embedded cache available
Functions ¶
This section is empty.
Types ¶
type Discovery ¶
type Discovery struct {
// Organizations represents the organizations that are returned by the discovery server
OrganizationList Organizations `json:"organizations"`
// Servers represents the servers that are returned by the discovery server
ServerList Servers `json:"servers"`
// contains filtered or unexported fields
}
Discovery is the main structure used for this package.
func (*Discovery) MarkOrganizationsExpired ¶
func (discovery *Discovery) MarkOrganizationsExpired()
MarkOrganizationsExpired marks the organizations as expired
func (*Discovery) MarkServersExpired ¶
func (discovery *Discovery) MarkServersExpired()
MarkServersExpired marks the servers as expired
func (*Discovery) Organizations ¶
func (discovery *Discovery) Organizations(ctx context.Context, cache bool) (*Organizations, bool, error)
Organizations returns the discovery organizations The second return value is a boolean that indicates whether a fresh list was updated internally If there was an error, a cached copy is returned if available. cache is set to true if there should be no network call done
func (*Discovery) SecureHomeArgs ¶
func (discovery *Discovery) SecureHomeArgs(orgID string) (*Organization, *Server, error)
SecureHomeArgs returns the secure internet home server arguments: - The organization it belongs to - The secure internet server itself An error is returned if and only if nil is returned for the organization.
func (*Discovery) SecureLocationList ¶
SecureLocationList returns a slice of all the available locations.
func (*Discovery) ServerByCountryCode ¶
ServerByCountryCode returns the discovery server by the country code An error is returned if and only if nil is returned for the server.
func (*Discovery) ServerByURL ¶
ServerByURL returns the discovery server by the base URL and the according type ("secure_internet", "institute_access") An error is returned if and only if nil is returned for the server.
func (*Discovery) Servers ¶
Servers returns the discovery servers The second return value is a boolean that indicates whether a fresh list was updated internally If there was an error, a cached copy is returned if available. cache is set to true if there should be no network call done
func (*Discovery) UpdateOrganizations ¶
func (discovery *Discovery) UpdateOrganizations(other Organizations)
UpdateOrganizations updates the discovery organizations to the new version It does this by checking versions
func (*Discovery) UpdateServers ¶
UpdateServers updates the discovery servers to the new version It does this by checking versions
type ErrCountryNotFound ¶
type ErrCountryNotFound struct {
CountryCode string
}
ErrCountryNotFound is used when the secure internet country cannot be found
func (*ErrCountryNotFound) Error ¶
func (cnf *ErrCountryNotFound) Error() string
type Organization ¶
type Organization struct {
// Organization is the embedded public type that is a subset of this thus common Organization
discotypes.Organization
// SecureInternetHome is the secure internet home server that belongs to this organization
// Omitted if none is defined
SecureInternetHome string `json:"secure_internet_home"`
// KeywordList is the list of keywords
// Omitted if none is defined
KeywordList discotypes.MapOrString `json:"keyword_list,omitempty"`
}
Organization is a single discovery Organization
func (*Organization) Score ¶
func (o *Organization) Score(search string) int
Score returns the levenshstein score for a search query `search` on the organizations
type Organizations ¶
type Organizations struct {
// Version is the version field in discovery. The Go library checks this for rollbacks
Version uint64 `json:"v"`
// List is the list of organizations, omitted if empty
List []Organization `json:"organization_list,omitempty"`
// Timestamp is the timestamp that is internally used by the Go library to keep track
// of when the organizations were last updated
Timestamp time.Time `json:"go_timestamp"`
// UpdateHeader is the result of the "Last-Modified" header
UpdateHeader time.Time `json:"go_update_header"`
}
Organizations are the list of organizations from https://disco.eduvpn.org/v2/organization_list.json
type Server ¶
type Server struct {
// Server is the embedded public type that is a subset of this common Server
discotypes.Server
// AuthenticationURLTemplate is the template to be used for authentication to skip WAYF
AuthenticationURLTemplate string `json:"authentication_url_template,omitempty"`
// KeywordList are the keywords of the server, omitted if empty
KeywordList discotypes.MapOrString `json:"keyword_list,omitempty"`
// PublicKeyList are the public keys of the server. Currently not used in this lib but returned by the upstream discovery server
PublicKeyList []string `json:"public_key_list,omitempty"`
// SupportContact is the list/slice of support contacts
SupportContact []string `json:"support_contact,omitempty"`
}
Server is a single discovery server
type Servers ¶
type Servers struct {
// Version is the version field in discovery. The Go library checks this for rollbacks
Version uint64 `json:"v"`
// List is the list of servers, omitted if empty
List []Server `json:"server_list,omitempty"`
// Timestamp is a timestamp that is internally used by the Go library to keek track
// of when the servers were last updated
Timestamp time.Time `json:"go_timestamp"`
// UpdateHeader is the result of the "Last-Modified" header
UpdateHeader time.Time `json:"go_update_header"`
}
Servers are the list of servers from https://disco.eduvpn.org/v2/server_list.json