From 379e95035717eaf3a510cab5904ef731abf8398a Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 15 Aug 2012 10:29:59 -0400 Subject: [PATCH] Remove support for ProxyURLs. It was only added to support TV renaming, which has since moved from the frontend into the backend. --- config/config.go | 4 --- config/config.sample.json | 6 +---- server/server.go | 56 --------------------------------------- 3 files changed, 1 insertion(+), 65 deletions(-) diff --git a/config/config.go b/config/config.go index ae70283..ac497fe 100644 --- a/config/config.go +++ b/config/config.go @@ -21,10 +21,6 @@ type Configuration struct { // The port on which the server back end runs. Port int - // An array of URLs that the /proxy service will for which the back-end will - // forward GET requests and return the result. - ProxyURLs []string - // Whether to include dotfiles (files that begin with a '.'). Users will still // be able to access directories that begin with a '.', but they will not be // included in the list. diff --git a/config/config.sample.json b/config/config.sample.json index ec1ae38..e5879e1 100644 --- a/config/config.sample.json +++ b/config/config.sample.json @@ -3,9 +3,5 @@ "Port": 8084, - "ProxyURLs": [ - "http://services.tvrage.com/tools/quickinfo.php", - ], - "IncludeDotfiles": true -} \ No newline at end of file +} diff --git a/server/server.go b/server/server.go index 8784740..e5874a7 100644 --- a/server/server.go +++ b/server/server.go @@ -14,10 +14,7 @@ import ( "encoding/json" "fmt" "io" - "net" "net/http" - "net/http/httputil" - "net/url" "os" "path" "strings" @@ -105,58 +102,6 @@ func serviceHandler(response http.ResponseWriter, request *http.Request) { } } -func proxyHandler(response http.ResponseWriter, request *http.Request) { - rawURL := request.FormValue("url") - if len(rawURL) < 1 { - return - } - - var validURL bool = false - for i := range gConfig.ProxyURLs { - allowedURL := gConfig.ProxyURLs[i] - validURL = validURL || strings.HasPrefix(rawURL, allowedURL) - } - - if !validURL { - errorResponse(response, "URL is not in proxy whitelist") - return - } - - url_, err := url.Parse(rawURL) - if err != nil { - errorResponse(response, err.Error()) - return - } - err = performProxy(url_, response, request) - if err != nil { - errorResponse(response, err.Error()) - } -} - -func performProxy(url_ *url.URL, response http.ResponseWriter, origRequest *http.Request) error { - conn, err := net.Dial("tcp", url_.Host+":http") - if err != nil { - return err - } - client := httputil.NewClientConn(conn, nil) - request, err := http.NewRequest("GET", url_.String(), nil) - if err != nil { - return err - } - request.Header.Set("User-Agent", origRequest.UserAgent()) - err = client.Write(request) - if err != nil { - return err - } - var proxyResponse *http.Response - proxyResponse, err = client.Read(request) - if err != nil && err != httputil.ErrPersistEOF { - return err - } - _, err = io.Copy(response, proxyResponse.Body) - return err -} - func downloadHandler(response http.ResponseWriter, request *http.Request) { valid, fullPath := IsValidPath(request.FormValue("path")) if valid { @@ -205,7 +150,6 @@ func RunBackEnd(c *config.Configuration) { mux.Handle("/fe/", http.StripPrefix("/fe/", http.FileServer(http.Dir(kFrontEndFiles)))) mux.HandleFunc("/service", serviceHandler) mux.HandleFunc("/download", downloadHandler) - mux.HandleFunc("/proxy", proxyHandler) error := http.ListenAndServe(fmt.Sprintf(":%d", gConfig.Port), mux) fmt.Printf("error %v", error) -- 2.43.5