diff --git a/config/.config.go.un~ b/config/.config.go.un~ deleted file mode 100644 index 430af02..0000000 Binary files a/config/.config.go.un~ and /dev/null differ diff --git a/config/.new.go.un~ b/config/.new.go.un~ deleted file mode 100644 index 9ee28f2..0000000 Binary files a/config/.new.go.un~ and /dev/null differ diff --git a/config/config.go b/config/config.go index 6df26a8..a503e00 100755 --- a/config/config.go +++ b/config/config.go @@ -41,6 +41,10 @@ func GetAuth() (string, string, bool) { return user, pass, user != "" && pass != "" } +func GetTrim() string { + return conf.Get("trim").GetString() +} + func GetPort() string { port := conf.Get("p").GetInt() return ":" + fmt.Sprint(port) diff --git a/config/new.go b/config/new.go index 663f7a5..dbe21da 100755 --- a/config/new.go +++ b/config/new.go @@ -47,6 +47,7 @@ func parseArgs() (*args.ArgSet, error) { as.Append(args.BOOL, "compress", "enable compression", true) as.Append(args.STRING, "crt", "path to crt for ssl", "") as.Append(args.STRING, "key", "path to key for ssl", "") + as.Append(args.STRING, "trim", "path prefix to trim, like '/abc' to change '/abc/def' to '/def'", "") as.Append(args.STRING, "tcp", "address for tcp only tunnel", "") as.Append(args.DURATION, "timeout", "timeout for tunnel", time.Minute) as.Append(args.STRING, "proxy", "double-comma separated (+ if auth)from,scheme://to.tld:port,,", "") diff --git a/server/proxy.go b/server/proxy.go index e603988..73fedc5 100755 --- a/server/proxy.go +++ b/server/proxy.go @@ -4,6 +4,7 @@ import ( "bytes" "crypto/tls" "io" + "local/rproxy3/config" "local/rproxy3/storage/packable" "log" "net/http" @@ -25,6 +26,7 @@ type rewrite struct { func (s *Server) Proxy(w http.ResponseWriter, r *http.Request) { newURL, err := s.lookup(mapKey(r.Host)) + r.URL.Path = strings.TrimPrefix(r.URL.Path, config.GetTrim()) var transport http.RoundTripper http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} transport = &redirPurge{