change conf to argsset and flag for oauth

This commit is contained in:
bel
2019-10-22 04:52:04 +00:00
parent e20ba5361d
commit bc11dd7f82
10 changed files with 398 additions and 250 deletions

View File

@@ -4,7 +4,6 @@ import (
"bytes"
"crypto/tls"
"io"
"local/rproxy3/config"
"local/rproxy3/storage/packable"
"log"
"net/http"
@@ -33,10 +32,6 @@ func (s *Server) Proxy(w http.ResponseWriter, r *http.Request) {
targetHost: newURL.Host,
baseTransport: http.DefaultTransport,
}
transport = &rewrite{
rewrites: config.GetRewrites(mapKey(r.Host)),
baseTransport: transport,
}
if err != nil {
http.NotFound(w, r)
log.Printf("unknown host lookup %q", r.Host)
@@ -54,6 +49,12 @@ func (s *Server) lookup(host string) (*url.URL, error) {
return v.URL(), err
}
func (s *Server) lookupBOAuthZ(host string) (bool, error) {
v := packable.NewString()
err := s.db.Get(nsBOAuthZ, host, v)
return v.String() != "", err
}
func mapKey(host string) string {
host = strings.Split(host, ".")[0]
host = strings.Split(host, ":")[0]