Skip to content

Commit

Permalink
Add more dummy headers
Browse files Browse the repository at this point in the history
  • Loading branch information
coyove committed Sep 3, 2017
1 parent 592b196 commit 390847d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func main() {
logg.W("[WARNING] you are using the default username and password (-u user and -p pass)")
}

G_Cache, G_RequestDummies = lru.NewCache(*G_DNSCacheEntries), lru.NewCache(2)
G_Cache, G_RequestDummies = lru.NewCache(*G_DNSCacheEntries), lru.NewCache(6)

if *G_ProxyChina {
buf, _ := ioutil.ReadFile("./chinalist.txt")
Expand Down
4 changes: 3 additions & 1 deletion proxy/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ func (proxy *ProxyHttpServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
payload := fmt.Sprintf("GET / HTTP/1.1\r\nHost: %s\r\n%s: %s\r\n", host, rkeyHeader, rkey)

G_RequestDummies.Info(func(k lru.Key, v interface{}, h int64) {
payload += k.(string) + ": " + v.(string) + "\r\n"
if v.(string) != "" {
payload += k.(string) + ": " + v.(string) + "\r\n"
}
})

upstreamConn.Write([]byte(payload + "\r\n"))
Expand Down
14 changes: 12 additions & 2 deletions proxy/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,18 @@ func ReverseRandomKey(key string) []byte {
func processBody(req *http.Request, enc bool) {
var rkey string
if enc {
G_RequestDummies.Add("Accept-Language", req.Header.Get("Accept-Language"))
G_RequestDummies.Add("User-Agent", req.Header.Get("User-Agent"))
add := func(field string) {
if x := req.Header.Get(field); x != "" {
G_RequestDummies.Add(field, x)
}
}

add("Accept-Language")
add("User-Agent")
add("Referer")
add("Cache-Control")
add("Accept-Encoding")
add("Connection")

rkey = RandomKey()
SafeAddHeader(req, rkeyHeader2, rkey)
Expand Down

0 comments on commit 390847d

Please sign in to comment.