80 lines
2.0 KiB
Go
80 lines
2.0 KiB
Go
package globals
|
|
|
|
import (
|
|
"os"
|
|
"sync"
|
|
)
|
|
|
|
var LogFile *os.File
|
|
|
|
type Config struct {
|
|
// general
|
|
Timezone string `json:"timezone"`
|
|
LogFilePath string `json:"logFilePath"`
|
|
LogLevel string `json:"logLevel"`
|
|
LogLevelNumeric int
|
|
|
|
// latex
|
|
LatexEngine string `json:"latexEngine"`
|
|
LatexSourceFilePath string `json:"latexSourceFilePath"`
|
|
LatexOutputPath string `json:"latexOutputPath"`
|
|
|
|
// webserver
|
|
WebserverDomain string `json:"webserverDomain"`
|
|
WebserverPort string `json:"webserverPort"`
|
|
WebserverSecure bool `json:"webserverSecure"`
|
|
WebserverPortSecure string `json:"webserverPortSecure"`
|
|
CertificatePath string `json:"certificatePath"`
|
|
CertificateKeyPath string `json:"certificateKeyPath"`
|
|
TrustedProxies []string `json:"trustedProxies"`
|
|
}
|
|
var AppConfig Config
|
|
|
|
type LatexExecution struct {
|
|
ExecutionLock sync.Mutex
|
|
ExecutionState string
|
|
Timestamp string
|
|
TimestampRFC string
|
|
Output []byte
|
|
}
|
|
var LatexExec LatexExecution
|
|
var LatexExecutionStateSuccess = "Success"
|
|
var LatexExecutionStateFailure = "Failure"
|
|
|
|
// Creates a copy of a LatexExecution (without the Mutex)
|
|
func (execution *LatexExecution) Copy() (exeCopy *LatexExecution) {
|
|
if execution == nil { return nil }
|
|
|
|
exeCopy = &LatexExecution{
|
|
ExecutionState: execution.ExecutionState,
|
|
Timestamp: execution.Timestamp,
|
|
TimestampRFC: execution.TimestampRFC,
|
|
}
|
|
|
|
if execution.Output != nil {
|
|
exeCopy.Output = make([]byte, len(execution.Output))
|
|
copy(exeCopy.Output, execution.Output)
|
|
}
|
|
|
|
return exeCopy
|
|
}
|
|
|
|
// Returns whether the two executions are equal
|
|
func (left *LatexExecution) Equal(right *LatexExecution) (isEqual bool) {
|
|
if left.ExecutionState != right.ExecutionState { return false }
|
|
if left.Timestamp != right.Timestamp { return false }
|
|
if left.TimestampRFC != right.TimestampRFC { return false }
|
|
if string(left.Output) != string(right.Output) { return false }
|
|
return true
|
|
}
|
|
|
|
type ClientInfo struct {
|
|
ClientIP string
|
|
RequestType string
|
|
RequestPath string
|
|
Proxy string
|
|
Proxied bool
|
|
ProxyTrusted bool
|
|
}
|
|
|