xdsserver

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2018 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSDKInfo

func GetSDKInfo(scriptDir, url, filename, md5sum string, log *logrus.Logger) (xsapiv1.SDK, error)

GetSDKInfo Used get-sdk-info script to extract SDK get info from a SDK file/tarball

func ListCrossSDK

func ListCrossSDK(scriptDir string, update bool, log *logrus.Logger) ([]xsapiv1.SDK, error)

ListCrossSDK List all available and installed SDK (call "db-dump" script)

func UpdateSDKDb added in v1.1.0

func UpdateSDKDb(scriptDir string, log *logrus.Logger) (string, error)

UpdateSDKDb Used db-update script to update SDK database

Types

type APIService

type APIService struct {
	*Context
	// contains filtered or unexported fields
}

APIService .

func NewAPIV1

func NewAPIV1(ctx *Context) *APIService

NewAPIV1 creates a new instance of API service

type ClientSession

type ClientSession struct {
	ID       string
	WSID     string // only one WebSocket per client/session
	MaxAge   int64
	IOSocket *socketio.Socket
	// contains filtered or unexported fields
}

ClientSession contains the info of a user/client session

type Context

type Context struct {
	ProgName      string
	Cli           *cli.Context
	Config        *xdsconfig.Config
	Log           *logrus.Logger
	LogLevelSilly bool
	LogSillyf     func(format string, args ...interface{})
	SThg          *st.SyncThing
	SThgCmd       *exec.Cmd
	SThgInotCmd   *exec.Cmd

	WWWServer *WebServer

	Exit chan os.Signal
	// contains filtered or unexported fields
}

Context holds the XDS server context

func NewXdsServer

func NewXdsServer(cliCtx *cli.Context) *Context

NewXdsServer Create a new instance of XDS server

func (*Context) Run

func (ctx *Context) Run() (int, error)

Run Main function called to run XDS Server

type CrossSDK

type CrossSDK struct {
	*Context
	// contains filtered or unexported fields
}

CrossSDK Hold SDK config

func NewCrossSDK

func NewCrossSDK(ctx *Context, sdk xsapiv1.SDK, scriptDir string) (*CrossSDK, error)

NewCrossSDK creates a new instance of CrossSDK

func (*CrossSDK) AbortInstallRemove

func (s *CrossSDK) AbortInstallRemove(timeout int) error

AbortInstallRemove abort an install or remove command

func (*CrossSDK) Get

func (s *CrossSDK) Get() *xsapiv1.SDK

Get Return SDK definition

func (*CrossSDK) GetEnvCmd

func (s *CrossSDK) GetEnvCmd() []string

GetEnvCmd returns the command used to initialized the environment

func (*CrossSDK) Install

func (s *CrossSDK) Install(file string, force bool, timeout int, args []string, sess *ClientSession) error

Install a SDK (non blocking command, IOW run in background)

func (*CrossSDK) Remove

func (s *CrossSDK) Remove(timeout int, sess *ClientSession) error

Remove Used to remove/uninstall a SDK

type EventDef

type EventDef struct {
	// contains filtered or unexported fields
}

EventDef Definition on one event

type Events

type Events struct {
	*Context
	// contains filtered or unexported fields
}

Events Hold registered events per context

func EventsConstructor added in v1.1.0

func EventsConstructor(ctx *Context) *Events

EventsConstructor creates an instance of Events

func (*Events) Emit

func (e *Events) Emit(evName string, data interface{}, fromSessID string) error

Emit Used to manually emit an event

func (*Events) GetList

func (e *Events) GetList() []string

GetList returns the list of all supported events

func (*Events) Register

func (e *Events) Register(evName, sessionID string) error

Register Used by a client/session to register to a specific (or all) event(s)

func (*Events) UnRegister

func (e *Events) UnRegister(evName, sessionID string) error

UnRegister Used by a client/session to un-register event(s)

type FolderEventCB

type FolderEventCB func(cfg *xsapiv1.FolderConfig, data *FolderEventCBData)

FolderEventCB Callback prototype for FolderEvent events

type FolderEventCBData

type FolderEventCBData map[string]interface{}

FolderEventCBData Data format of FolderEvent events

type Folders

type Folders struct {
	*Context
	// contains filtered or unexported fields
}

Folders Represent a an XDS folders

func FoldersConstructor added in v1.1.0

func FoldersConstructor(ctx *Context) *Folders

FoldersConstructor Create a new instance of Model Folders

func (*Folders) Add

Add adds a new folder

func (*Folders) Delete

func (f *Folders) Delete(id string) (xsapiv1.FolderConfig, error)

Delete deletes a specific folder

func (*Folders) ForceSync

func (f *Folders) ForceSync(id string) error

ForceSync Force the synchronization of a folder

func (*Folders) Get

func (f *Folders) Get(id string) *IFOLDER

Get returns the folder config or nil if not existing

func (*Folders) GetConfigArr

func (f *Folders) GetConfigArr() []xsapiv1.FolderConfig

GetConfigArr returns the config of all folders as an array

func (*Folders) IsFolderInSync

func (f *Folders) IsFolderInSync(id string) (bool, error)

IsFolderInSync Returns true when folder is in sync

func (*Folders) LoadConfig

func (f *Folders) LoadConfig() error

LoadConfig Load folders configuration from disk

func (*Folders) ResolveID

func (f *Folders) ResolveID(id string) (string, error)

ResolveID Complete a Folder ID (helper for user that can use partial ID value)

func (*Folders) SaveConfig

func (f *Folders) SaveConfig() error

SaveConfig Save folders configuration to disk

func (*Folders) Update

func (f *Folders) Update(id string, cfg xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error)

Update Update a specific folder

type IFOLDER

type IFOLDER interface {
	NewUID(suffix string) string                                    // Get a new folder UUID
	Add(cfg xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error)    // Add a new folder
	Setup(prj xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error)  // Local setup of the folder
	GetConfig() xsapiv1.FolderConfig                                // Get folder public configuration
	GetFullPath(dir string) string                                  // Get folder full path
	ConvPathCli2Svr(s string) string                                // Convert path from Client to Server
	ConvPathSvr2Cli(s string) string                                // Convert path from Server to Client
	Remove() error                                                  // Remove a folder
	Update(cfg xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error) // Update a new folder
	Sync() error                                                    // Force folder files synchronization
	IsInSync() (bool, error)                                        // Check if folder files are in-sync
}

IFOLDER Folder interface

type ITARGET added in v1.1.0

type ITARGET interface {
	NewUID(suffix string) string                                                     // Get a new target UUID
	Add(cfg xsapiv1.TargetConfig, terms *Terminals) (*xsapiv1.TargetConfig, error)   // Add a new target
	Delete() error                                                                   // Remove a target
	Setup(prj xsapiv1.TargetConfig, terms *Terminals) (*xsapiv1.TargetConfig, error) // Local setup of the folder
	GetConfig() xsapiv1.TargetConfig                                                 // Get target public configuration
}

ITARGET Target interface

type ITERMINAL added in v1.1.0

type ITERMINAL interface {
	GetConfig() xsapiv1.TerminalConfig                                          // Get terminal public configuration
	UpdateConfig(cfg xsapiv1.TerminalConfig) *xsapiv1.TerminalConfig            // Update terminal config
	Open(sock *socketio.Socket, sessID string) (*xsapiv1.TerminalConfig, error) // Open a terminal session
	Close() (*xsapiv1.TerminalConfig, error)                                    // Close a terminal session
	Resize(cols, rows uint16) (*xsapiv1.TerminalConfig, error)                  // Resize a terminal session
	Signal(sigName string) error                                                // Send a signal to a terminal session
}

ITERMINAL Terminal interface

type PathMap

type PathMap struct {
	*Context
	// contains filtered or unexported fields
}

PathMap .

func NewFolderPathMap

func NewFolderPathMap(ctx *Context) *PathMap

NewFolderPathMap Create a new instance of PathMap

func (*PathMap) Add

Add a new folder

func (*PathMap) ConvPathCli2Svr

func (f *PathMap) ConvPathCli2Svr(s string) string

ConvPathCli2Svr Convert path from Client to Server

func (*PathMap) ConvPathSvr2Cli

func (f *PathMap) ConvPathSvr2Cli(s string) string

ConvPathSvr2Cli Convert path from Server to Client

func (*PathMap) GetConfig

func (f *PathMap) GetConfig() xsapiv1.FolderConfig

GetConfig Get public part of folder config

func (*PathMap) GetFullPath

func (f *PathMap) GetFullPath(dir string) string

GetFullPath returns the full path of a directory (from server POV)

func (*PathMap) IsInSync

func (f *PathMap) IsInSync() (bool, error)

IsInSync Check if folder files are in-sync

func (*PathMap) NewUID

func (f *PathMap) NewUID(suffix string) string

NewUID Get a UUID

func (*PathMap) Remove

func (f *PathMap) Remove() error

Remove a folder

func (*PathMap) Setup

Setup Setup local project config

func (*PathMap) Sync

func (f *PathMap) Sync() error

Sync Force folder files synchronization

func (*PathMap) Update

Update update some fields of a folder

type RegisteredCB

type RegisteredCB struct {
	// contains filtered or unexported fields
}

RegisteredCB Hold registered callbacks

type SDKs

type SDKs struct {
	*Context
	Sdks         map[string]*CrossSDK
	SdksFamilies map[string]*xsapiv1.SDKFamilyConfig
	// contains filtered or unexported fields
}

SDKs List of installed SDK

func SDKsConstructor added in v1.1.0

func SDKsConstructor(ctx *Context) (*SDKs, error)

SDKsConstructor creates a new instance of SDKs

func (*SDKs) AbortInstall

func (s *SDKs) AbortInstall(id string, timeout int) (*xsapiv1.SDK, error)

AbortInstall Used to abort SDK installation

func (*SDKs) Get

func (s *SDKs) Get(id string) *xsapiv1.SDK

Get returns an SDK from id

func (*SDKs) GetAll

func (s *SDKs) GetAll() []xsapiv1.SDK

GetAll returns all existing SDKs

func (*SDKs) GetByPath

func (s *SDKs) GetByPath(path string) (*xsapiv1.SDK, error)

GetByPath Find a SDK from path

func (*SDKs) GetEnvCmd

func (s *SDKs) GetEnvCmd(id string, defaultID string) []string

GetEnvCmd returns the command used to initialized the environment for an SDK

func (*SDKs) Install

func (s *SDKs) Install(id, filepath string, force bool, timeout int, args []string, sess *ClientSession) (*xsapiv1.SDK, error)

Install Used to install a new SDK

func (*SDKs) Remove

func (s *SDKs) Remove(id string, timeout int, sess *ClientSession) (*xsapiv1.SDK, error)

Remove Used to uninstall a SDK

func (*SDKs) ResolveID

func (s *SDKs) ResolveID(id string) (string, error)

ResolveID Complete an SDK ID (helper for user that can use partial ID value)

func (*SDKs) Stop

func (s *SDKs) Stop()

Stop SDKs management

type STFolder

type STFolder struct {
	*Context
	// contains filtered or unexported fields
}

STFolder .

func NewFolderST

func NewFolderST(ctx *Context, sthg *st.SyncThing) *STFolder

NewFolderST Create a new instance of STFolder

func (*STFolder) Add

Add a new folder

func (*STFolder) ConvPathCli2Svr

func (f *STFolder) ConvPathCli2Svr(s string) string

ConvPathCli2Svr Convert path from Client to Server

func (*STFolder) ConvPathSvr2Cli

func (f *STFolder) ConvPathSvr2Cli(s string) string

ConvPathSvr2Cli Convert path from Server to Client

func (*STFolder) GetConfig

func (f *STFolder) GetConfig() xsapiv1.FolderConfig

GetConfig Get public part of folder config

func (*STFolder) GetFullPath

func (f *STFolder) GetFullPath(dir string) string

GetFullPath returns the full path of a directory (from server POV)

func (*STFolder) IsInSync

func (f *STFolder) IsInSync() (bool, error)

IsInSync Check if folder files are in-sync

func (*STFolder) NewUID

func (f *STFolder) NewUID(suffix string) string

NewUID Get a UUID

func (*STFolder) Remove

func (f *STFolder) Remove() error

Remove a folder

func (*STFolder) Setup

Setup Setup local project config

func (*STFolder) Sync

func (f *STFolder) Sync() error

Sync Force folder files synchronization

func (*STFolder) Update

Update update some fields of a folder

type STFolderDisable

type STFolderDisable struct {
	*Context
	// contains filtered or unexported fields
}

STFolderDisable .

func NewFolderSTDisable

func NewFolderSTDisable(ctx *Context) *STFolderDisable

NewFolderSTDisable Create a new instance of STFolderDisable

func (*STFolderDisable) Add

Add a new folder

func (*STFolderDisable) ConvPathCli2Svr

func (f *STFolderDisable) ConvPathCli2Svr(s string) string

ConvPathCli2Svr Convert path from Client to Server

func (*STFolderDisable) ConvPathSvr2Cli

func (f *STFolderDisable) ConvPathSvr2Cli(s string) string

ConvPathSvr2Cli Convert path from Server to Client

func (*STFolderDisable) GetConfig

func (f *STFolderDisable) GetConfig() xsapiv1.FolderConfig

GetConfig Get public part of folder config

func (*STFolderDisable) GetFullPath

func (f *STFolderDisable) GetFullPath(dir string) string

GetFullPath returns the full path of a directory (from server POV)

func (*STFolderDisable) IsInSync

func (f *STFolderDisable) IsInSync() (bool, error)

IsInSync Check if folder files are in-sync

func (*STFolderDisable) NewUID

func (f *STFolderDisable) NewUID(suffix string) string

NewUID Get a UUID

func (*STFolderDisable) Remove

func (f *STFolderDisable) Remove() error

Remove a folder

func (*STFolderDisable) Setup

Setup Setup local project config

func (*STFolderDisable) Sync

func (f *STFolderDisable) Sync() error

Sync Force folder files synchronization

func (*STFolderDisable) Update

Update update some fields of a folder

type Sessions

type Sessions struct {
	*Context
	// contains filtered or unexported fields
}

Sessions holds client sessions

func ClientSessionsConstructor added in v1.1.0

func ClientSessionsConstructor(ctx *Context, cookieMaxAge string) *Sessions

ClientSessionsConstructor .

func (*Sessions) Get

func (s *Sessions) Get(c *gin.Context) *ClientSession

Get returns the client session for a specific ID

func (*Sessions) IOSocketGet

func (s *Sessions) IOSocketGet(sid string) *socketio.Socket

IOSocketGet Get socketio definition from sid

func (*Sessions) Middleware

func (s *Sessions) Middleware() gin.HandlerFunc

Middleware is used to managed session

func (*Sessions) Stop

func (s *Sessions) Stop()

Stop sessions management

func (*Sessions) UpdateIOSocket

func (s *Sessions) UpdateIOSocket(sid string, so *socketio.Socket) error

UpdateIOSocket updates the IO Socket definition for of a session

type Targets added in v1.1.0

type Targets struct {
	*Context
	// contains filtered or unexported fields
}

Targets Represent a XDS targets

func TargetsConstructor added in v1.1.0

func TargetsConstructor(ctx *Context) *Targets

TargetsConstructor Create a new instance of Model Target

func (*Targets) Add added in v1.1.0

Add adds a new target

func (*Targets) CloseTerminal added in v1.1.0

func (t *Targets) CloseTerminal(targetID, termID string, sess *ClientSession) (*xsapiv1.TerminalConfig, error)

CloseTerminal Close a target terminal

func (*Targets) CreateUpdateTerminal added in v1.1.0

func (t *Targets) CreateUpdateTerminal(targetID string, tmCfg xsapiv1.TerminalConfig, initial bool) (*xsapiv1.TerminalConfig, error)

CreateUpdateTerminal Create or Update a target terminal definition

func (*Targets) Delete added in v1.1.0

func (t *Targets) Delete(id string, sess *ClientSession) (xsapiv1.TargetConfig, error)

Delete deletes a specific target

func (*Targets) DeleteTerminal added in v1.1.0

func (t *Targets) DeleteTerminal(targetID, termID string) (*xsapiv1.TerminalConfig, error)

DeleteTerminal Delete a target terminal definition

func (*Targets) Get added in v1.1.0

func (t *Targets) Get(id string) *ITARGET

Get returns the target config or nil if not existing

func (*Targets) GetConfigArr added in v1.1.0

func (t *Targets) GetConfigArr() []xsapiv1.TargetConfig

GetConfigArr returns the config of all targets as an array

func (*Targets) GetTerminal added in v1.1.0

func (t *Targets) GetTerminal(targetID, termID string) (*ITERMINAL, error)

GetTerminal Return info of a specific terminal

func (*Targets) GetTerminalsArr added in v1.1.0

func (t *Targets) GetTerminalsArr(targetID string) ([]xsapiv1.TerminalConfig, error)

GetTerminalsArr Return list of existing terminals

func (*Targets) LoadConfig added in v1.1.0

func (t *Targets) LoadConfig() error

LoadConfig Load targets configuration from disk

func (*Targets) OpenTerminal added in v1.1.0

func (t *Targets) OpenTerminal(targetID, termID string, sess *ClientSession) (*xsapiv1.TerminalConfig, error)

OpenTerminal Open a target terminal

func (*Targets) ResizeTerminal added in v1.1.0

func (t *Targets) ResizeTerminal(targetID, termID string, cols, rows uint16, sess *ClientSession) (*xsapiv1.TerminalConfig, error)

ResizeTerminal Set size (row+col) of a target terminal

func (*Targets) ResolveID added in v1.1.0

func (t *Targets) ResolveID(id string) (string, error)

ResolveID Complete a Target ID (helper for user that can use partial ID value)

func (*Targets) ResolveTerminalID added in v1.1.0

func (t *Targets) ResolveTerminalID(termID string) (string, error)

ResolveTerminalID Complete a Terminal ID (helper for user that can use partial ID value)

func (*Targets) SaveConfig added in v1.1.0

func (t *Targets) SaveConfig() error

SaveConfig Save targets configuration to disk

func (*Targets) SignalTerminal added in v1.1.0

func (t *Targets) SignalTerminal(targetID, termID, sigNum string) error

SignalTerminal Send a signal to a target terminal

type TermSSH added in v1.1.0

type TermSSH struct {
	*Context
	// contains filtered or unexported fields
}

TermSSH .

func NewTermSSH added in v1.1.0

func NewTermSSH(ctx *Context, cfg xsapiv1.TerminalConfig, targetID string) *TermSSH

NewTermSSH Create a new instance of TermSSH

func (*TermSSH) Close added in v1.1.0

func (t *TermSSH) Close() (*xsapiv1.TerminalConfig, error)

Close a terminal

func (*TermSSH) GetConfig added in v1.1.0

func (t *TermSSH) GetConfig() xsapiv1.TerminalConfig

GetConfig Get public part of terminal config

func (*TermSSH) Open added in v1.1.0

func (t *TermSSH) Open(sock *socketio.Socket, sessID string) (*xsapiv1.TerminalConfig, error)

Open a new terminal - execute ssh command and bind stdin/stdout to WebSocket

func (*TermSSH) Resize added in v1.1.0

func (t *TermSSH) Resize(cols, rows uint16) (*xsapiv1.TerminalConfig, error)

Resize a terminal

func (*TermSSH) Signal added in v1.1.0

func (t *TermSSH) Signal(sigName string) error

Signal Send a signal to a terminal

func (*TermSSH) UpdateConfig added in v1.1.0

func (t *TermSSH) UpdateConfig(newCfg xsapiv1.TerminalConfig) *xsapiv1.TerminalConfig

UpdateConfig Update terminal config

type Terminals added in v1.1.0

type Terminals struct {
	*Context
	// contains filtered or unexported fields
}

Terminals Represent a XDS terminals

func TerminalsConstructor added in v1.1.0

func TerminalsConstructor(ctx *Context) *Terminals

TerminalsConstructor Create a new instance of Model Terminal

func (*Terminals) Close added in v1.1.0

func (t *Terminals) Close(id string, sess *ClientSession) (*xsapiv1.TerminalConfig, error)

Close a specific terminal

func (*Terminals) Free added in v1.1.0

func (t *Terminals) Free(id string) (*xsapiv1.TerminalConfig, error)

Free a specific terminal

func (*Terminals) Get added in v1.1.0

func (t *Terminals) Get(id string) *ITERMINAL

Get returns the terminal config or nil if not existing

func (*Terminals) GetConfigArr added in v1.1.0

func (t *Terminals) GetConfigArr() []xsapiv1.TerminalConfig

GetConfigArr returns the config of all terminals as an array

func (*Terminals) New added in v1.1.0

New Create a new terminal

func (*Terminals) Open added in v1.1.0

func (t *Terminals) Open(id string, sess *ClientSession) (*xsapiv1.TerminalConfig, error)

Open adds a new terminal

func (*Terminals) Resize added in v1.1.0

func (t *Terminals) Resize(id string, cols, rows uint16, sess *ClientSession) (*xsapiv1.TerminalConfig, error)

Resize a specific terminal

func (*Terminals) Signal added in v1.1.0

func (t *Terminals) Signal(id, sigName string) error

Signal Send a Signal a specific terminal

type TgtStd added in v1.1.0

type TgtStd struct {
	*Context
	TgtConfig xsapiv1.TargetConfig
	// contains filtered or unexported fields
}

TgtStd .

func NewTargetStandard added in v1.1.0

func NewTargetStandard(ctx *Context) *TgtStd

NewTargetStandard Create a new instance of TgtStd

func (*TgtStd) Add added in v1.1.0

func (t *TgtStd) Add(cfg xsapiv1.TargetConfig, terms *Terminals) (*xsapiv1.TargetConfig, error)

Add a new target

func (*TgtStd) Delete added in v1.1.0

func (t *TgtStd) Delete() error

Delete a target

func (*TgtStd) GetConfig added in v1.1.0

func (t *TgtStd) GetConfig() xsapiv1.TargetConfig

GetConfig Get public part of target config

func (*TgtStd) NewUID added in v1.1.0

func (t *TgtStd) NewUID(suffix string) string

NewUID Get a UUID

func (*TgtStd) Setup added in v1.1.0

func (t *TgtStd) Setup(cfg xsapiv1.TargetConfig, terms *Terminals) (*xsapiv1.TargetConfig, error)

Setup Setup local project config

type WebServer

type WebServer struct {
	*Context
	// contains filtered or unexported fields
}

WebServer .

func WebServerConstructor added in v1.1.0

func WebServerConstructor(ctx *Context) *WebServer

WebServerConstructor creates an instance of WebServer

func (*WebServer) Serve

func (s *WebServer) Serve() error

Serve starts a new instance of the Web Server

func (*WebServer) Stop

func (s *WebServer) Stop()

Stop web server

Jump to

Keyboard shortcuts

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