fix import orders

This commit is contained in:
Damian Bednarczyk
2023-11-29 15:02:05 -06:00
parent 3fdbf3524d
commit dc558b38fa
9 changed files with 19 additions and 14 deletions

View File

@@ -1,9 +1,9 @@
package requestmodifers package requestmodifers
import ( import (
"strings"
//"fmt" //"fmt"
"ladder/proxychain" "ladder/proxychain"
"strings"
) )
var forwardBlacklist map[string]bool var forwardBlacklist map[string]bool
@@ -27,7 +27,6 @@ func init() {
// ForwardRequestHeaders forwards the requests headers sent from the client to the upstream server // ForwardRequestHeaders forwards the requests headers sent from the client to the upstream server
func ForwardRequestHeaders() proxychain.RequestModification { func ForwardRequestHeaders() proxychain.RequestModification {
return func(chain *proxychain.ProxyChain) error { return func(chain *proxychain.ProxyChain) error {
forwardHeaders := func(key, value []byte) { forwardHeaders := func(key, value []byte) {
k := strings.ToLower(string(key)) k := strings.ToLower(string(key))
v := string(value) v := string(value)

View File

@@ -3,10 +3,10 @@ package requestmodifers
import ( import (
"fmt" "fmt"
"net/url" "net/url"
"regexp"
"ladder/proxychain" "ladder/proxychain"
tx "ladder/proxychain/responsemodifers" tx "ladder/proxychain/responsemodifers"
"regexp"
) )
const archivistUrl string = "https://archive.is/latest" const archivistUrl string = "https://archive.is/latest"

View File

@@ -2,10 +2,10 @@ package requestmodifers
import ( import (
"net/url" "net/url"
"regexp"
"ladder/proxychain" "ladder/proxychain"
tx "ladder/proxychain/responsemodifers" tx "ladder/proxychain/responsemodifers"
"regexp"
) )
const waybackUrl string = "https://web.archive.org/web/" const waybackUrl string = "https://web.archive.org/web/"

View File

@@ -4,15 +4,16 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
http "github.com/bogdanfinn/fhttp"
"net" "net"
"time"
http "github.com/bogdanfinn/fhttp"
/* /*
tls_client "github.com/bogdanfinn/tls-client" tls_client "github.com/bogdanfinn/tls-client"
//"net/http" //"net/http"
*/ */
"time"
"ladder/proxychain" "ladder/proxychain"
) )
@@ -71,7 +72,6 @@ func (cd *CustomDialer) DialContext(ctx context.Context, network, addr string) (
// ResolveWithGoogleDoH modifies a ProxyChain's client to make the request by resolving the URL // ResolveWithGoogleDoH modifies a ProxyChain's client to make the request by resolving the URL
// using Google's DNS over HTTPs service // using Google's DNS over HTTPs service
func ResolveWithGoogleDoH() proxychain.RequestModification { func ResolveWithGoogleDoH() proxychain.RequestModification {
///customDialer := NewCustomDialer(10*time.Second, 10*time.Second) ///customDialer := NewCustomDialer(10*time.Second, 10*time.Second)
return func(chain *proxychain.ProxyChain) error { return func(chain *proxychain.ProxyChain) error {
/* /*

View File

@@ -2,6 +2,7 @@ package requestmodifers
import ( import (
"fmt" "fmt"
"ladder/proxychain" "ladder/proxychain"
tx "ladder/proxychain/responsemodifers" tx "ladder/proxychain/responsemodifers"
) )
@@ -12,7 +13,6 @@ import (
// if url is "", then the referrer header is removed. // if url is "", then the referrer header is removed.
func SpoofReferrer(url string) proxychain.RequestModification { func SpoofReferrer(url string) proxychain.RequestModification {
return func(chain *proxychain.ProxyChain) error { return func(chain *proxychain.ProxyChain) error {
// change refer on client side js // change refer on client side js
script := fmt.Sprintf(`document.referrer = "%s"`, url) script := fmt.Sprintf(`document.referrer = "%s"`, url)
chain.AddOnceResponseModifications( chain.AddOnceResponseModifications(

View File

@@ -2,9 +2,10 @@ package requestmodifers
import ( import (
_ "embed" _ "embed"
"strings"
"ladder/proxychain" "ladder/proxychain"
tx "ladder/proxychain/responsemodifers" tx "ladder/proxychain/responsemodifers"
"strings"
) )
// https://github.com/faisalman/ua-parser-js/tree/master // https://github.com/faisalman/ua-parser-js/tree/master

View File

@@ -2,9 +2,10 @@ package responsemodifers
import ( import (
"fmt" "fmt"
"ladder/proxychain"
"net/url" "net/url"
"strings" "strings"
"ladder/proxychain"
) )
var forwardBlacklist map[string]bool var forwardBlacklist map[string]bool
@@ -23,7 +24,6 @@ func init() {
// ForwardResponseHeaders forwards the response headers from the upstream server to the client // ForwardResponseHeaders forwards the response headers from the upstream server to the client
func ForwardResponseHeaders() proxychain.ResponseModification { func ForwardResponseHeaders() proxychain.ResponseModification {
return func(chain *proxychain.ProxyChain) error { return func(chain *proxychain.ProxyChain) error {
//fmt.Println(chain.Response.Header) //fmt.Println(chain.Response.Header)
for uname, headers := range chain.Response.Header { for uname, headers := range chain.Response.Header {
name := strings.ToLower(uname) name := strings.ToLower(uname)

View File

@@ -3,10 +3,12 @@ package responsemodifers
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"io"
//"github.com/go-shiori/dom" //"github.com/go-shiori/dom"
"github.com/markusmobius/go-trafilatura" "github.com/markusmobius/go-trafilatura"
//"golang.org/x/net/html" //"golang.org/x/net/html"
"io"
"ladder/proxychain" "ladder/proxychain"
"ladder/proxychain/responsemodifers/api" "ladder/proxychain/responsemodifers/api"
) )
@@ -46,5 +48,4 @@ func APIOutline() proxychain.ResponseModification {
chain.Response.Body = io.NopCloser(buf) chain.Response.Body = io.NopCloser(buf)
return nil return nil
} }
} }

View File

@@ -66,6 +66,7 @@ func (r *HTMLRewriter) Close() error {
r.tokenBuffer.Reset() r.tokenBuffer.Reset()
r.currentToken = nil r.currentToken = nil
r.currentTokenProcessed = false r.currentTokenProcessed = false
return nil return nil
} }
@@ -79,6 +80,7 @@ func (r *HTMLRewriter) Read(p []byte) (int, error) {
if r.tokenizer.Err() == io.EOF { if r.tokenizer.Err() == io.EOF {
return 0, io.EOF return 0, io.EOF
} }
return 0, r.tokenizer.Err() return 0, r.tokenizer.Err()
} }
@@ -96,6 +98,7 @@ func (r *HTMLRewriter) Read(p []byte) (int, error) {
if !rewriter.ShouldModify(r.currentToken) { if !rewriter.ShouldModify(r.currentToken) {
continue continue
} }
prepend, a := rewriter.ModifyToken(r.currentToken) prepend, a := rewriter.ModifyToken(r.currentToken)
appends = append(appends, a) appends = append(appends, a)
// add <prepends> to buffer // add <prepends> to buffer
@@ -125,5 +128,6 @@ func (r *HTMLRewriter) Read(p []byte) (int, error) {
r.currentTokenProcessed = true r.currentTokenProcessed = true
err = nil // EOF in this context is expected and not an actual error err = nil // EOF in this context is expected and not an actual error
} }
return n, err return n, err
} }