Skip to content

Commit

Permalink
Fix string
Browse files Browse the repository at this point in the history
  • Loading branch information
coyove committed Jan 9, 2020
1 parent f87d09d commit 59cbff5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cmd/goflyway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func (c *connector) getFingerprint(r *http.Request) string {
}

func (c *connector) ServeHTTP(w http.ResponseWriter, r *http.Request) {
plain := false
plain, iscurl := false, false
pp := func() {
path := r.URL.Path
if !strings.HasPrefix(path, "/") {
Expand Down Expand Up @@ -336,7 +336,7 @@ func (c *connector) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
pa, err := base64.StdEncoding.DecodeString(strings.TrimSpace(authData))
if err == nil && bytes.ContainsRune(pa, ':') {
if string(pa[bytes.IndexByte(pa, ':')+1]) == c.auth {
if string(pa[bytes.IndexByte(pa, ':')+1:]) == c.auth {
goto OK
}
}
Expand Down Expand Up @@ -366,6 +366,8 @@ func (c *connector) ServeHTTP(w http.ResponseWriter, r *http.Request) {
c.book.Add(ip, "white", 0)
c.book.Add(c.getFingerprint(r), ip, 0)
c.mu.Unlock()

iscurl = strings.Contains(strings.ToLower(r.UserAgent()), "curl/")
}

if plain {
Expand Down Expand Up @@ -407,7 +409,11 @@ func (c *connector) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}

proxyClient.Write([]byte("HTTP/1.0 200 Connection Established\r\n"))
if iscurl {
proxyClient.Write([]byte("HTTP/1.1 200 OK\r\n"))
} else {
proxyClient.Write([]byte("HTTP/1.0 200 Connection Established\r\n"))
}
proxyClient.Write([]byte("Filler: "))
for i := 0; i < rand.Intn(100)+300; i++ {
proxyClient.Write([]byte("aaaaaaaa"))
Expand Down

0 comments on commit 59cbff5

Please sign in to comment.