Add nopath for vue things

This commit is contained in:
Bel LaPointe
2020-07-25 02:23:04 -06:00
parent 61811e8e61
commit ec1e0cdf2e
3 changed files with 37 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
package config
import (
"encoding/json"
"fmt"
"log"
"strings"
@@ -78,3 +79,23 @@ func GetTimeout() time.Duration {
timeout := conf.Get("timeout").GetDuration()
return timeout
}
func GetCORS(key string) bool {
cors := conf.GetString("cors")
var m map[string]bool
if err := json.Unmarshal([]byte(cors), &m); err != nil {
return false
}
_, ok := m[key]
return ok
}
func GetNoPath(key string) bool {
nopath := conf.GetString("nopath")
var m map[string]bool
if err := json.Unmarshal([]byte(nopath), &m); err != nil {
return false
}
_, ok := m[key]
return ok
}

View File

@@ -48,6 +48,8 @@ func parseArgs() (*args.ArgSet, error) {
as.Append(args.DURATION, "timeout", "timeout for tunnel", time.Minute)
as.Append(args.STRING, "proxy", "double-comma separated (+ if oauth)from,scheme://to.tld:port,oauth,,", "")
as.Append(args.STRING, "oauth", "url for boauthz", "")
as.Append(args.STRING, "cors", "json dict key:true for keys to set CORS permissive headers, like {\"from\":true}", "{}")
as.Append(args.STRING, "nopath", "json dict key:true for keys to remove all path info from forwarded request, like -cors", "{}")
err := as.Parse()
return as, err