mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
proxy: support server mode of PROXY protocol v1
This commit is contained in:
1 parent
32e1c37cfe
commit
7486373821
15 files changed
+173
-37
No files matched your search
@@ -3,7 +3,7 @@ package http
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/textproto"
|
||||
"net/url"
|
||||
"strings"
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
// Methods are http methods from rfc.
|
||||
// https://www.ietf.org/rfc/rfc2616.txt, http methods must be uppercase
|
||||
// https://www.rfc-editor.org/rfc/rfc2616, http methods must be uppercase
|
||||
var Methods = [...][]byte{
|
||||
[]byte("GET"),
|
||||
[]byte("POST"),
|
||||
@@ -46,7 +46,7 @@ func parseRequest(r *bufio.Reader) (*request, error) {
|
||||
|
||||
method, uri, proto, ok := parseStartLine(line)
|
||||
if !ok {
|
||||
return nil, errors.New("error in parseStartLine")
|
||||
return nil, fmt.Errorf("error in parseStartLine: %s", line)
|
||||
}
|
||||
|
||||
header, err := tpr.ReadMIMEHeader()
|
||||
|
||||
@@ -51,7 +51,7 @@ func (s *HTTP) Serve(cc net.Conn) {
|
||||
c := proxy.NewConn(cc)
|
||||
req, err := parseRequest(c.Reader())
|
||||
if err != nil {
|
||||
log.F("[http] can not parse request from %s", c.RemoteAddr())
|
||||
log.F("[http] can not parse request from %s, error: %v", c.RemoteAddr(), err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user