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 string, isMobilePlatform bool) []string
- func (db *Database) GetHttpsRequestRegexes(sponsorID string) []map[string]string
- func (db *Database) GetRandomizedHomepages(sponsorID, clientRegion string, isMobilePlatform bool) []string
- func (db *Database) GetUpgradeClientVersion(clientVersion, clientPlatform string) string
- func (db *Database) IsValidServerEntryTag(serverEntryTag string) bool
- type HomePage
- type Host
- type HttpsRequestRegex
- type MobileHomePage
- type PageViewRegex
- type Server
- 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 Hosts map[string]Host `json:"hosts"` Servers []Server `json:"servers"` 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"` // 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. The server list (db.Servers) loaded from JSON is stored as an array instead of a map to ensure servers are discovered deterministically. Each iteration over a map in go is seeded with a random value which causes non-deterministic ordering.
func (*Database) GetHomepages ¶
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 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.
type Host ¶
type Host struct { DatacenterName string `json:"datacenter_name"` Id string `json:"id"` IpAddress string `json:"ip_address"` IsTCS bool `json:"is_TCS"` MeekCookieEncryptionPublicKey string `json:"meek_cookie_encryption_public_key"` MeekServerObfuscatedKey string `json:"meek_server_obfuscated_key"` MeekServerPort int `json:"meek_server_port"` TacticsRequestPublicKey string `json:"tactics_request_public_key"` TacticsRequestObfuscatedKey string `json:"tactics_request_obfuscated_key"` Region string `json:"region"` }
type HttpsRequestRegex ¶
type MobileHomePage ¶
type PageViewRegex ¶
type Server ¶
type Server struct { AlternateSshObfuscatedPorts []string `json:"alternate_ssh_obfuscated_ports"` Capabilities map[string]bool `json:"capabilities"` DiscoveryDateRange []string `json:"discovery_date_range"` EgressIpAddress string `json:"egress_ip_address"` HostId string `json:"host_id"` Id string `json:"id"` InternalIpAddress string `json:"internal_ip_address"` IpAddress string `json:"ip_address"` IsEmbedded bool `json:"is_embedded"` IsPermanent bool `json:"is_permanent"` PropogationChannelId string `json:"propagation_channel_id"` SshHostKey string `json:"ssh_host_key"` SshObfuscatedKey string `json:"ssh_obfuscated_key"` SshObfuscatedPort int `json:"ssh_obfuscated_port"` SshObfuscatedQUICPort int `json:"ssh_obfuscated_quic_port"` SshObfuscatedTapdancePort int `json:"ssh_obfuscated_tapdance_port"` SshPassword string `json:"ssh_password"` SshPort string `json:"ssh_port"` SshUsername string `json:"ssh_username"` WebServerCertificate string `json:"web_server_certificate"` WebServerPort string `json:"web_server_port"` WebServerSecret string `json:"web_server_secret"` ConfigurationVersion int `json:"configuration_version"` }
type Sponsor ¶
type Sponsor struct { Banner string HomePages map[string][]HomePage `json:"home_pages"` HttpsRequestRegexes []HttpsRequestRegex `json:"https_request_regexes"` Id string `json:"id"` MobileHomePages map[string][]HomePage `json:"mobile_home_pages"` Name string `json:"name"` PageViewRegexes []PageViewRegex `json:"page_view_regexes"` WebsiteBanner string `json:"website_banner"` WebsiteBannerLink string `json:"website_banner_link"` }