Documentation
¶
Index ¶
- Constants
- func Deserialise(filename string, object interface{}) error
- func GetRandBase32(numBytes int) (string, error)
- func InitKraken(cfg *Config, shutdown chan bool, ready chan bool, bCtx *BackendContext)
- func Serialise(filename string, object interface{}) error
- func UnmarshalResources(rawResources []json.RawMessage) ([]core.Resource, error)
- type BackendConfig
- type BackendContext
- type BridgeTest
- type BridgeTestRequest
- type BridgeTestResponse
- type Config
- type Distributors
- type EmailConfig
- type EmailDistConfig
- type GettorDistConfig
- type GettorUpdater
- type Github
- type Gitlab
- type GoogleDriveUpdater
- type HttpsDistConfig
- type Metrics
- type MoatDistConfig
- type ResourceConfig
- type ResourceTestPool
- type S3Updater
- type Set
- type Stringer
- type StubDistConfig
- type TelegramDistConfig
- type TimeDistributionConfig
- type Updaters
- type WebApiConfig
- type WhatsAppConfig
Constants ¶
const ( KrakenTickerInterval = 30 * time.Minute MinTransportWords = 3 MinFunctionalFraction = 0.5 MinRatioFraction = 0.5 TransportPrefix = "transport " ExtraInfoPrefix = "extra-info " RecordEndPrefix = "-----END SIGNATURE-----" )
const ( // FarInTheFuture determines a time span that's far enough in the future to // practically count as infinity. FarInTheFuture = time.Hour * 24 * 365 * 100 // MaxResources determines the maximum number of resources that we're // willing to buffer before sending a request to bridgestrap. MaxResources = 25 )
const (
PrometheusNamespace = "rdsys_backend"
)
Variables ¶
This section is empty.
Functions ¶
func GetRandBase32 ¶
GetRandBase32 takes as input the number of desired bytes and returns a Base32-encoded string consisting of the given number of cryptographically secure random bytes. If anything went wrong, an error is returned.
func InitKraken ¶
func InitKraken(cfg *Config, shutdown chan bool, ready chan bool, bCtx *BackendContext)
Types ¶
type BackendConfig ¶
type BackendConfig struct { ExtrainfoFile string `json:"extrainfo_file"` NetworkstatusFile string `json:"networkstatus_file"` DescriptorsFile string `json:"descriptors_file"` BlocklistFile string `json:"blocklist_file"` AllowlistFile string `json:"allowlist_file"` ApiTokens map[string]string `json:"api_tokens"` ResourcesEndpoint string `json:"api_endpoint_resources"` ResourceStreamEndpoint string `json:"api_endpoint_resource_stream"` TargetsEndpoint string `json:"api_endpoint_targets"` StatusEndpoint string `json:"web_endpoint_status"` MetricsEndpoint string `json:"web_endpoint_metrics"` BridgestrapEndpoint string `json:"bridgestrap_endpoint"` BridgestrapToken string `json:"bridgestrap_token"` OnbascaEndpoint string `json:"onbasca_endpoint"` OnbascaToken string `json:"onbasca_token"` BandwidthRatioThreshold float64 `json:"bandwidth_ratio_threshold"` StorageDir string `json:"storage_dir"` AssignmentsFile string `json:"assignments_file"` // DistProportions contains the proportion of resources that each // distributor should get. E.g. if the HTTPS distributor is set to x and // the moat distributor is set to y, then HTTPS gets x/(x+y) of all // resources and moat gets y/(x+y). DistProportions map[string]int `json:"distribution_proportions"` Resources map[string]ResourceConfig `json:"resources"` WebApi WebApiConfig `json:"web_api"` }
func (BackendConfig) ResourceStreamURL ¶
func (bc BackendConfig) ResourceStreamURL() string
ResourceStreamURL returns the url to connect to the resource stream endpoint
func (BackendConfig) ResourcesURL ¶
func (bc BackendConfig) ResourcesURL() string
ResourceStreamURL returns the url to connect to the resources endpoint
type BackendContext ¶
type BackendContext struct { Config *Config Resources core.BackendResources // contains filtered or unexported fields }
BackendContext contains the state that our backend requires.
func (*BackendContext) InitBackend ¶
func (b *BackendContext) InitBackend(cfg *Config)
InitBackend initialises our backend.
type BridgeTest ¶
type BridgeTest struct { Functional bool `json:"functional"` LastTested *time.Time `json:"last_tested"` Ratio *float64 `json:"ratio"` Error string `json:"error,omitempty"` }
BridgeTest represents the status of a single bridge in bridgestrap's response.
type BridgeTestRequest ¶
type BridgeTestRequest struct {
BridgeLines []string `json:"bridge_lines"`
}
BridgeTestRequest represents requests for bridgestrap and onbasca. Here's what its API look like: https://gitlab.torproject.org/phw/bridgestrap#input
type BridgeTestResponse ¶
type BridgeTestResponse struct { Bridges map[string]*BridgeTest `json:"bridge_results"` Time float64 `json:"time"` Error string `json:"error,omitempty"` }
BridgesTestResponse represents bridgestrap and onbasca's responses.
type Config ¶
type Config struct { Backend BackendConfig `json:"backend"` Distributors Distributors `json:"distributors"` Updaters Updaters `json:"updaters"` // contains filtered or unexported fields }
Config represents our central configuration file.
func LoadConfig ¶
LoadConfig loads the given JSON configuration file and returns the resulting Config configuration object.
func ParseFlags ¶
ParseFlags to load config file and configure the log it returns a Config struct and a close function meant to be called once the program finishes
func (*Config) Set ¶
Set loads the given JSON configuration file rewritting the existing config
type Distributors ¶
type Distributors struct { Https HttpsDistConfig `json:"https"` Email EmailDistConfig `json:"email"` Stub StubDistConfig `json:"stub"` Gettor GettorDistConfig `json:"gettor"` Moat MoatDistConfig `json:"moat"` Telegram TelegramDistConfig `json:"telegram"` Whatsapp WhatsAppConfig `json:"whatsapp"` }
type EmailConfig ¶
type EmailConfig struct { Address string `json:"address"` SmtpServer string `json:"smtp_server"` SmtpUsername string `json:"smtp_username"` SmtpPassword string `json:"smtp_password"` ImapServer string `json:"imap_server"` ImapUsername string `json:"imap_username"` ImapPassword string `json:"imap_password"` }
type EmailDistConfig ¶
type EmailDistConfig struct { Resources []string `json:"resources"` NumBridgesPerRequest int `json:"num_bridges_per_request"` RotationPeriodHours int `json:"rotation_period_hours"` AllowedDomains []string `json:"allowed_domains"` Email EmailConfig `json:"email"` MetricsAddress string `json:"metrics_address"` }
type GettorDistConfig ¶
type GettorDistConfig struct { Resources []string `json:"resources"` Email EmailConfig `json:"email"` MetricsAddress string `json:"metrics_address"` }
type GettorUpdater ¶
type GettorUpdater struct { Github Github `json:"github"` Gitlab Gitlab `json:"gitlab"` S3Updaters []S3Updater `json:"s3"` GoogleDriveUpdater GoogleDriveUpdater `json:"gdrive"` MetricsAddress string `json:"metrics_address"` }
type Github ¶
type Gitlab ¶
type GoogleDriveUpdater ¶
type HttpsDistConfig ¶
type HttpsDistConfig struct { Resources []string `json:"resources"` GeoipDB string `json:"geoipdb"` Geoip6DB string `json:"geoip6db"` WebApi WebApiConfig `json:"web_api"` TimeDistribution TimeDistributionConfig `json:"time_distribution"` TrustProxy bool `json:"trust_proxy"` }
type Metrics ¶
type Metrics struct { DistributingNonFunctional prometheus.Gauge IgnoringBandwidthRatio prometheus.Gauge FlickeringBandwidth *prometheus.CounterVec RatiosSeen prometheus.Histogram Resources *prometheus.GaugeVec DistributorResources *prometheus.GaugeVec Requests *prometheus.CounterVec }
type MoatDistConfig ¶
type MoatDistConfig struct { Resources []string `json:"resources"` GeoipDB string `json:"geoipdb"` Geoip6DB string `json:"geoip6db"` CircumventionMap string `json:"circumvention_map"` CircumventionDefaults string `json:"circumvention_defaults"` BuiltInBridgesURL string `json:"builtin_bridges_url"` ShimTokens map[string]string `json:"shim_tokens"` DummyBridgesFile string `json:"dummy_bridges_file"` TimeDistribution TimeDistributionConfig `json:"time_distribution"` WebApi WebApiConfig `json:"web_api"` TrustProxy bool `json:"trust_proxy"` }
type ResourceConfig ¶
type ResourceTestPool ¶
ResourceTestPool implements a pool to which we add resources until it's time to send them to bridgestrap for testing.
func NewResourceTestPool ¶
func NewResourceTestPool(bridgestrapEndpoint string, bridgestrapToken string, onbascaEndpoint string, onbascaToken string, bandwidthRatioThreshold float64) *ResourceTestPool
NewResourceTestPool returns a new resource test pool.
func (*ResourceTestPool) GetTestFunc ¶
func (p *ResourceTestPool) GetTestFunc() func(r core.Resource)
GetTestFunc returns a function that's executed when a new resource is added to rdsys's backend. The function takes as input a resource and submits it to our testing pool.
func (*ResourceTestPool) Stop ¶
func (p *ResourceTestPool) Stop()
Stop stops the test pool by signalling to the dispatcher that it's time to shut down.
type S3Updater ¶
type S3Updater struct { AccessKey string `json:"access_key"` AccessSecret string `json:"access_secret"` SigningMethod string `json:"signing_method"` EndpointUrl string `json:"endpoint_url"` EndpointRegion string `json:"endpoint_region"` Name string `json:"name"` Bucket string `json:"bucket"` NameProceduralGenerationSeed string `json:"name_procedural_generation_seed"` }
type Set ¶
type Set struct { Set map[interface{}]struct{} // contains filtered or unexported fields }
type StubDistConfig ¶
type StubDistConfig struct { Resources []string `json:"resources"` WebApi WebApiConfig `json:"web_api"` }
type TelegramDistConfig ¶
type TelegramDistConfig struct { Resource string `json:"resource"` NumBridgesPerRequest int `json:"num_bridges_per_request"` RotationPeriodHours int `json:"rotation_period_hours"` Token string `json:"token"` MinUserID int64 `json:"min_user_id"` UpdaterTokens map[string]string `json:"updater_tokens"` StorageDir string `json:"storage_dir"` ApiAddress string `json:"api_address"` LoxServerAddress string `json:"lox_server_address"` }
type TimeDistributionConfig ¶
type Updaters ¶
type Updaters struct {
Gettor GettorUpdater `json:"gettor"`
}