|
@@ -50,16 +50,30 @@ type HttpServerConfig struct {
|
|
|
ProxyAddr string `json:"proxy_addr"`
|
|
|
RouteMapPath string `json:"route_map_path"`
|
|
|
PageModPath string `json:"page_mod_path"`
|
|
|
+ CustomFServePath string `json:"custom_fileserve_cfg_path"`
|
|
|
CookieFile string `json:"cookie_file"`
|
|
|
FullProxyDomain string // the domain name of the proxied site with the protocol
|
|
|
KnownHosts []string `json:"known_hosts"`
|
|
|
CorsHosts []string `json:"cors_hosts"`
|
|
|
Redirects []*RedirectRule `json:"redirects"`
|
|
|
+ Caching bool
|
|
|
+ CustomFserve *CustomFileServer
|
|
|
CookieJar []*http.Cookie
|
|
|
PhpSession *http.Cookie
|
|
|
SsoToken *http.Cookie
|
|
|
}
|
|
|
|
|
|
+type CustomFile struct {
|
|
|
+ Request string `json:"request"`
|
|
|
+ Serve string `json:"serve"`
|
|
|
+ ContentType string `json:"content-type"`
|
|
|
+ FileData []byte
|
|
|
+}
|
|
|
+
|
|
|
+type CustomFileServer struct {
|
|
|
+ Config []*CustomFile `json:"config"`
|
|
|
+}
|
|
|
+
|
|
|
type RedirectRule struct {
|
|
|
From string `json:"from"`
|
|
|
To string `json:"to"`
|
|
@@ -96,6 +110,7 @@ func ReadConfig(loc string) (*HttpServerConfig, error) {
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
+ cfg.CustomFserve = ReadCustomFiles(cfg.CustomFServePath)
|
|
|
cfg.FullDomain = fmt.Sprintf("%s://%s", cfg.Proto, cfg.AllowedDomain)
|
|
|
cfg.FullProxyDomain = fmt.Sprintf("%s://%s", cfg.Proto, cfg.ProxyAddr)
|
|
|
cfg.FullAltAllowedDomain = fmt.Sprintf("%s://%s", cfg.Proto, cfg.AltAllowedDomain)
|
|
@@ -134,3 +149,33 @@ func ReadRouteMap(loc string) *RouteMap {
|
|
|
return &mapfile
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+/*
|
|
|
+Read in the custom file server configuration
|
|
|
+
|
|
|
+ :param loc: path to the custom file server config
|
|
|
+*/
|
|
|
+func ReadCustomFiles(loc string) *CustomFileServer {
|
|
|
+ b, err := os.ReadFile(loc)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal("couldnt read custom config file: ", err)
|
|
|
+ }
|
|
|
+ var fserveCfg CustomFileServer
|
|
|
+ err = json.Unmarshal(b, &fserveCfg)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal("error loading in the config file: ", err)
|
|
|
+ }
|
|
|
+ for idx := range fserveCfg.Config {
|
|
|
+ _, err = os.Stat(fserveCfg.Config[idx].Serve)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal("Couldnt verify the existence of file: ", fserveCfg.Config[idx].Serve, " error: ", err)
|
|
|
+ }
|
|
|
+ b, err = os.ReadFile(fserveCfg.Config[idx].Serve)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal("Error reading in custom fileserver file: ", err)
|
|
|
+ }
|
|
|
+ fserveCfg.Config[idx].FileData = b
|
|
|
+ }
|
|
|
+ fmt.Printf("%+v\n", fserveCfg)
|
|
|
+ return &fserveCfg
|
|
|
+}
|