@@ -129,11 +129,16 @@ const (
129
129
type Node struct {
130
130
Name string
131
131
P2P , GRPC_PUB , GRPC_PRIV uint16
132
+ QUIC bool
132
133
}
133
134
134
135
// P2PEndpoint returns full p2p endpoint, including identity.
135
136
func p2pEndpoint (n Node , ip , id string ) string {
136
- return fmt .Sprintf ("/ip4/%s/tcp/%d/p2p/%s" , ip , n .P2P , id )
137
+ if n .QUIC {
138
+ return fmt .Sprintf ("/ip4/%s/udp/%d/quic-v1/p2p/%s" , ip , n .P2P , id )
139
+ } else {
140
+ return fmt .Sprintf ("/ip4/%s/tcp/%d/p2p/%s" , ip , n .P2P , id )
141
+ }
137
142
}
138
143
139
144
// NodeClient is a Node with attached grpc connection.
@@ -368,14 +373,21 @@ func deployPoetD(ctx *testcontext.Context, id string, flags ...DeploymentFlag) (
368
373
369
374
func deployBootnodeSvc (ctx * testcontext.Context , id string ) error {
370
375
labels := nodeLabels (bootnodeApp , id )
376
+ p2pProto := apiv1 .ProtocolTCP
377
+ if ctx .QUIC {
378
+ p2pProto = apiv1 .ProtocolUDP
379
+ }
371
380
svc := corev1 .Service (id , ctx .Namespace ).
372
381
WithLabels (labels ).
373
382
WithSpec (corev1 .ServiceSpec ().
374
383
WithSelector (labels ).
375
384
WithPorts (
376
- corev1 .ServicePort ().WithName ("grpc-pub" ).WithPort (9092 ).WithProtocol ("TCP" ),
377
- corev1 .ServicePort ().WithName ("grpc-priv" ).WithPort (9093 ).WithProtocol ("TCP" ),
378
- corev1 .ServicePort ().WithName ("p2p" ).WithPort (7513 ).WithProtocol ("TCP" ),
385
+ corev1 .ServicePort ().WithName ("grpc-pub" ).WithPort (9092 ).
386
+ WithProtocol (apiv1 .ProtocolTCP ),
387
+ corev1 .ServicePort ().WithName ("grpc-priv" ).WithPort (9093 ).
388
+ WithProtocol (apiv1 .ProtocolTCP ),
389
+ corev1 .ServicePort ().WithName ("p2p" ).WithPort (7513 ).
390
+ WithProtocol (p2pProto ),
379
391
).
380
392
WithClusterIP ("None" ),
381
393
)
@@ -388,15 +400,23 @@ func deployBootnodeSvc(ctx *testcontext.Context, id string) error {
388
400
389
401
func deployNodeSvc (ctx * testcontext.Context , id string ) error {
390
402
labels := nodeLabels (smesherApp , id )
403
+ p2pProto := apiv1 .ProtocolTCP
404
+ if ctx .QUIC {
405
+ p2pProto = apiv1 .ProtocolUDP
406
+ }
391
407
svc := corev1 .Service (id , ctx .Namespace ).
392
408
WithLabels (labels ).
393
409
WithSpec (corev1 .ServiceSpec ().
394
410
WithSelector (labels ).
395
411
WithPorts (
396
- corev1 .ServicePort ().WithName ("p2p" ).WithPort (7513 ).WithProtocol ("TCP" ),
397
- corev1 .ServicePort ().WithName ("grpc-pub" ).WithPort (9092 ).WithProtocol ("TCP" ),
398
- corev1 .ServicePort ().WithName ("grpc-priv" ).WithPort (9093 ).WithProtocol ("TCP" ),
399
- corev1 .ServicePort ().WithName ("grpc-post" ).WithPort (9094 ).WithProtocol ("TCP" ),
412
+ corev1 .ServicePort ().WithName ("p2p" ).WithPort (7513 ).
413
+ WithProtocol (p2pProto ),
414
+ corev1 .ServicePort ().WithName ("grpc-pub" ).WithPort (9092 ).
415
+ WithProtocol (apiv1 .ProtocolTCP ),
416
+ corev1 .ServicePort ().WithName ("grpc-priv" ).WithPort (9093 ).
417
+ WithProtocol (apiv1 .ProtocolTCP ),
418
+ corev1 .ServicePort ().WithName ("grpc-post" ).WithPort (9094 ).
419
+ WithProtocol (apiv1 .ProtocolTCP ),
400
420
).
401
421
WithClusterIP ("None" ),
402
422
)
@@ -581,6 +601,7 @@ func deployNodes(ctx *testcontext.Context, kind string, from, to int, opts ...De
581
601
P2P : 7513 ,
582
602
GRPC_PUB : 9092 ,
583
603
GRPC_PRIV : 9093 ,
604
+ QUIC : ctx .QUIC ,
584
605
},
585
606
}
586
607
return nil
@@ -654,6 +675,7 @@ func deployRemoteNodes(ctx *testcontext.Context, from, to int,
654
675
P2P : 7513 ,
655
676
GRPC_PUB : 9092 ,
656
677
GRPC_PRIV : 9093 ,
678
+ QUIC : ctx .QUIC ,
657
679
},
658
680
}
659
681
return nil
@@ -726,6 +748,15 @@ func deployNode(ctx *testcontext.Context, id string, labels map[string]string, f
726
748
for _ , flag := range flags {
727
749
cmd = append (cmd , flag .Flag ())
728
750
}
751
+ p2pProto := apiv1 .ProtocolTCP
752
+ if ctx .QUIC {
753
+ p2pProto = apiv1 .ProtocolUDP
754
+ cmd = append (cmd ,
755
+ "--listen" , "/ip4/0.0.0.0/udp/7513/quic-v1" ,
756
+ "--enable-tcp-transport=false" ,
757
+ "--enable-quic-transport=true" ,
758
+ )
759
+ }
729
760
deployment := appsv1 .Deployment (id , ctx .Namespace ).
730
761
WithLabels (labels ).
731
762
WithSpec (appsv1 .DeploymentSpec ().
@@ -757,7 +788,7 @@ func deployNode(ctx *testcontext.Context, id string, labels map[string]string, f
757
788
WithImage (ctx .Image ).
758
789
WithImagePullPolicy (apiv1 .PullIfNotPresent ).
759
790
WithPorts (
760
- corev1 .ContainerPort ().WithContainerPort (7513 ).WithName ("p2p" ),
791
+ corev1 .ContainerPort ().WithContainerPort (7513 ).WithName ("p2p" ). WithProtocol ( p2pProto ) ,
761
792
corev1 .ContainerPort ().WithContainerPort (9092 ).WithName ("grpc-pub" ),
762
793
corev1 .ContainerPort ().WithContainerPort (9093 ).WithName ("grpc-priv" ),
763
794
corev1 .ContainerPort ().WithContainerPort (9094 ).WithName ("grpc-post" ),
0 commit comments