discovery

package
v0.0.0-...-4b2ba41 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package discovery implements the server discovery by contacting disco.eduvpn.org and returning the data as a Go structure

Index

Constants

This section is empty.

Variables

View Source
var DiscoURL = "https://disco.eduvpn.org/v2/"

DiscoURL is the URL used for fetching the discovery files and signatures

View Source
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) Fill

func (discovery *Discovery) Fill() error

Fill makes sure that the cache is filled with the embedded discovery

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

func (discovery *Discovery) SecureLocationList() []string

SecureLocationList returns a slice of all the available locations.

func (*Discovery) ServerByCountryCode

func (discovery *Discovery) ServerByCountryCode(countryCode string) (*Server, error)

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

func (discovery *Discovery) ServerByURL(
	baseURL string,
	srvType string,
) (*Server, error)

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

func (discovery *Discovery) Servers(ctx context.Context, cache bool) (*Servers, bool, error)

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

func (discovery *Discovery) UpdateServers(other Servers)

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

func (*Server) Score

func (s *Server) Score(search string) int

Score returns the score of the search query `str` on this 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL