@@ -34,31 +34,35 @@ pub struct Common {
3434 login_fail_exit : bool ,
3535 protocol : String ,
3636 tls_enable : bool ,
37- tls_cert_file : String ,
38- tls_key_file : String ,
39- tls_trusted_ca_file : String ,
40- tls_server_name : String ,
41- dns_server : IpAddr ,
42- start : String ,
37+ tls_cert_file : Option < String > ,
38+ tls_key_file : Option < String > ,
39+ tls_trusted_ca_file : Option < String > ,
40+ tls_server_name : Option < String > ,
41+ dns_server : Option < IpAddr > ,
42+ start : Option < String > ,
4343 heartbeat_interval : u8 ,
4444 heartbeat_timeout : u8 ,
45- metas : Vec < String > ,
45+ metas : Option < Vec < String > > ,
4646 udp_packet_size : u16 ,
47- include_conf_files : Vec < String > ,
47+ include_conf_files : Option < Vec < String > > ,
4848}
4949
50+ #[ derive( Debug , Deserialize , Serialize ) ]
5051pub struct Config {
5152 common : Common ,
5253}
5354
5455
5556impl Config {
56- pub fn new ( cnf_file : & Path ) {
57+ pub fn new ( cnf_file : & Path ) -> Config {
5758 let def_str = include_str ! ( "../frpc_full.ini" ) ;
5859 let mut def_cnf = config:: Config :: default ( ) ;
5960 def_cnf
6061 . merge ( config:: File :: from_str ( def_str, config:: FileFormat :: Ini ) ) . unwrap ( )
6162 . merge ( config:: File :: from ( cnf_file) ) . unwrap ( ) ;
62- dbg ! ( def_cnf. get:: <HashMap <String , String >>( "common" ) . unwrap( ) ) ;
63+
64+ Config {
65+ common : def_cnf. get :: < Common > ( "common" ) . unwrap ( )
66+ }
6367 }
6468}
0 commit comments