Remove support for ProxyURLs.
authorRobert Sesek <rsesek@bluestatic.org>
Wed, 15 Aug 2012 14:29:59 +0000 (10:29 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Wed, 15 Aug 2012 14:29:59 +0000 (10:29 -0400)
It was only added to support TV renaming, which has since moved from the
frontend into the backend.

config/config.go
config/config.sample.json
server/server.go

index ae7028359636493e7112a050845be389cf1bec1b..ac497fe5ff01a5e23be5e92296757b97333670c4 100644 (file)
@@ -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.
index ec1ae3820b7c1f592578e91f1a71adc559ae9330..e5879e185ede569e861f0f3e4d5a67ceffdf83ef 100644 (file)
@@ -3,9 +3,5 @@
 
   "Port": 8084,
 
-  "ProxyURLs": [
-    "http://services.tvrage.com/tools/quickinfo.php",
-  ],
-
   "IncludeDotfiles": true
-}
\ No newline at end of file
+}
index 87847405f3376bde95ab0a9a3be98f755a6df06c..e5874a71368bac68bf44cb3f2fa7ed52ea20df2f 100644 (file)
@@ -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)