Documentation ¶
Overview ¶
Package psinet implements psinet database services. The psinet database is a JSON-format file containing information about the Psiphon network, including sponsors, home pages, stats regexes, available upgrades, and other servers for discovery. This package also implements the Psiphon discovery algorithm.
Index ¶
- Constants
- type ClientVersion
- type Database
- func (db *Database) DiscoverServers(discoveryValue int) []string
- func (db *Database) GetHomepages(sponsorID, clientRegion, clientASN string, isMobilePlatform bool) []string
- func (db *Database) GetHttpsRequestRegexes(sponsorID string) []map[string]string
- func (db *Database) GetRandomizedHomepages(sponsorID, clientRegion, clientASN string, isMobilePlatform bool) []string
- func (db *Database) GetUpgradeClientVersion(clientVersion, clientPlatform string) string
- func (db *Database) IsValidServerEntryTag(serverEntryTag string) bool
- type DiscoveryServer
- type HomePage
- type HttpsRequestRegex
- type Sponsor
Constants ¶
const (
MAX_DATABASE_AGE_FOR_SERVER_ENTRY_VALIDITY = 48 * time.Hour
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientVersion ¶
type ClientVersion struct {
Version string `json:"version"`
}
type Database ¶
type Database struct { common.ReloadableFile Sponsors map[string]*Sponsor `json:"sponsors"` Versions map[string][]ClientVersion `json:"client_versions"` DefaultSponsorID string `json:"default_sponsor_id"` ValidServerEntryTags map[string]bool `json:"valid_server_entry_tags"` DiscoveryServers []*DiscoveryServer `json:"discovery_servers"` // contains filtered or unexported fields }
Database serves Psiphon API data requests. It's safe for concurrent usage. The Reload function supports hot reloading of Psiphon network data while the server is running.
func NewDatabase ¶
NewDatabase initializes a Database, calling Reload on the specified filename.
func (*Database) DiscoverServers ¶
DiscoverServers selects new encoded server entries to be "discovered" by the client, using the discoveryValue -- a function of the client's IP address -- as the input into the discovery algorithm.
func (*Database) GetHomepages ¶
func (db *Database) GetHomepages( sponsorID, clientRegion, clientASN string, isMobilePlatform bool) []string
GetHomepages returns a list of home pages for the specified sponsor, region, and platform.
func (*Database) GetHttpsRequestRegexes ¶
GetHttpsRequestRegexes returns bytes transferred stats regexes for the specified sponsor.
func (*Database) GetRandomizedHomepages ¶
func (db *Database) GetRandomizedHomepages( sponsorID, clientRegion, clientASN string, isMobilePlatform bool) []string
GetRandomizedHomepages returns a randomly ordered list of home pages for the specified sponsor, region, and platform.
func (*Database) GetUpgradeClientVersion ¶
GetUpgradeClientVersion returns a new client version when an upgrade is indicated for the specified client current version. The result is "" when no upgrade is available. Caller should normalize clientPlatform.
func (*Database) IsValidServerEntryTag ¶
IsValidServerEntryTag checks if the specified server entry tag is valid.