Created
May 9, 2025 11:45
-
-
Save phanirithvij/b518f3e2738a5ea0e727bef864cd8d9e to your computer and use it in GitHub Desktop.
seedr.cc webseed proxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io" | |
"log" | |
"net/http" | |
"net/url" | |
) | |
// It can be improved by using some seedr.cc API | |
// but it is generic enough for now | |
// generated by claude.ai initially, hand modified | |
const ( | |
folder = "some-folder-name" | |
file1URL = "some-hard-coded-url" | |
) | |
func getProxyUrlForURL(u *url.URL) string { | |
fmt.Println(u.String()) | |
switch u.String() { | |
case "/" + folder + "/file1.ext": | |
return file1URL | |
} | |
return "" | |
} | |
func main() { | |
proxyHandler := func(w http.ResponseWriter, r *http.Request) { | |
// Create the proxy request | |
proxyURL := getProxyUrlForURL(r.URL) | |
req, err := http.NewRequest(r.Method, proxyURL, r.Body) | |
if err != nil { | |
http.Error(w, "Bad request", http.StatusBadRequest) | |
return | |
} | |
// Copy headers | |
req.Header = r.Header.Clone() | |
// Send the request | |
resp, err := http.DefaultClient.Do(req) | |
if err != nil { | |
http.Error(w, "Failed to reach upstream server", http.StatusBadGateway) | |
return | |
} | |
defer resp.Body.Close() | |
// Copy the response headers and body | |
for k, v := range resp.Header { | |
for _, vv := range v { | |
w.Header().Add(k, vv) | |
} | |
} | |
w.WriteHeader(resp.StatusCode) | |
io.Copy(w, resp.Body) | |
} | |
http.HandleFunc("/", proxyHandler) | |
log.Println("Proxy server listening on http://localhost:3832") | |
log.Fatal(http.ListenAndServe(":3832", nil)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
go run main.go
add
http://localhost:3832/
in http sources/webseeds section, re-run with updated filenames. re-add url to webseeds sectionLICENSE: WTFPL