handle queries
This commit is contained in:
12
README.md
12
README.md
@@ -14,14 +14,14 @@ Certain sites may display missing images or encounter formatting issues. This ca
|
|||||||
|
|
||||||
### Features
|
### Features
|
||||||
- [x] Bypass Paywalls
|
- [x] Bypass Paywalls
|
||||||
- [x] Remove CORS headers from responses, Assets, and images ...
|
- [x] Remove CORS headers from responses, assets, and images ...
|
||||||
- [x] Keep site browsable
|
- [x] Keep site browsable
|
||||||
- [x] Add a debug path
|
- [x] Add a raw path
|
||||||
- [x] Add a API
|
- [x] Add a API
|
||||||
- [x] Docker container
|
- [x] Docker container
|
||||||
- [x] Linux binary
|
- [x] Linux binary
|
||||||
- [x] Mac OS binary
|
- [x] Mac OS binary
|
||||||
- [x] Windows binary (Untested)
|
- [x] Windows binary (untested)
|
||||||
- [x] Remove most of the ads (unexpected side effect)
|
- [x] Remove most of the ads (unexpected side effect)
|
||||||
- [x] Basic Auth
|
- [x] Basic Auth
|
||||||
|
|
||||||
@@ -53,15 +53,13 @@ docker-compose up -d
|
|||||||
Or direct by appending the URL to the end of the proxy URL:
|
Or direct by appending the URL to the end of the proxy URL:
|
||||||
http://localhost:8080/https://www.google.com
|
http://localhost:8080/https://www.google.com
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### API
|
### API
|
||||||
```bash
|
```bash
|
||||||
curl -X GET "http://localhost:8080/api/https://www.google.com"
|
curl -X GET "http://localhost:8080/api/https://www.google.com"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Debug
|
### RAW
|
||||||
http://localhost:8080/debug/https://www.google.com
|
http://localhost:8080/raw/https://www.google.com
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ func Api(c *fiber.Ctx) error {
|
|||||||
// Get the url from the URL
|
// Get the url from the URL
|
||||||
urlQuery := c.Params("*")
|
urlQuery := c.Params("*")
|
||||||
|
|
||||||
body, req, resp, err := fetchSite(urlQuery)
|
queries := c.Queries()
|
||||||
|
body, req, resp, err := fetchSite(urlQuery, queries)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("ERROR:", err)
|
log.Println("ERROR:", err)
|
||||||
c.SendStatus(500)
|
c.SendStatus(500)
|
||||||
|
|||||||
@@ -18,9 +18,10 @@ var ForwardedFor = getenv("X_FORWARDED_FOR", "66.249.66.1")
|
|||||||
|
|
||||||
func ProxySite(c *fiber.Ctx) error {
|
func ProxySite(c *fiber.Ctx) error {
|
||||||
// Get the url from the URL
|
// Get the url from the URL
|
||||||
urlQuery := c.Params("*")
|
url := c.Params("*")
|
||||||
|
|
||||||
body, _, resp, err := fetchSite(urlQuery)
|
queries := c.Queries()
|
||||||
|
body, _, resp, err := fetchSite(url, queries)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("ERROR:", err)
|
log.Println("ERROR:", err)
|
||||||
c.SendStatus(500)
|
c.SendStatus(500)
|
||||||
@@ -31,17 +32,26 @@ func ProxySite(c *fiber.Ctx) error {
|
|||||||
return c.SendString(body)
|
return c.SendString(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
func fetchSite(urlQuery string) (string, *http.Request, *http.Response, error) {
|
func fetchSite(urlpath string, queries map[string]string) (string, *http.Request, *http.Response, error) {
|
||||||
u, err := url.Parse(urlQuery)
|
|
||||||
|
urlQuery := "?"
|
||||||
|
if len(queries) > 0 {
|
||||||
|
for k, v := range queries {
|
||||||
|
urlQuery += k + "=" + v + "&"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
urlQuery = strings.TrimSuffix(urlQuery, "&")
|
||||||
|
|
||||||
|
u, err := url.Parse(urlpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", nil, nil, err
|
return "", nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println(u.String())
|
log.Println(u.String() + urlQuery)
|
||||||
|
|
||||||
// Fetch the site
|
// Fetch the site
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
req, _ := http.NewRequest("GET", u.String(), nil)
|
req, _ := http.NewRequest("GET", u.String()+urlQuery, nil)
|
||||||
req.Header.Set("User-Agent", UserAgent)
|
req.Header.Set("User-Agent", UserAgent)
|
||||||
req.Header.Set("X-Forwarded-For", ForwardedFor)
|
req.Header.Set("X-Forwarded-For", ForwardedFor)
|
||||||
req.Header.Set("Referer", u.String())
|
req.Header.Set("Referer", u.String())
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ func Raw(c *fiber.Ctx) error {
|
|||||||
// Get the url from the URL
|
// Get the url from the URL
|
||||||
urlQuery := c.Params("*")
|
urlQuery := c.Params("*")
|
||||||
|
|
||||||
body, _, _, err := fetchSite(urlQuery)
|
queries := c.Queries()
|
||||||
|
body, _, _, err := fetchSite(urlQuery, queries)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("ERROR:", err)
|
log.Println("ERROR:", err)
|
||||||
c.SendStatus(500)
|
c.SendStatus(500)
|
||||||
|
|||||||
Reference in New Issue
Block a user