File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed
Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use std::process::Command;
55
66use anyhow:: { anyhow, bail, Context } ;
77use cidr_utils:: cidr:: IpCidr ;
8+ use std:: fs:: Path ;
89use std:: thread:: sleep;
910use std:: time:: Duration ;
1011use version_compare:: Version ;
@@ -127,10 +128,10 @@ impl AdapterDevice {
127128 }
128129}
129130
130- pub fn init_device (
131+ pub fn init_device < T : AsRef < Path > > (
131132 device_guid : & GUID ,
132133 name : & str ,
133- inf_path : & str ,
134+ inf_path : T ,
134135) -> anyhow:: Result < AdapterDevice > {
135136 let devices = enum_device ( & FOR_TUN_DEV_CLASS , FOR_TUN_HWID ) ?;
136137 if devices. is_empty ( ) {
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ pub use device_ops::init_device;
88pub use device_ops:: net_config;
99pub use device_ops:: AdapterDevice ;
1010use std:: sync:: Arc ;
11+ use std:: fs:: Path ;
1112use tokio:: io;
1213use windows:: core:: GUID ;
1314use windows:: Win32 :: Foundation :: CloseHandle ;
@@ -61,9 +62,8 @@ impl Drop for WriteFile {
6162
6263pub type TunSocket = ( ReadFile , WriteFile , AdapterDevice ) ;
6364
64- pub fn create_async_tun ( device_id : & GUID , name : & str ) -> anyhow:: Result < TunSocket > {
65- //TODO: inf_path change to compile path
66- let device = init_device ( device_id, name, "C:/DriverTest/Drivers/ForTun.inf" ) ?;
65+ pub fn create_async_tun < T : AsRef < Path > > ( device_id : & GUID , name : & str , inf_path : T ) -> anyhow:: Result < TunSocket > {
66+ let device = init_device ( device_id, name, inf_path/*"C:/DriverTest/Drivers/ForTun.inf"*/ ) ?;
6767 let file = device. start_adapter ( ) ?;
6868 let file = match WinOverlappedFile :: new ( file) {
6969 Ok ( file) => Arc :: new ( file) ,
You can’t perform that action at this time.
0 commit comments