1
0
Fork 0

Use h2c from x/net to handle h2c requests

Co-authored-by: Mathieu Lonjaret <mathieu.lonjaret@gmail.com>
This commit is contained in:
Julien Salleyron 2019-07-01 15:08:04 +02:00 committed by Traefiker Bot
parent c7d336f958
commit 4360ca14c1
224 changed files with 22414 additions and 11768 deletions

View file

@ -2,14 +2,11 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build go1.9
package ipv4
import (
"net"
"runtime"
"syscall"
"golang.org/x/net/internal/socket"
)
@ -76,7 +73,7 @@ type Message = socket.Message
// headers.
func (c *payloadHandler) ReadBatch(ms []Message, flags int) (int, error) {
if !c.ok() {
return 0, syscall.EINVAL
return 0, errInvalidConn
}
switch runtime.GOOS {
case "linux":
@ -92,6 +89,9 @@ func (c *payloadHandler) ReadBatch(ms []Message, flags int) (int, error) {
n = 0
err = &net.OpError{Op: "read", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Err: err}
}
if compatFreeBSD32 && ms[0].NN > 0 {
adjustFreeBSD32(&ms[0])
}
return n, err
}
}
@ -107,7 +107,7 @@ func (c *payloadHandler) ReadBatch(ms []Message, flags int) (int, error) {
// On other platforms, this method will write only a single message.
func (c *payloadHandler) WriteBatch(ms []Message, flags int) (int, error) {
if !c.ok() {
return 0, syscall.EINVAL
return 0, errInvalidConn
}
switch runtime.GOOS {
case "linux":
@ -139,7 +139,7 @@ func (c *payloadHandler) WriteBatch(ms []Message, flags int) (int, error) {
// On other platforms, this method will read only a single message.
func (c *packetHandler) ReadBatch(ms []Message, flags int) (int, error) {
if !c.ok() {
return 0, syscall.EINVAL
return 0, errInvalidConn
}
switch runtime.GOOS {
case "linux":
@ -155,6 +155,9 @@ func (c *packetHandler) ReadBatch(ms []Message, flags int) (int, error) {
n = 0
err = &net.OpError{Op: "read", Net: c.IPConn.LocalAddr().Network(), Source: c.IPConn.LocalAddr(), Err: err}
}
if compatFreeBSD32 && ms[0].NN > 0 {
adjustFreeBSD32(&ms[0])
}
return n, err
}
}
@ -170,7 +173,7 @@ func (c *packetHandler) ReadBatch(ms []Message, flags int) (int, error) {
// On other platforms, this method will write only a single message.
func (c *packetHandler) WriteBatch(ms []Message, flags int) (int, error) {
if !c.ok() {
return 0, syscall.EINVAL
return 0, errInvalidConn
}
switch runtime.GOOS {
case "linux":