mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-08-06 13:18:30 +02:00
Updated version code and defs
- Updated version code - Replaced hardcoded path of some config folder string with const value
This commit is contained in:
@@ -108,9 +108,9 @@ func filterProxyConfigFilename(filename string) string {
|
|||||||
|
|
||||||
func SaveReverseProxyConfig(endpoint *dynamicproxy.ProxyEndpoint) error {
|
func SaveReverseProxyConfig(endpoint *dynamicproxy.ProxyEndpoint) error {
|
||||||
//Get filename for saving
|
//Get filename for saving
|
||||||
filename := filepath.Join("./conf/proxy/", endpoint.RootOrMatchingDomain+".config")
|
filename := filepath.Join(CONF_HTTP_PROXY, endpoint.RootOrMatchingDomain+".config")
|
||||||
if endpoint.ProxyType == dynamicproxy.ProxyTypeRoot {
|
if endpoint.ProxyType == dynamicproxy.ProxyTypeRoot {
|
||||||
filename = "./conf/proxy/root.config"
|
filename = filepath.Join(CONF_HTTP_PROXY, "root.config")
|
||||||
}
|
}
|
||||||
|
|
||||||
filename = filterProxyConfigFilename(filename)
|
filename = filterProxyConfigFilename(filename)
|
||||||
@@ -125,9 +125,9 @@ func SaveReverseProxyConfig(endpoint *dynamicproxy.ProxyEndpoint) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func RemoveReverseProxyConfig(endpoint string) error {
|
func RemoveReverseProxyConfig(endpoint string) error {
|
||||||
filename := filepath.Join("./conf/proxy/", endpoint+".config")
|
filename := filepath.Join(CONF_HTTP_PROXY, endpoint+".config")
|
||||||
if endpoint == "/" {
|
if endpoint == "/" {
|
||||||
filename = "./conf/proxy/root.config"
|
filename = filepath.Join(CONF_HTTP_PROXY, "/root.config")
|
||||||
}
|
}
|
||||||
|
|
||||||
filename = filterProxyConfigFilename(filename)
|
filename = filterProxyConfigFilename(filename)
|
||||||
@@ -179,11 +179,11 @@ func ExportConfigAsZip(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Specify the folder path to be zipped
|
// Specify the folder path to be zipped
|
||||||
if !utils.FileExists("./conf") {
|
if !utils.FileExists(CONF_FOLDER) {
|
||||||
SystemWideLogger.PrintAndLog("Backup", "Configuration folder not found", nil)
|
SystemWideLogger.PrintAndLog("Backup", "Configuration folder not found", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
folderPath := "./conf"
|
folderPath := CONF_FOLDER
|
||||||
|
|
||||||
// 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")
|
||||||
@@ -284,12 +284,12 @@ func ImportConfigFromZip(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Create the target directory to unzip the files
|
// Create the target directory to unzip the files
|
||||||
targetDir := "./conf"
|
targetDir := CONF_FOLDER
|
||||||
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()))
|
//backupPath := filepath.Dir(*path_conf) + filepath.Base(*path_conf) + ".old_" + strconv.Itoa(int(time.Now().Unix()))
|
||||||
//os.Rename(*path_conf, backupPath)
|
//os.Rename(*path_conf, backupPath)
|
||||||
os.Rename("./conf", "./conf.old_"+strconv.Itoa(int(time.Now().Unix())))
|
os.Rename(CONF_FOLDER, CONF_FOLDER+".old_"+strconv.Itoa(int(time.Now().Unix())))
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.MkdirAll(targetDir, os.ModePerm)
|
err = os.MkdirAll(targetDir, os.ModePerm)
|
||||||
|
23
src/def.go
23
src/def.go
@@ -44,7 +44,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
/* Build Constants */
|
/* Build Constants */
|
||||||
SYSTEM_NAME = "Zoraxy"
|
SYSTEM_NAME = "Zoraxy"
|
||||||
SYSTEM_VERSION = "3.2.4"
|
SYSTEM_VERSION = "3.2.5"
|
||||||
DEVELOPMENT_BUILD = false
|
DEVELOPMENT_BUILD = false
|
||||||
|
|
||||||
/* System Constants */
|
/* System Constants */
|
||||||
@@ -63,14 +63,19 @@ const (
|
|||||||
LOG_EXTENSION = ".log"
|
LOG_EXTENSION = ".log"
|
||||||
STATISTIC_AUTO_SAVE_INTERVAL = 600 /* Seconds */
|
STATISTIC_AUTO_SAVE_INTERVAL = 600 /* Seconds */
|
||||||
|
|
||||||
/* Configuration Folder Storage Path Constants */
|
/*
|
||||||
CONF_HTTP_PROXY = "./conf/proxy"
|
Configuration Folder Storage Path Constants
|
||||||
CONF_STREAM_PROXY = "./conf/streamproxy"
|
Note: No tailing slash in the path
|
||||||
CONF_CERT_STORE = "./conf/certs"
|
*/
|
||||||
CONF_REDIRECTION = "./conf/redirect"
|
CONF_FOLDER = "./conf"
|
||||||
CONF_ACCESS_RULE = "./conf/access"
|
CONF_HTTP_PROXY = CONF_FOLDER + "/proxy"
|
||||||
CONF_PATH_RULE = "./conf/rules/pathrules"
|
CONF_STREAM_PROXY = CONF_FOLDER + "/streamproxy"
|
||||||
CONF_PLUGIN_GROUPS = "./conf/plugin_groups.json"
|
CONF_CERT_STORE = CONF_FOLDER + "/certs"
|
||||||
|
CONF_REDIRECTION = CONF_FOLDER + "/redirect"
|
||||||
|
CONF_ACCESS_RULE = CONF_FOLDER + "/access"
|
||||||
|
CONF_PATH_RULE = CONF_FOLDER + "/rules/pathrules"
|
||||||
|
CONF_PLUGIN_GROUPS = CONF_FOLDER + "/plugin_groups.json"
|
||||||
|
CONF_GEODB_PATH = CONF_FOLDER + "/geodb"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* System Startup Flags */
|
/* System Startup Flags */
|
||||||
|
@@ -69,7 +69,7 @@ func main() {
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
if *geoDbUpdate {
|
if *geoDbUpdate {
|
||||||
geodb.DownloadGeoDBUpdate("./conf/geodb")
|
geodb.DownloadGeoDBUpdate(CONF_GEODB_PATH)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -135,7 +135,7 @@ func ReverseProxtInit() {
|
|||||||
Load all conf from files
|
Load all conf from files
|
||||||
|
|
||||||
*/
|
*/
|
||||||
confs, _ := filepath.Glob("./conf/proxy/*.config")
|
confs, _ := filepath.Glob(CONF_HTTP_PROXY + "/*.config")
|
||||||
for _, conf := range confs {
|
for _, conf := range confs {
|
||||||
err := LoadReverseProxyConfig(conf)
|
err := LoadReverseProxyConfig(conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user