mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
fix: remove trailing null byte for local connection (#11295)
Fixes #633 I have written end-to-end tests against HAProxy in https://code.forgejo.org/forgejo/end-to-end/pulls/1578 and also written unit tests. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11295 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: famfo <famfo@famfo.xyz> Co-committed-by: famfo <famfo@famfo.xyz>
This commit is contained in:
parent
cf17b5fad9
commit
9767cebc42
5 changed files with 116 additions and 7 deletions
|
|
@ -15,6 +15,7 @@ import (
|
|||
"time"
|
||||
|
||||
"forgejo.org/modules/log"
|
||||
"forgejo.org/modules/setting"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -46,6 +47,7 @@ func NewConn(conn net.Conn, timeout time.Duration) *Conn {
|
|||
bufReader: bufio.NewReader(conn),
|
||||
conn: conn,
|
||||
proxyHeaderTimeout: timeout,
|
||||
acceptUnknown: setting.ProxyProtocolAcceptUnknown,
|
||||
}
|
||||
return pConn
|
||||
}
|
||||
|
|
@ -456,7 +458,7 @@ func (p *Conn) readV1ProxyHeader() error {
|
|||
// Verify the type is known
|
||||
switch parts[1] {
|
||||
case "UNKNOWN":
|
||||
if !p.acceptUnknown || len(parts) != 2 {
|
||||
if !p.acceptUnknown {
|
||||
p.conn.Close()
|
||||
return &ErrBadHeader{[]byte(header)}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue