7
7
import io .vproxy .base .util .coll .RingQueue ;
8
8
import io .vproxy .msquic .*;
9
9
import io .vproxy .msquic .callback .ConnectionCallback ;
10
+ import io .vproxy .msquic .callback .ConnectionCallbackList ;
10
11
import io .vproxy .msquic .wrap .Connection ;
11
12
import io .vproxy .msquic .wrap .Listener ;
12
13
import io .vproxy .pni .Allocator ;
@@ -41,8 +42,15 @@ public static int createAccepted(NexusContext nctx, IPPort remote,
41
42
QuicConnection connQ , Listener listener , QuicListenerEventNewConnection data , Allocator allocator ) {
42
43
var peer = new NexusPeer (nctx , remote );
43
44
peer .isServer = true ;
44
- peer .quicConn = new Connection (new Connection .Options (listener , allocator , peer .new NexusNodeConnectionCallback (), connQ ));
45
+ ConnectionCallback cb = peer .new NexusNodeConnectionCallback ();
46
+ if (nctx .debug ) {
47
+ cb = ConnectionCallbackList .withLog (cb , true );
48
+ }
49
+ peer .quicConn = new Connection (new Connection .Options (listener , allocator , cb , connQ ));
45
50
peer .quicConn .setConnectionInfo (data );
51
+ if (nctx .debug ) {
52
+ peer .quicConn .enableTlsSecretDebug ();
53
+ }
46
54
connQ .setCallbackHandler (MsQuicUpcall .connectionCallback , peer .quicConn .ref .MEMORY );
47
55
var err = connQ .setConfiguration (nctx .serverConfiguration .opts .configurationQ );
48
56
if (err != 0 ) {
@@ -76,8 +84,11 @@ private void doConnect() {
76
84
Connection conn ;
77
85
try (var tmpAllocator = Allocator .ofConfined ()) {
78
86
var returnStatus = new IntArray (tmpAllocator , 1 );
79
- conn = new Connection (new Connection .Options (nctx .registration , allocator ,
80
- new NexusNodeConnectionCallback (),
87
+ ConnectionCallback cb = new NexusNodeConnectionCallback ();
88
+ if (nctx .debug ) {
89
+ cb = ConnectionCallbackList .withLog (cb , true );
90
+ }
91
+ conn = new Connection (new Connection .Options (nctx .registration , allocator , cb ,
81
92
ref -> nctx .registration .opts .registrationQ .openConnection (
82
93
MsQuicUpcall .connectionCallback , ref .MEMORY , returnStatus , allocator
83
94
)));
@@ -87,6 +98,9 @@ private void doConnect() {
87
98
return ;
88
99
}
89
100
}
101
+ if (nctx .debug ) {
102
+ conn .enableTlsSecretDebug ();
103
+ }
90
104
int errcode = conn .start (nctx .clientConfiguration , remoteAddress );
91
105
if (errcode != 0 ) {
92
106
Logger .error (LogType .CONN_ERROR , "starting quic connection to " + remoteAddress + " failed, errcode=" + errcode );
@@ -180,7 +194,7 @@ private void initializeServerActiveControlStream() {
180
194
}
181
195
QuicSocketFD fd ;
182
196
try {
183
- fd = QuicSocketFD .newStream (quicConn );
197
+ fd = QuicSocketFD .newStream (nctx . debug , quicConn );
184
198
} catch (IOException e ) {
185
199
Logger .error (LogType .CONN_ERROR , "failed to initiate quic stream to " + quicConn .getRemoteAddress (), e );
186
200
terminate (quicConn , "failed to initiate quic stream" );
@@ -200,7 +214,7 @@ public int connected(Connection conn, QuicConnectionEventConnected data) {
200
214
nctx .loop .getSelectorEventLoop ().nextTick (() -> {
201
215
QuicSocketFD fd ;
202
216
try {
203
- fd = QuicSocketFD .newStream (conn );
217
+ fd = QuicSocketFD .newStream (nctx . debug , conn );
204
218
} catch (IOException e ) {
205
219
Logger .error (LogType .SOCKET_ERROR , "failed to create stream from " + conn , e );
206
220
conn .close ();
@@ -219,7 +233,7 @@ public int shutdownComplete(Connection conn, QuicConnectionEventConnectionShutdo
219
233
220
234
@ Override
221
235
public int peerStreamStarted (Connection conn , QuicConnectionEventPeerStreamStarted data ) {
222
- var fd = QuicSocketFD .wrapAcceptedStream (conn , data .getStream ());
236
+ var fd = QuicSocketFD .wrapAcceptedStream (nctx . debug , conn , data .getStream ());
223
237
if (isInitialized ) {
224
238
StreamHandlers .INSTANCE .handleAccepted (nctx , NexusPeer .this , fd );
225
239
} else if (isServer ) {
0 commit comments