File tree 2 files changed +26
-5
lines changed 2 files changed +26
-5
lines changed Original file line number Diff line number Diff line change 4
4
#![ allow( unused) ]
5
5
6
6
pub ( crate ) use clap:: Parser ;
7
+ use std:: net:: SocketAddr ;
7
8
use tracing:: debug;
8
9
9
10
#[ derive( Parser ) ]
@@ -30,7 +31,16 @@ pub(crate) struct CmdArgs {
30
31
driver : Option < String > ,
31
32
#[ arg( long, value_name = "name of kernel interface" ) ]
32
33
interface : Vec < String > ,
34
+
35
+ // gRPC server address
36
+ #[ arg(
37
+ long,
38
+ value_name = "gRPC server address" ,
39
+ default_value = "[::1]:50051"
40
+ ) ]
41
+ grpc_address : String ,
33
42
}
43
+
34
44
impl CmdArgs {
35
45
pub fn get_driver_name ( & self ) -> & str {
36
46
match & self . driver {
@@ -92,4 +102,15 @@ impl CmdArgs {
92
102
93
103
out
94
104
}
105
+
106
+ /// Get the gRPC server address
107
+ pub fn get_grpc_address ( & self ) -> SocketAddr {
108
+ match self . grpc_address . parse ( ) {
109
+ Ok ( addr) => addr,
110
+ Err ( e) => {
111
+ eprintln ! ( "Error: Invalid gRPC address '{}': {}" , self . grpc_address, e) ;
112
+ panic ! ( "Process receives unexpected gRPC address. Aborting..." ) ;
113
+ }
114
+ }
115
+ }
95
116
}
Original file line number Diff line number Diff line change @@ -61,11 +61,11 @@ fn main() {
61
61
/* parse cmd line args */
62
62
let args = CmdArgs :: parse ( ) ;
63
63
64
- let grpc_address = "[::1]:50051" . parse ( ) . expect ( "Bad grpc address" ) ;
65
-
66
- if let Err ( e) = start_mgmt ( grpc_address ) {
64
+ // Get the gRPC address from command line args
65
+ let grpc_addr = args . get_grpc_address ( ) ;
66
+ if let Err ( e) = start_mgmt ( grpc_addr ) {
67
67
error ! ( "Failed to start management service: {e}" ) ;
68
- std :: process :: exit ( 0 ) ;
68
+ panic ! ( "Management service failed to start. Aborting..." ) ;
69
69
}
70
70
71
71
debug ! ( "Starting pipeline...." ) ;
@@ -82,7 +82,7 @@ fn main() {
82
82
}
83
83
other => {
84
84
error ! ( "Unknown driver '{other}'. Aborting..." ) ;
85
- std :: process :: exit ( 0 ) ;
85
+ panic ! ( "Packet processing pipeline failed to start. Aborting..." ) ;
86
86
}
87
87
}
88
88
You can’t perform that action at this time.
0 commit comments