alkasir: Index | Files | Directories

package client

import ""

Alkasir client

the client package contains alkasir-client specific code like its main entrypoint.


Package Files

api.go client.go client_unix.go clientversion.go doc.go http.go i18n.go misc.go static.go uitest.go updatechecker.go updateresult_string.go upgradebin.go upgradeblocklist.go util.go


const ClientAPIVersion = 2

ClientAPIVersion is used to verify that the browser/extension and client can speak to eachother.

const UITEST = false


var (
    // LanguageOptions = []string{"en", "ar", "zh", "sv", "fa"}
    LanguageOptions = []string{"en", "ar", "fa"}
var VERSION string

VERSION represents the client version number, it's set by the build system.

func AddRoutes Uses

func AddRoutes(mux *http.ServeMux) error

adds api routes to given mix router

func Atexit Uses

func Atexit(f func())

Atexit adds a func to be run when the application is exiting.

func AtexitKillCmd Uses

func AtexitKillCmd(cmd *exec.Cmd)

AtexitKillCmd takes care of killing a command on application exit.

TODO: currently this does not clean up references to dead processes, it just adds forever.

func ConfigPath Uses

func ConfigPath(file ...string) string

ConfigPath - TODO: deprecate or something...

func CreateSuggestion Uses

func CreateSuggestion(w rest.ResponseWriter, r *rest.Request)

CreateSuggestion .

func DeleteConnection Uses

func DeleteConnection(w rest.ResponseWriter, r *rest.Request)

func GetAllHostPatterns Uses

func GetAllHostPatterns(w rest.ResponseWriter, r *rest.Request)

Fetch and list all host patterns

func GetAllMethods Uses

func GetAllMethods(w rest.ResponseWriter, r *rest.Request)

api integration

func GetAllServices Uses

func GetAllServices(w rest.ResponseWriter, r *rest.Request)

JSON api function

func GetConnections Uses

func GetConnections(w rest.ResponseWriter, r *rest.Request)

func GetDebug Uses

func GetDebug(w rest.ResponseWriter, r *rest.Request)

func GetNotifications Uses

func GetNotifications(w rest.ResponseWriter, r *rest.Request)

func GetNotificationsUITest Uses

func GetNotificationsUITest(w rest.ResponseWriter, r *rest.Request)

GetNotifications writes all current notifications.

func GetPAC Uses

func GetPAC(w rest.ResponseWriter, r *rest.Request)

func GetStatusSummary Uses

func GetStatusSummary(w rest.ResponseWriter, r *rest.Request)

JSON api function

func GetSuggestion Uses

func GetSuggestion(w rest.ResponseWriter, r *rest.Request)

func GetSuggestions Uses

func GetSuggestions(w rest.ResponseWriter, r *rest.Request)

GetSuggestions returns all local/remote suggestion sessions, can be filtered by time of creation.

func GetTransportTraffic Uses

func GetTransportTraffic(w rest.ResponseWriter, r *rest.Request)

GetTransportTraffic returns all current traffic entries and empties the queue

func GetUserSettings Uses

func GetUserSettings(w rest.ResponseWriter, r *rest.Request)

func GetVersion Uses

func GetVersion(w rest.ResponseWriter, r *rest.Request)

GetVersion returns the alkasir-client version.

func HtmlHandler Uses

func HtmlHandler(w http.ResponseWriter, r *http.Request)

HtmlHandler is a HandlerFunc that serves all pages in the internal browser using a single html template.

func NewRestClient Uses

func NewRestClient() (*client.Client, error)

NewRestClient returns an central server client using the current default transport if the central server is not runing locally.

func PostBrowsercodeToClipboard Uses

func PostBrowsercodeToClipboard(w rest.ResponseWriter, r *rest.Request)

func PostConnection Uses

func PostConnection(w rest.ResponseWriter, r *rest.Request)

func PostExportChromeExtension Uses

func PostExportChromeExtension(w rest.ResponseWriter, r *rest.Request)

func PostLog Uses

func PostLog(w rest.ResponseWriter, r *rest.Request)


func PostTransportTraffic Uses

func PostTransportTraffic(w rest.ResponseWriter, r *rest.Request)

func PostUserSettings Uses

func PostUserSettings(w rest.ResponseWriter, r *rest.Request)

func Run Uses

func Run()

Init does precondition check if the application can/should be started. Init will return an error message with reason for exit printed.

func SetUpgradeArtifact Uses

func SetUpgradeArtifact(name string)

func StartBinaryUpgradeChecker Uses

func StartBinaryUpgradeChecker(diffsBaseURL string)

StartBinaryUpgradeChecker checks for binary upgrades when the connection is up and on a schedule.

This function runs in it's own goroutine.

func StartBlocklistUpgrader Uses

func StartBlocklistUpgrader()

StartBlocklistUpgrader react to certain conitions for when the list of blocked urls should be updated.

This function runs in it's own goroutine.

func SubmitSuggestion Uses

func SubmitSuggestion(w rest.ResponseWriter, r *rest.Request)

SubmitSuggestion initiates the comminication with Central for a Submission session.

func TestMethod Uses

func TestMethod(w rest.ResponseWriter, r *rest.Request)

TestMethod tests a transport method

func ToggleConnection Uses

func ToggleConnection(w rest.ResponseWriter, r *rest.Request)

func ValidLanguage Uses

func ValidLanguage(lang string) bool

func ValidateConnectionString Uses

func ValidateConnectionString(w rest.ResponseWriter, r *rest.Request)

type Auth Uses

type Auth struct {
    Key string
    // contains filtered or unexported fields

Auth .

func (Auth) ServeHTTP Uses

func (a Auth) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ConnectionSetting Uses

type ConnectionSetting struct {
    ID        string `json:"id"`      // runtime only connection ID.
    Name      string `json:"name"`    // display name  generated from hash of connection string.
    Encoded   string `json:"encoded"` // only sent from client to browser, never the other way around.
    Disabled  bool   `json:"disabled"`
    Protected bool   `json:"protected"` // if true, the user cannot delete or modify this connection.

ConnectionSetting .

type HostPatternListItem Uses

type HostPatternListItem struct {
    Pattern    string   // The url pattern itself
    Categories []string // Which lists this pattern belongs to (blocked/direct/...)


type Link struct {
    ID   string // The Id of whatever is being linked
    Name string // Usually the name of the linked object, might also be some kind of title.

A link to another entity.

type MethodListItem Uses

type MethodListItem struct {
    ID       string
    Service  Link
    Name     string
    Protocol string
    BindAddr string
    Running  bool

type MethodTestResult Uses

type MethodTestResult struct {
    MethodID string
    // TestURL  string
    Ok      bool
    Message string

Response from a transport connection test

type Notification Uses

type Notification struct {
    ID          string               `json:"id"`        // UUID
    EventTime   time.Time            `json:"eventTime"` // A timestamp associated with the notification
    Level       string               `json:"level"`     // info,success,danger,warning: for styling
    Priority    int                  `json:"priority"`  // Priority ranges from -2 to 2. -2 is lowest priority. 2 is highest. Zero is default.
    Title       string               `json:"title"`     // header
    Message     string               `json:"message"`   // body
    Actions     []NotificationAction `json:"actions"`
    Dismissable bool                 `json:"dismissable"` // can the user dismiss this

Notification represents a user notifcation event which also can have some interactivity configured.

type NotificationAction Uses

type NotificationAction struct {
    Name  string `json:"name"`
    Route string `json:"route"`

type PostLogRequest Uses

type PostLogRequest struct {
    Level   lg.Level `json:"level"`
    Context string   `json:"context"`
    Message string   `json:"message"`

type ServiceListItem Uses

type ServiceListItem struct {
    ID      string
    Name    string
    Running bool
    Methods []Link

type StatusSummary Uses

type StatusSummary struct {
    TransportOk         bool      `json:"transportOk"`         // true if there are no problems with transports
    BrowserOk           bool      `json:"browserOk"`           // true if the browser extension is connected
    CentralOk           bool      `json:"centralOk"`           // true if the communication with the central server is good
    CountryCode         string    `json:"countryCode"`         // The currently active country code
    LastBlocklistCheck  time.Time `json:"lastBlocklistCheck"`  // Time blocklist was last checked for
    LastBlocklistChange time.Time `json:"lastBlocklistChange"` // Time blocklist was last updated
    AlkasirVersion      string    `json:"alkasirVersion"`      // Current alkasir version (TODO remove? version ping is also available)

StatusSummary is a composite type of various alkasir client

type UpdateChecker Uses

type UpdateChecker struct {
    Interval        time.Duration      // Duration between automatic checks
    LastCheck       time.Time          // The last time update was checked
    LastFailedCheck time.Time          // The last time an update check failed (cleared on succesful update)
    LastUpdate      time.Time          // The last time an update was successful
    RequestC        chan UpdateRequest `json:"-"` // Channel that updatechecker clients receives requests on
    // contains filtered or unexported fields

UpdateChecker manages triggering UpdateRequests on a channel on intervals orand then handling of UpdateRepsonses

func NewUpdateChecker Uses

func NewUpdateChecker(name string) (*UpdateChecker, error)

NewUpdateChecker creates and returns an UpdateChecker instance. The caller should then listen on the RequestC channel for UpdateRequests.

func (*UpdateChecker) Activate Uses

func (u *UpdateChecker) Activate()

Activate starts or resumes the triggering of update requests

func (*UpdateChecker) Deactivate Uses

func (u *UpdateChecker) Deactivate()

Deactivate pauses triggering of update reuquests

func (*UpdateChecker) UpdateNow Uses

func (u *UpdateChecker) UpdateNow() error

UpdateNow forces an Update request to be triggered if the

type UpdateRequest Uses

type UpdateRequest struct {
    ResponseC chan UpdateResult // The client is required to send an UpdateResult back on this channel to
    // contains filtered or unexported fields

UpdateRequest is sent to the client of an UpdateChecker on a channel.

type UpdateResult Uses

type UpdateResult int

UpdateResult is sent by the client of an UpdateChecker on the UpdateRequest's Repsonse channel to indicate wehter the Update was successful or failed.

const (
    UpdateError UpdateResult = iota

These are the UpdateResult constants

func (UpdateResult) String Uses

func (i UpdateResult) String() string

type UserSettings Uses

type UserSettings struct {
    Language            string   `json:"language"`
    LanguageOptions     []string `json:"languageOptions"`
    CountryCode         string   `json:"countryCode"`
    ClientAutoUpdate    bool     `json:"clientAutoUpdate"`
    BlocklistAutoUpdate bool     `json:"blocklistAutoUpdate"`

type ValidateConnectionStringRequest Uses

type ValidateConnectionStringRequest struct {
    ConnectionString string `json:"connectionString"`

type ValidateConnectionStringResponse Uses

type ValidateConnectionStringResponse struct {
    Ok   bool   `json:"ok"`
    Name string `json:"name"`


internal/configConfiguration file access
uiapi for ui module(s)
ui/wmGUI package, requires cgo/platform specific stuff.

Package client imports 52 packages (graph) and is imported by 2 packages. Updated 2016-09-22. Refresh now. Tools for package owners.