Documentation
¶
Index ¶
- Constants
- Variables
- func AppendGeneralInfo(lines *[]LineResult)
- func BindRequest[T any](c echo.Context, request T) error
- func CleanString(input string) string
- func Cleanup()
- func ConsistentFormat(logLines []string) (bool, int)
- func ContainerStdoutToTmp(containerID string) *os.File
- func F64NumberToK(num *float64) string
- func FilePathInGlobalFilePaths(filePath string) bool
- func FileStats(filePath string, isRemote bool, sshConfig *SSHConfig) (int, int64, error)
- func FilesByPattern(pattern string, isRemote bool, sshConfig *SSHConfig) ([]string, error)
- func GetHomedir() string
- func GetTmpFileNameForContainer() string
- func GetTmpFileNameForSTDIN() string
- func HTTPErrorHandler(err error, c echo.Context)
- func HandleCltrC(f func())
- func HandleStdinPipe()
- func IsGzip(buffer []byte) bool
- func IsInputFromPipe() bool
- func IsReadableFile(filename string, isRemote bool, sshConfig *SSHConfig, checkUTF8 bool) (bool, error)
- func JudgeLogLevel(line string, keywordPosition int) string
- func ListDockerContainers() ([]container.Summary, error)
- func NewEcho(opts ...EchoOption) error
- func NewOrReusableClient(config *SSHConfig) (*ssh.Client, error)
- func NewSession(config *SSHConfig) (*ssh.Session, error)
- func OpenBrowser(url string)
- func PipeLinesToTmp(tmpFile *os.File) error
- func ResponseHTML(c echo.Context, b []byte, cacheMS string) error
- func ResponsePlain(c echo.Context, b []byte, cacheMS string) error
- func SetHeadersResponseHTML(header http.Header, cacheMS string)
- func SetHeadersResponseJSON(header http.Header)
- func SetHeadersResponsePNG(header http.Header)
- func SetHeadersResponsePlainText(header http.Header, cacheMS string)
- func SetHeadersResponseSvg(header http.Header)
- func SetupCors(e *echo.Echo, options *EchoOptions)
- func SetupLoggingStdout(logLevel slog.Leveler)
- func SetupMiddlewares(e *echo.Echo)
- func SetupRoutes(e *echo.Echo, options *EchoOptions)
- func StringInSlice(s string, ss []string) bool
- func UpdateGlobalFilePaths(filePaths SliceFlags, sshPaths SliceFlags, dockerPaths SliceFlags, limit int)
- func WatchFilePaths(seconds int64, filePaths SliceFlags, sshPaths SliceFlags, ...)
- type API
- type APIHandler
- type APIRequest
- type APIResponse
- type AssetsHandler
- type DockerPathConfig
- type EchoOption
- type EchoOptions
- type FileInfo
- type HTTPErrorResponse
- type LineResult
- type SSHConfig
- type SSHPathConfig
- type ScanResult
- type SliceFlags
- type ValidationErrs
- type Watcher
Constants ¶
const ( TypeFile = "file" TypeStdin = "stdin" TypeSSH = "ssh" TypeDocker = "docker" TmpStdinPath = "/tmp/GOL-STDIN-" TmpContainerPath = "/tmp/GOL-CONTAINER-" ErrorMsgSessionAlreadyStarted = "ssh: session already started" )
Variables ¶
var GlobalFilePaths []FileInfo
var GlobalPathSSHConfig []SSHPathConfig
var GlobalPipeTmpFilePath string
var GlobalSSHClients = make(map[string]*ssh.Client)
Functions ¶
func AppendGeneralInfo ¶
func AppendGeneralInfo(lines *[]LineResult)
func CleanString ¶
CleanString removes non-printable characters from a string
func ConsistentFormat ¶
ConsistentFormat checks if all log lines have log levels at the same position
func ContainerStdoutToTmp ¶
func F64NumberToK ¶
func FilesByPattern ¶
func GetHomedir ¶
func GetHomedir() string
func GetTmpFileNameForContainer ¶
func GetTmpFileNameForContainer() string
func GetTmpFileNameForSTDIN ¶
func GetTmpFileNameForSTDIN() string
func HTTPErrorHandler ¶
HTTPErrorHandler handles HTTP errors for entire application
func HandleCltrC ¶
func HandleCltrC(f func())
func HandleStdinPipe ¶
func HandleStdinPipe()
func IsInputFromPipe ¶
func IsInputFromPipe() bool
IsInputFromPipe checks if there is input from a pipe
func IsReadableFile ¶
func IsReadableFile(filename string, isRemote bool, sshConfig *SSHConfig, checkUTF8 bool) (bool, error)
IsReadableFile checks if the file is readable and optionally checks for valid UTF-8 encoded content
func JudgeLogLevel ¶
JudgeLogLevel returns the log level based on the content of the log line if the format is consistent
func ListDockerContainers ¶
func NewEcho ¶
func NewEcho(opts ...EchoOption) error
func OpenBrowser ¶
func OpenBrowser(url string)
func PipeLinesToTmp ¶
func SetHeadersResponseHTML ¶
func SetHeadersResponseJSON ¶
func SetHeadersResponsePNG ¶
func SetHeadersResponseSvg ¶
func SetupCors ¶
func SetupCors(e *echo.Echo, options *EchoOptions)
func SetupLoggingStdout ¶
func SetupMiddlewares ¶
func SetupRoutes ¶
func SetupRoutes(e *echo.Echo, options *EchoOptions)
func StringInSlice ¶
func UpdateGlobalFilePaths ¶
func UpdateGlobalFilePaths(filePaths SliceFlags, sshPaths SliceFlags, dockerPaths SliceFlags, limit int)
func WatchFilePaths ¶
func WatchFilePaths(seconds int64, filePaths SliceFlags, sshPaths SliceFlags, dockerPaths SliceFlags, limit int)
Types ¶
type API ¶
type API struct {
}
func (*API) FindSSHConfig ¶
func (a *API) FindSSHConfig(host string) *SSHPathConfig
type APIHandler ¶
type APIHandler struct {
API *API
}
func NewAPIHandler ¶
func NewAPIHandler() *APIHandler
type APIRequest ¶
type APIRequest struct {
Query string `json:"query" query:"query"`
Ignore string `json:"ignore" query:"ignore"`
FilePath string `json:"file_path" query:"file_path"`
Host string `json:"host" query:"host"`
Type string `json:"type" query:"type"`
Page int `json:"page" query:"page" default:"1" validate:"required,gte=1" message:"page >=1 is required"`
PerPage int `json:"per_page" query:"per_page" default:"15" validate:"required" message:"per_page is required"`
Reverse bool `json:"reverse" query:"reverse" default:"false"`
}
type APIResponse ¶
type APIResponse struct {
Result ScanResult `json:"result"`
FilePaths []FileInfo `json:"file_paths"`
}
type AssetsHandler ¶
type AssetsHandler struct {
// contains filtered or unexported fields
}
func NewAssetsHandler ¶
func NewAssetsHandler(publicDir *embed.FS, distDir string, filename string) *AssetsHandler
type DockerPathConfig ¶
func StringToDockerPathConfig ¶
func StringToDockerPathConfig(s string) (*DockerPathConfig, error)
s is an input of the form "container_id /path/to/file"
type EchoOption ¶
type EchoOption func(*EchoOptions) error
type EchoOptions ¶
type FileInfo ¶
type FileInfo struct {
FilePath string `json:"file_path"`
LinesCount int `json:"lines_count"`
FileSize int64 `json:"file_size"`
Name string `json:"name"`
Type string `json:"type"`
Host string `json:"host"`
}
func GetContainerFileInfos ¶
func GetFileInfos ¶
func UniqueFileInfos ¶
type HTTPErrorResponse ¶
type HTTPErrorResponse struct {
Error interface{} `json:"error"`
}
HTTPErrorResponse is the response for HTTP errors
type LineResult ¶
type SSHPathConfig ¶
type SSHPathConfig struct {
Host string
Port string
User string
Password string
PrivateKeyPath string
FilePath string
}
func StringToSSHPathConfig ¶
func StringToSSHPathConfig(s string) (*SSHPathConfig, error)
s is an input of the form "user@host[:port] [password=/path/to/password] [private_key=/path/to/key] /path/to/file"
type ScanResult ¶
type ScanResult struct {
FilePath string `json:"file_path"`
Host string `json:"host"`
Type string `json:"type"`
MatchPattern string `json:"match_pattern"`
Total int `json:"total"`
Lines []LineResult `json:"lines"`
}
func ContainerLogsFromFile ¶
type SliceFlags ¶
type SliceFlags []string
func (*SliceFlags) Set ¶
func (i *SliceFlags) Set(value string) error
provide a Set() method on the type so we can use it with flag.Var
func (*SliceFlags) String ¶
func (i *SliceFlags) String() string
provide a String() method on the type so we can use it with flag.Var
type ValidationErrs ¶
func ValidateRequest ¶
func ValidateRequest[T any](request T) (ValidationErrs, error)