20
20
#include " node_quic_util-inl.h"
21
21
#include " node_quic_default_application.h"
22
22
#include " node_quic_http3_application.h"
23
+ #include " node_sockaddr-inl.h"
23
24
#include " v8.h"
24
25
#include " uv.h"
25
26
@@ -1348,7 +1349,7 @@ void QuicSession::PathValidation(
1348
1349
Debug (this ,
1349
1350
" Path validation succeeded. Updating local and remote addresses" );
1350
1351
SetLocalAddress (&path->local );
1351
- remote_address_.Update (& path->remote );
1352
+ remote_address_.Update (path->remote . addr , path-> remote . addrlen );
1352
1353
IncrementStat (
1353
1354
1 , &session_stats_,
1354
1355
&session_stats::path_validation_success_count);
@@ -1466,7 +1467,7 @@ bool QuicSession::Receive(
1466
1467
// It's possible for the remote address to change from one
1467
1468
// packet to the next so we have to look at the addr on
1468
1469
// every packet.
1469
- remote_address_. Copy ( addr) ;
1470
+ remote_address_ = addr;
1470
1471
QuicPath path (Socket ()->GetLocalAddress (), &remote_address_);
1471
1472
1472
1473
{
@@ -1765,7 +1766,7 @@ bool QuicSession::SelectPreferredAddress(
1765
1766
SocketAddress* local_address = Socket ()->GetLocalAddress ();
1766
1767
uv_getaddrinfo_t req;
1767
1768
1768
- if (!SocketAddress:: ResolvePreferredAddress (
1769
+ if (!ResolvePreferredAddress (
1769
1770
env (), local_address->GetFamily (),
1770
1771
paddr, &req)) {
1771
1772
return false ;
@@ -1791,7 +1792,7 @@ bool QuicSession::SendPacket(
1791
1792
ngtcp2_path_storage* path) {
1792
1793
sendbuf_.Push (std::move (buf));
1793
1794
// TODO(@jasnell): Update the local endpoint also?
1794
- remote_address_.Update (& path->path .remote );
1795
+ remote_address_.Update (path->path .remote . addr , path-> path . remote . addrlen );
1795
1796
return SendPacket (" stream data" );
1796
1797
}
1797
1798
@@ -1986,7 +1987,8 @@ bool QuicSession::SetSocket(QuicSocket* socket, bool nat_rebinding) {
1986
1987
// Step 4: Update ngtcp2
1987
1988
SocketAddress* local_address = socket->GetLocalAddress ();
1988
1989
if (nat_rebinding) {
1989
- ngtcp2_addr addr = local_address->ToAddr ();
1990
+ ngtcp2_addr addr;
1991
+ ToNgtcp2Addr (local_address, &addr);
1990
1992
ngtcp2_conn_set_local_addr (Connection (), &addr);
1991
1993
} else {
1992
1994
QuicPath path (local_address, &remote_address_);
@@ -2274,7 +2276,7 @@ bool QuicSession::WritePackets(const char* diagnostic_label) {
2274
2276
}
2275
2277
2276
2278
data.Realloc (nwrite);
2277
- remote_address_.Update (& path.path .remote );
2279
+ remote_address_.Update (path.path .remote . addr , path. path . remote . addrlen );
2278
2280
sendbuf_.Push (std::move (data));
2279
2281
if (!SendPacket (diagnostic_label))
2280
2282
return false ;
@@ -2400,8 +2402,8 @@ void QuicSession::InitServer(
2400
2402
ExtendMaxStreamsBidi (DEFAULT_MAX_STREAMS_BIDI);
2401
2403
ExtendMaxStreamsUni (DEFAULT_MAX_STREAMS_UNI);
2402
2404
2403
- remote_address_. Copy ( addr) ;
2404
- max_pktlen_ = SocketAddress:: GetMaxPktLen (addr);
2405
+ remote_address_ = addr;
2406
+ max_pktlen_ = GetMaxPktLen (addr);
2405
2407
2406
2408
config->SetOriginalConnectionID (ocid);
2407
2409
config->GenerateStatelessResetToken ();
@@ -2512,8 +2514,8 @@ bool QuicSession::InitClient(
2512
2514
QlogMode qlog) {
2513
2515
CHECK_NULL (connection_);
2514
2516
2515
- remote_address_. Copy ( addr) ;
2516
- max_pktlen_ = SocketAddress:: GetMaxPktLen (addr);
2517
+ remote_address_ = addr;
2518
+ max_pktlen_ = GetMaxPktLen (addr);
2517
2519
2518
2520
QuicSessionConfig config (env ());
2519
2521
max_crypto_buffer_ = config.GetMaxCryptoBuffer ();
@@ -3073,7 +3075,7 @@ void QuicSessionGetRemoteAddress(
3073
3075
Environment* env = session->env ();
3074
3076
CHECK (args[0 ]->IsObject ());
3075
3077
args.GetReturnValue ().Set (
3076
- AddressToJS (env, ** session->GetRemoteAddress (), args[0 ].As <Object>()));
3078
+ session->GetRemoteAddress ()-> ToJS (env , args[0 ].As <Object>()));
3077
3079
}
3078
3080
3079
3081
void QuicSessionGetCertificate (
@@ -3131,9 +3133,8 @@ void NewQuicClientSession(const FunctionCallbackInfo<Value>& args) {
3131
3133
std::string hostname (*servername);
3132
3134
3133
3135
sockaddr_storage addr;
3134
- int err = SocketAddress::ToSockAddr (family, *address, port, &addr);
3135
- if (err != 0 )
3136
- return args.GetReturnValue ().Set (err);
3136
+ if (SocketAddress::ToSockAddr (family, *address, port, &addr) == nullptr )
3137
+ return args.GetReturnValue ().Set (-1 );
3137
3138
3138
3139
int select_preferred_address_policy = QUIC_PREFERRED_ADDRESS_IGNORE;
3139
3140
if (!args[10 ]->Int32Value (env->context ())
0 commit comments