mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-06-04 22:57:20 +02:00
Exposed log and db filepath setting
This commit is contained in:
parent
84aec4387a
commit
ebd316a7f1
@ -167,7 +167,11 @@ func ExportConfigAsZip(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Specify the folder path to be zipped
|
// Specify the folder path to be zipped
|
||||||
folderPath := "./conf/"
|
if !utils.FileExists("./conf") {
|
||||||
|
SystemWideLogger.PrintAndLog("Backup", "Configuration folder not found", nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
folderPath := "./conf"
|
||||||
|
|
||||||
// Set the Content-Type header to indicate it's a zip file
|
// Set the Content-Type header to indicate it's a zip file
|
||||||
w.Header().Set("Content-Type", "application/zip")
|
w.Header().Set("Content-Type", "application/zip")
|
||||||
@ -222,7 +226,7 @@ func ExportConfigAsZip(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Open the file on disk
|
// Open the file on disk
|
||||||
file, err := os.Open("sys.db")
|
file, err := os.Open("./sys.db")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
SystemWideLogger.PrintAndLog("Backup", "Unable to open sysdb", err)
|
SystemWideLogger.PrintAndLog("Backup", "Unable to open sysdb", err)
|
||||||
return
|
return
|
||||||
@ -271,6 +275,8 @@ func ImportConfigFromZip(w http.ResponseWriter, r *http.Request) {
|
|||||||
targetDir := "./conf"
|
targetDir := "./conf"
|
||||||
if utils.FileExists(targetDir) {
|
if utils.FileExists(targetDir) {
|
||||||
//Backup the old config to old
|
//Backup the old config to old
|
||||||
|
//backupPath := filepath.Dir(*path_conf) + filepath.Base(*path_conf) + ".old_" + strconv.Itoa(int(time.Now().Unix()))
|
||||||
|
//os.Rename(*path_conf, backupPath)
|
||||||
os.Rename("./conf", "./conf.old_"+strconv.Itoa(int(time.Now().Unix())))
|
os.Rename("./conf", "./conf.old_"+strconv.Itoa(int(time.Now().Unix())))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
src/def.go
10
src/def.go
@ -46,7 +46,6 @@ const (
|
|||||||
DEVELOPMENT_BUILD = false /* Development: Set to false to use embedded web fs */
|
DEVELOPMENT_BUILD = false /* Development: Set to false to use embedded web fs */
|
||||||
|
|
||||||
/* System Constants */
|
/* System Constants */
|
||||||
DATABASE_PATH = "sys.db"
|
|
||||||
TMP_FOLDER = "./tmp"
|
TMP_FOLDER = "./tmp"
|
||||||
WEBSERV_DEFAULT_PORT = 5487
|
WEBSERV_DEFAULT_PORT = 5487
|
||||||
MDNS_HOSTNAME_PREFIX = "zoraxy_" /* Follow by node UUID */
|
MDNS_HOSTNAME_PREFIX = "zoraxy_" /* Follow by node UUID */
|
||||||
@ -59,7 +58,6 @@ const (
|
|||||||
ACME_AUTORENEW_CONFIG_PATH = "./conf/acme_conf.json"
|
ACME_AUTORENEW_CONFIG_PATH = "./conf/acme_conf.json"
|
||||||
CSRF_COOKIENAME = "zoraxy_csrf"
|
CSRF_COOKIENAME = "zoraxy_csrf"
|
||||||
LOG_PREFIX = "zr"
|
LOG_PREFIX = "zr"
|
||||||
LOG_FOLDER = "./log"
|
|
||||||
LOG_EXTENSION = ".log"
|
LOG_EXTENSION = ".log"
|
||||||
|
|
||||||
/* Configuration Folder Storage Path Constants */
|
/* Configuration Folder Storage Path Constants */
|
||||||
@ -86,10 +84,16 @@ var (
|
|||||||
acmeAutoRenewInterval = flag.Int("autorenew", 86400, "ACME auto TLS/SSL certificate renew check interval (seconds)")
|
acmeAutoRenewInterval = flag.Int("autorenew", 86400, "ACME auto TLS/SSL certificate renew check interval (seconds)")
|
||||||
acmeCertAutoRenewDays = flag.Int("earlyrenew", 30, "Number of days to early renew a soon expiring certificate (days)")
|
acmeCertAutoRenewDays = flag.Int("earlyrenew", 30, "Number of days to early renew a soon expiring certificate (days)")
|
||||||
enableHighSpeedGeoIPLookup = flag.Bool("fastgeoip", false, "Enable high speed geoip lookup, require 1GB extra memory (Not recommend for low end devices)")
|
enableHighSpeedGeoIPLookup = flag.Bool("fastgeoip", false, "Enable high speed geoip lookup, require 1GB extra memory (Not recommend for low end devices)")
|
||||||
staticWebServerRoot = flag.String("webroot", "./www", "Static web server root folder. Only allow chnage in start paramters")
|
|
||||||
allowWebFileManager = flag.Bool("webfm", true, "Enable web file manager for static web server root folder")
|
allowWebFileManager = flag.Bool("webfm", true, "Enable web file manager for static web server root folder")
|
||||||
enableAutoUpdate = flag.Bool("cfgupgrade", true, "Enable auto config upgrade if breaking change is detected")
|
enableAutoUpdate = flag.Bool("cfgupgrade", true, "Enable auto config upgrade if breaking change is detected")
|
||||||
|
|
||||||
|
/* Path Configuration Flags */
|
||||||
|
//path_database = flag.String("dbpath", "./sys.db", "Database path")
|
||||||
|
//path_conf = flag.String("conf", "./conf", "Configuration folder path")
|
||||||
|
path_uuid = flag.String("uuid", "./sys.uuid", "sys.uuid file path")
|
||||||
|
path_logFile = flag.String("log", "./log", "Log folder path")
|
||||||
|
path_webserver = flag.String("webroot", "./www", "Static web server root folder. Only allow change in start paramters")
|
||||||
|
|
||||||
/* Maintaince Function Flags */
|
/* Maintaince Function Flags */
|
||||||
geoDbUpdate = flag.Bool("update_geoip", false, "Download the latest GeoIP data and exit")
|
geoDbUpdate = flag.Bool("update_geoip", false, "Download the latest GeoIP data and exit")
|
||||||
)
|
)
|
||||||
|
@ -86,7 +86,7 @@ func main() {
|
|||||||
SetupCloseHandler()
|
SetupCloseHandler()
|
||||||
|
|
||||||
//Read or create the system uuid
|
//Read or create the system uuid
|
||||||
uuidRecord := "./sys.uuid"
|
uuidRecord := *path_uuid
|
||||||
if !utils.FileExists(uuidRecord) {
|
if !utils.FileExists(uuidRecord) {
|
||||||
newSystemUUID := uuid.New().String()
|
newSystemUUID := uuid.New().String()
|
||||||
os.WriteFile(uuidRecord, []byte(newSystemUUID), 0775)
|
os.WriteFile(uuidRecord, []byte(newSystemUUID), 0775)
|
||||||
|
@ -96,7 +96,7 @@ func ReverseProxtInit() {
|
|||||||
RedirectRuleTable: redirectTable,
|
RedirectRuleTable: redirectTable,
|
||||||
GeodbStore: geodbStore,
|
GeodbStore: geodbStore,
|
||||||
StatisticCollector: statisticCollector,
|
StatisticCollector: statisticCollector,
|
||||||
WebDirectory: *staticWebServerRoot,
|
WebDirectory: *path_webserver,
|
||||||
AccessController: accessController,
|
AccessController: accessController,
|
||||||
AutheliaRouter: autheliaRouter,
|
AutheliaRouter: autheliaRouter,
|
||||||
LoadBalancer: loadBalancer,
|
LoadBalancer: loadBalancer,
|
||||||
|
@ -54,14 +54,14 @@ var (
|
|||||||
|
|
||||||
func startupSequence() {
|
func startupSequence() {
|
||||||
//Start a system wide logger and log viewer
|
//Start a system wide logger and log viewer
|
||||||
l, err := logger.NewLogger(LOG_PREFIX, LOG_FOLDER)
|
l, err := logger.NewLogger(LOG_PREFIX, *path_logFile)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
SystemWideLogger = l
|
SystemWideLogger = l
|
||||||
} else {
|
} else {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
LogViewer = logviewer.NewLogViewer(&logviewer.ViewerOption{
|
LogViewer = logviewer.NewLogViewer(&logviewer.ViewerOption{
|
||||||
RootFolder: LOG_FOLDER,
|
RootFolder: *path_logFile,
|
||||||
Extension: LOG_EXTENSION,
|
Extension: LOG_EXTENSION,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ func startupSequence() {
|
|||||||
backendType = dbinc.BackendBoltDB
|
backendType = dbinc.BackendBoltDB
|
||||||
}
|
}
|
||||||
l.PrintAndLog("database", "Using "+backendType.String()+" as the database backend", nil)
|
l.PrintAndLog("database", "Using "+backendType.String()+" as the database backend", nil)
|
||||||
db, err := database.NewDatabase(DATABASE_PATH, backendType)
|
db, err := database.NewDatabase("./sys.db", backendType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -158,7 +158,7 @@ func startupSequence() {
|
|||||||
staticWebServer = webserv.NewWebServer(&webserv.WebServerOptions{
|
staticWebServer = webserv.NewWebServer(&webserv.WebServerOptions{
|
||||||
Sysdb: sysdb,
|
Sysdb: sysdb,
|
||||||
Port: strconv.Itoa(WEBSERV_DEFAULT_PORT), //Default Port
|
Port: strconv.Itoa(WEBSERV_DEFAULT_PORT), //Default Port
|
||||||
WebRoot: *staticWebServerRoot,
|
WebRoot: *path_webserver,
|
||||||
EnableDirectoryListing: true,
|
EnableDirectoryListing: true,
|
||||||
EnableWebDirManager: *allowWebFileManager,
|
EnableWebDirManager: *allowWebFileManager,
|
||||||
Logger: SystemWideLogger,
|
Logger: SystemWideLogger,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user