psinet

package
v0.0.13-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2017 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package psiphon/server/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

This section is empty.

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"`
}

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

func NewDatabase(filename string) (*Database, error)

NewDatabase initializes a Database, calling Reload on the specified filename.

func (*Database) DiscoverServers

func (db *Database) DiscoverServers(discoveryValue int) []string

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

func (db *Database) GetHomepages(sponsorID, clientRegion string, isMobilePlatform bool) []string

GetHomepages returns a list of home pages for the specified sponsor, region, and platform.

func (*Database) GetHttpsRequestRegexes

func (db *Database) GetHttpsRequestRegexes(sponsorID string) []map[string]string

GetHttpsRequestRegexes returns bytes transferred stats regexes for the specified sponsor.

func (*Database) GetRandomHomepage

func (db *Database) GetRandomHomepage(sponsorID, clientRegion string, isMobilePlatform bool) []string

GetRandomHomepage returns a random home page from a set of home pages for the specified sponsor, region, and platform.

func (*Database) GetUpgradeClientVersion

func (db *Database) GetUpgradeClientVersion(clientVersion, clientPlatform string) string

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.

type HomePage

type HomePage struct {
	Region string `json:"region"`
	Url    string `json:"url"`
}

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"`
	Region                        string `json:"region"`
}

type HttpsRequestRegex

type HttpsRequestRegex struct {
	Regex   string `json:"regex"`
	Replace string `json:"replace"`
}

type MobileHomePage

type MobileHomePage struct {
	Region string `json:"region"`
	Url    string `json:"url"`
}

type PageViewRegex

type PageViewRegex struct {
	Regex   string `json:"regex"`
	Replace string `json:"replace"`
}

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"`
	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"`
}
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"`
}

Jump to

Keyboard shortcuts

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