mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
pass a conn to qtls that returns the remote address
This commit is contained in:
parent
b2723d6d13
commit
da4b3e3176
4 changed files with 37 additions and 2 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"unsafe"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
|
@ -112,6 +113,7 @@ func NewCryptoSetupClient(
|
|||
handshakeStream io.Writer,
|
||||
oneRTTStream io.Writer,
|
||||
connID protocol.ConnectionID,
|
||||
remoteAddr net.Addr,
|
||||
tp *TransportParameters,
|
||||
handleParams func([]byte),
|
||||
tlsConf *tls.Config,
|
||||
|
@ -131,7 +133,7 @@ func NewCryptoSetupClient(
|
|||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
cs.conn = qtls.Client(nil, cs.tlsConf)
|
||||
cs.conn = qtls.Client(newConn(remoteAddr), cs.tlsConf)
|
||||
return cs, clientHelloWritten, nil
|
||||
}
|
||||
|
||||
|
@ -141,6 +143,7 @@ func NewCryptoSetupServer(
|
|||
handshakeStream io.Writer,
|
||||
oneRTTStream io.Writer,
|
||||
connID protocol.ConnectionID,
|
||||
remoteAddr net.Addr,
|
||||
tp *TransportParameters,
|
||||
handleParams func([]byte),
|
||||
tlsConf *tls.Config,
|
||||
|
@ -160,7 +163,7 @@ func NewCryptoSetupServer(
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cs.conn = qtls.Server(nil, cs.tlsConf)
|
||||
cs.conn = qtls.Server(newConn(remoteAddr), cs.tlsConf)
|
||||
return cs, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
|||
&bytes.Buffer{},
|
||||
ioutil.Discard,
|
||||
protocol.ConnectionID{},
|
||||
nil,
|
||||
&TransportParameters{},
|
||||
func([]byte) {},
|
||||
tlsConf,
|
||||
|
@ -111,6 +112,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
|||
sHandshakeStream,
|
||||
ioutil.Discard,
|
||||
protocol.ConnectionID{},
|
||||
nil,
|
||||
&TransportParameters{},
|
||||
func([]byte) {},
|
||||
testdata.GetTLSConfig(),
|
||||
|
@ -144,6 +146,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
|||
sHandshakeStream,
|
||||
ioutil.Discard,
|
||||
protocol.ConnectionID{},
|
||||
nil,
|
||||
&TransportParameters{},
|
||||
func([]byte) {},
|
||||
testdata.GetTLSConfig(),
|
||||
|
@ -171,6 +174,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
|||
sHandshakeStream,
|
||||
ioutil.Discard,
|
||||
protocol.ConnectionID{},
|
||||
nil,
|
||||
&TransportParameters{},
|
||||
func([]byte) {},
|
||||
testdata.GetTLSConfig(),
|
||||
|
@ -249,6 +253,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
|||
cHandshakeStream,
|
||||
ioutil.Discard,
|
||||
protocol.ConnectionID{},
|
||||
nil,
|
||||
&TransportParameters{},
|
||||
func([]byte) {},
|
||||
clientConf,
|
||||
|
@ -263,6 +268,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
|||
sHandshakeStream,
|
||||
ioutil.Discard,
|
||||
protocol.ConnectionID{},
|
||||
nil,
|
||||
&TransportParameters{StatelessResetToken: &token},
|
||||
func([]byte) {},
|
||||
serverConf,
|
||||
|
@ -304,6 +310,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
|||
cHandshakeStream,
|
||||
ioutil.Discard,
|
||||
protocol.ConnectionID{},
|
||||
nil,
|
||||
&TransportParameters{},
|
||||
func([]byte) {},
|
||||
&tls.Config{InsecureSkipVerify: true},
|
||||
|
@ -340,6 +347,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
|||
cHandshakeStream,
|
||||
ioutil.Discard,
|
||||
protocol.ConnectionID{},
|
||||
nil,
|
||||
cTransportParameters,
|
||||
func(p []byte) { sTransportParametersRcvd = p },
|
||||
clientConf,
|
||||
|
@ -358,6 +366,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
|||
sHandshakeStream,
|
||||
ioutil.Discard,
|
||||
protocol.ConnectionID{},
|
||||
nil,
|
||||
sTransportParameters,
|
||||
func(p []byte) { cTransportParametersRcvd = p },
|
||||
testdata.GetTLSConfig(),
|
||||
|
|
|
@ -2,11 +2,32 @@ package handshake
|
|||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"net"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/marten-seemann/qtls"
|
||||
)
|
||||
|
||||
type conn struct {
|
||||
remoteAddr net.Addr
|
||||
}
|
||||
|
||||
func newConn(remote net.Addr) net.Conn {
|
||||
return &conn{remoteAddr: remote}
|
||||
}
|
||||
|
||||
var _ net.Conn = &conn{}
|
||||
|
||||
func (c *conn) Read([]byte) (int, error) { return 0, nil }
|
||||
func (c *conn) Write([]byte) (int, error) { return 0, nil }
|
||||
func (c *conn) Close() error { return nil }
|
||||
func (c *conn) RemoteAddr() net.Addr { return c.remoteAddr }
|
||||
func (c *conn) LocalAddr() net.Addr { return nil }
|
||||
func (c *conn) SetReadDeadline(time.Time) error { return nil }
|
||||
func (c *conn) SetWriteDeadline(time.Time) error { return nil }
|
||||
func (c *conn) SetDeadline(time.Time) error { return nil }
|
||||
|
||||
type clientSessionCache struct {
|
||||
tls.ClientSessionCache
|
||||
}
|
||||
|
|
|
@ -196,6 +196,7 @@ var newSession = func(
|
|||
handshakeStream,
|
||||
oneRTTStream,
|
||||
clientDestConnID,
|
||||
conn.RemoteAddr(),
|
||||
params,
|
||||
s.processTransportParameters,
|
||||
tlsConf,
|
||||
|
@ -263,6 +264,7 @@ var newClientSession = func(
|
|||
handshakeStream,
|
||||
oneRTTStream,
|
||||
s.destConnID,
|
||||
conn.RemoteAddr(),
|
||||
params,
|
||||
s.processTransportParameters,
|
||||
tlsConf,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue