Documentation ¶
Index ¶
- Variables
- func CompileJSONResult(result bool, message string, otherData ...map[string]interface{}) map[string]interface{}
- func ConnectSSH(host, username, pass, port string) (string, error)
- func DownloadDirectory(sourcePath, localPath, fileName string, session *ssh.Session) (string, error)
- func DownloadFile(localPath, fileName, fileNamePost string, session *ssh.Session) (string, error)
- func FormatBytes(size float64) string
- func GeneratePinCode()
- func LocalHomeDirectory() string
- func LocalPathCompletion(path string) ([]map[string]interface{}, string, error)
- func PublicKeyFile(file string) ssh.AuthMethod
- func RandStringBytes(n int) string
- func RemotePathCompletion(session *ssh.Session, path string) ([]map[string]interface{}, string, error)
- func Round(val float64, roundOn float64, places int) (newVal float64)
- func UnTarArchive(name, path string) (string, error)
- type ApiConnectionStruct
- type ApiV1
- func (c ApiV1) Connect() revel.Result
- func (c ApiV1) Disconnect(id string) revel.Result
- func (c ApiV1) Download(id string) revel.Result
- func (c ApiV1) GetConnections(id string) revel.Result
- func (c ApiV1) GetLocalHomeDirectory(id string) revel.Result
- func (c ApiV1) GetLocalPathCompletion(id string) revel.Result
- func (c ApiV1) GetRemoteHomeDirectory(id string) revel.Result
- func (c ApiV1) GetRemotePathCompletion(id string) revel.Result
- func (c ApiV1) Help() revel.Result
- type App
- func (c App) ConnectViaSSH() revel.Result
- func (c App) CreateNewLocalDirectory() revel.Result
- func (c App) Download() revel.Result
- func (c App) EstablishSSHConnection() revel.Result
- func (c App) GetLocalPathCompletion() revel.Result
- func (c App) GetPath() revel.Result
- func (c App) GetRemotePathCompletion() revel.Result
- func (c App) Index() revel.Result
- func (c App) LocalPathGoTo() revel.Result
- func (c App) RemotePathGoTo() revel.Result
- func (c App) SetPinCode() revel.Result
- func (c App) TestSSHConnection() revel.Result
- type FileStructureStruct
- type GeneralResponse
- type GetConnectionsStruct
- type GetPathCompletionStruct
- type PassThru
- type SSHSessionStruct
Constants ¶
This section is empty.
Variables ¶
var ( SSHclient *ssh.Client SSHsession *ssh.Session MockSSHServer = false MockSSHHostString = "sftp-mock-test" MockSSHUser = "test" MockSSHPass = "test" PinCode string TimeToWaitInvalidPin time.Duration ApiConnections = make(map[string]ApiConnectionStruct) )
Defines global variables
Functions ¶
func CompileJSONResult ¶
func CompileJSONResult(result bool, message string, otherData ...map[string]interface{}) map[string]interface{}
CompileJSONResult returns map[string]interface{} from input. Function helps to compile result for JSON output
func ConnectSSH ¶
func DownloadDirectory ¶
func DownloadFile ¶
func FormatBytes ¶
FormatBytes returns formatted string of bytes (1024 bytes -> 1KB)
func GeneratePinCode ¶
func GeneratePinCode()
func LocalHomeDirectory ¶
func LocalHomeDirectory() string
func LocalPathCompletion ¶
func PublicKeyFile ¶
func PublicKeyFile(file string) ssh.AuthMethod
PublicKeyFile returns ssh.AuthMethod which is needed to create additional AuthMethod from private key file
func RandStringBytes ¶
func RemotePathCompletion ¶
func UnTarArchive ¶
Types ¶
type ApiConnectionStruct ¶
type ApiV1 ¶
type ApiV1 struct {
*revel.Controller
}
func (ApiV1) Connect ¶
@Summary Connect via SSH @Description connect via SSH and store connection @ID connect @Accept json @Produce json @Param JSON body controllers.ApiConnectionStruct true "Connection information" @Success 200 {object} controllers.GeneralResponse "Success with connection ID in message" @Failure 403 {string} string "Not authorized!" @Router /connect [put]
func (ApiV1) Disconnect ¶
@Summary Disconnect @Description remove stored connection @ID disconnect @Accept json @Produce json @Param id path string true "Connection ID" @Success 200 {object} controllers.GeneralResponse "Success" @Failure 403 {string} string "Not authorized!" @Router /disconnect/{id} [delete]
func (ApiV1) Download ¶
@Summary Download @Description download file or directory @ID download @Produce json @Param id path string true "Connection ID" @Param path query string true "Path to file OR directory" @Param save_to query string false "If not empty than download to.. otherwise file/directory will be downloaded to local home directory" @Success 200 {object} controllers.GeneralResponse "Success" @Failure 403 {string} string "Not authorized!" @Router /download/{id} [get]
func (ApiV1) GetConnections ¶
@Summary Get connections @Description get list of stored connections @ID get-connections @Produce json @Success 200 {object} controllers.GetConnectionsStruct "Success" @Failure 403 {string} string "Not authorized!" @Router /getConnections [get]
func (ApiV1) GetLocalHomeDirectory ¶
@Summary Get local home directory @ID get-local-home-directory @Produce json @Success 200 {object} controllers.GeneralResponse "Success with local path in message" @Failure 403 {string} string "Not authorized!" @Router /getLocalHomeDirectory [get]
func (ApiV1) GetLocalPathCompletion ¶
@Summary Get local path completion @Description list local directories like "double tab" @ID get-local-path-completion @Produce json @Param path query string true "Local path" @Success 200 {object} controllers.GetPathCompletionStruct "Success with list of items" @Failure 403 {string} string "Not authorized!" @Router /getLocalPathCompletion [get]
func (ApiV1) GetRemoteHomeDirectory ¶
@Summary Get remote home directory @Description get remote home directory path @ID get-remote-home-directory-path @Produce json @Param id path string true "Connection ID" @Success 200 {object} controllers.GeneralResponse "Success with home directory path in message" @Failure 403 {string} string "Not authorized!" @Router /getRemoteHomeDirectory/{id} [get]
func (ApiV1) GetRemotePathCompletion ¶
@Summary Get remote path completion @Description list remote directories like "double tab" @ID get-remote-path-completion @Produce json @Param id path string true "Connection ID" @Param path query string true "Remote path" @Success 200 {object} controllers.GetPathCompletionStruct "Success with list of items" @Failure 403 {string} string "Not authorized!" @Router /getRemotePathCompletion/{id} [get]
type App ¶
type App struct {
*revel.Controller
}
func (App) ConnectViaSSH ¶
ConnectViaSSH returns JSON which contains: result: true for success/false for any error message: empty if success, message if error remote_path: remote home directory local_path: local home directory errors: array of messages received during the whole process of connecting via SSH
func (App) CreateNewLocalDirectory ¶
CreateNewLocalDirectory creates new local directory and returns JSON which contains: result: true for success/false for any error message: empty if success, message if error new_path: path to newly created directory
func (App) Download ¶
Download returns JSON which contains: result: true for success/false for any error message: empty if success, message if error If success function downloads file or directory locally
func (App) EstablishSSHConnection ¶
EstablishSSHConnection is a helper function which is used to connect via SSH and accepts ssh_ip, ssh_user, ssh_password, ssh_port
func (App) GetLocalPathCompletion ¶
GetLocalPathCompletion acts like double tab for local and returns JSON which contains: result: true for success/false for any error message: empty if success, message if error items: list of found files/folders
func (App) GetPath ¶
GetPath returns JSON which contains: result: true for success/false for any error message: empty if success, message if error path: formatted path from input
func (App) GetRemotePathCompletion ¶
GetRemotePathCompletion acts like double tab for remote and returns JSON which contains: result: true for success/false for any error message: empty if success, message if error items: list of found files/folders
func (App) LocalPathGoTo ¶
LocalPathGoTo returns JSON which contains: result: true for success/false for any error message: empty if success, message if error local_files: list of local files local_path_separator: local separator which is needed for navigation compatible with Windows/*nix based systems
func (App) RemotePathGoTo ¶
RemotePathGoTo returns JSON which contains: result: true for success/false for any error message: empty if success, message if error remote_files: list of remote files
func (App) SetPinCode ¶
func (App) TestSSHConnection ¶
TestSSHConnection returns if connection via SSH was made successfully or not it just executed function EstablishSSHConnection
type FileStructureStruct ¶
type GeneralResponse ¶
type GetConnectionsStruct ¶
type GetConnectionsStruct struct { Result bool `json:"result"` Message string `json:"message"` Connections []ApiConnectionStruct `json:"connections"` }
type GetPathCompletionStruct ¶
Source Files ¶
- api_v1.go
- api_v1_DELETE.go
- api_v1_GET.go
- api_v1_PUT.go
- app.go
- connect_via_ssh.go
- connection.go
- download.go
- download_directory.go
- download_file.go
- establish_connection.go
- get_path.go
- helper_types.go
- helpers.go
- init.go
- local_path_go_to.go
- mock_ssh_server.go
- new_local_dir.go
- path_completion.go
- remote_path_go_to.go
- test_connection.go