cmd

package
v1.0.0-rc.10 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GistFileName  = "terminal-recording.json"
	Application   = "termbacktime"
	GistAPI       = "https://api.github.com/gists"
	PlaybackURL   = "https://termbackti.me"
	LiveURL       = "https://xterm.live"
	Broker        = "wss://broker.termbackti.me"
	APIEndpoint   = "https://api.termbackti.me"
	Revision      = "0000000"
	Version       = "0.0.0"
	ConfigType    = "json"
	STUNServerOne = "stun:stun1.l.google.com:19302"
	STUNServerTwo = "stun:stun2.l.google.com:19302"
	HomeDir       = getHome()
	Username      = uuid()
)

Exported default compile settings.

View Source
var (
	Shell        string
	Closed       bool
	GistResponse map[string]interface{}
	GithubToken  string
	Instructions []Lines
)

Base application variables.

Functions

func DecodeAnswer

func DecodeAnswer(in string, obj interface{}) (interface{}, error)

DecodeAnswer decodes WebRTC answer from base64

func EncodeOffer

func EncodeOffer(obj interface{}) (string, error)

EncodeOffer encodes WebRTC offer in base64

func Error

func Error(err error) error

Error stops the spinner whenever an error is thrown.

func Execute

func Execute()

Execute runs the recording function by default.

func FMTTurn

func FMTTurn(addrs []string) []string

FMTTurn converts a string into a TURN URI

func InitConfig

func InitConfig(fn func() (string, bool)) (string, bool)

InitConfig reads in config file and ENV variables if set.

func ToJSON

func ToJSON(obj interface{}) string

ToJSON converts interface to JSON

func VersionCheck

func VersionCheck(current string) (string, bool)

VersionCheck checks the current version against the semver at termbackti.me/_version TODO: Create a manual command to check versions.

Types

type AuthResponse

type AuthResponse struct {
	Token string `json:"token"`
	Login string `json:"login"`
}

AuthResponse represents the WebSocket response from the broker

type GetGist

type GetGist struct {
	ID          string                 `json:"id,omitempty"`
	Description string                 `json:"description,omitempty"`
	Public      bool                   `json:"public,omitempty"`
	Owner       map[string]interface{} `json:"owner,omitempty"`
	Files       map[string]GistFile    `json:"files,omitempty"`
	Comments    int                    `json:"comments,omitempty"`
	HTMLURL     string                 `json:"html_url,omitempty"`
	GitPullURL  string                 `json:"git_pull_url,omitempty"`
	GitPushURL  string                 `json:"git_push_url,omitempty"`
	CreatedAt   time.Time              `json:"created_at,omitempty"`
	UpdatedAt   time.Time              `json:"updated_at,omitempty"`
	NodeID      string                 `json:"node_id,omitempty"`
}

GetGist represents a GitHub's gist API response.

type Gist

type Gist struct {
	Description string               `json:"description,omitempty"`
	Public      bool                 `json:"public,omitempty"`
	GistFiles   map[string]GistFiles `json:"files,omitempty"`
}

Gist is the required structure for POST data for API purposes.

type GistFile

type GistFile struct {
	Size     int    `json:"size,omitempty"`
	Filename string `json:"filename,omitempty"`
	Language string `json:"language,omitempty"`
	Type     string `json:"type,omitempty"`
	RawURL   string `json:"raw_url,omitempty"`
	Content  string `json:"content,omitempty"`
}

GistFile represents a file in a gist.

type GistFiles

type GistFiles struct {
	Content string `json:"content"`
}

GistFiles is the top-level struct for gist files.

type Info

type Info struct {
	Arch string `json:"a"`
	OS   string `json:"o"`
	Go   string `json:"v"`
}

Info is the distro information.

type Lines

type Lines struct {
	Time    int64    `json:"t,omitempty"`
	Command string   `json:"c,omitempty"`
	Lines   []string `json:"l,omitempty"`
	Sizes   []int    `json:"s,omitempty"`
}

Lines is an array of terminal STDOUT lines.

type LiveLine

type LiveLine struct {
	Command string   `json:"c,omitempty"`
	Lines   []string `json:"l,omitempty"`
	Sizes   []int    `json:"s,omitempty"`
}

LiveLine is for live terminal streaming

type LiveOffer

type LiveOffer struct {
	Offer string      `json:"offer"`
	TURN  *TURNServer `json:"turn,omitempty"`
}

LiveOffer creates SDP offers

type LiveResponse

type LiveResponse struct {
	Connected bool   `json:"connected"`
	Answer    string `json:"answer"`
}

LiveResponse represents the WebSocket response from the broker

type Logger

type Logger struct {
	*log.Logger
	// contains filtered or unexported fields
}

Logger writes logs to a temp file to display on exit

func GetLogger

func GetLogger(prefix ...string) *Logger

GetLogger returns a logger instance

func (*Logger) Dump

func (l *Logger) Dump() *Logger

Dump logger content

func (*Logger) Name

func (l *Logger) Name() string

Name returns the file name

func (*Logger) Remove

func (l *Logger) Remove() (bool, error)

Remove a log file

func (*Logger) Write

func (l *Logger) Write(str string) *Logger

Write wraps log.Println

type Recording

type Recording struct {
	Info    Info    `json:"i"`
	Started int64   `json:"d"`
	Title   string  `json:"t,omitempty"`
	Sizes   []int   `json:"s,omitempty"`
	Lines   []Lines `json:"r,omitempty"`
	Pack    string  `json:"p,omitempty"`
}

Recording JSON struct for recordings.

type TURNCredentials

type TURNCredentials struct {
	URLs       []string `json:"servers,omitempty"`
	Username   string   `json:"username,omitempty"`
	Credential string   `json:"credential,omitempty"`
}

TURNCredentials is the authorization creds for official TURN servers

type TURNServer

type TURNServer struct {
	URLs       string `json:"urls,omitempty"`
	Username   string `json:"username,omitempty"`
	Credential string `json:"credential,omitempty"`
}

TURNServer is used for the front end access to a TURN server

Jump to

Keyboard shortcuts

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