@@ -56,18 +56,22 @@ impl Device {
5656 Err ( _) => wintun:: Adapter :: create ( & wintun, tun_name, tun_name, guid) ?,
5757 } ;
5858
59- let address = config
60- . address
61- . unwrap_or ( IpAddr :: V4 ( Ipv4Addr :: new ( 10 , 1 , 0 , 2 ) ) ) ;
62- let mask = config
63- . netmask
64- . unwrap_or ( IpAddr :: V4 ( Ipv4Addr :: new ( 255 , 255 , 255 , 0 ) ) ) ;
65- let gateway = config. destination . map ( IpAddr :: from) ;
66- adapter. set_network_addresses_tuple ( address, mask, gateway) ?;
67- #[ cfg( feature = "wintun-dns" ) ]
68- if let Some ( dns_servers) = & config. platform_config . dns_servers {
69- adapter. set_dns_servers ( dns_servers) ?;
59+ // on win7 guid will not be correctly assigned, user should skip the config step.
60+ if !config. platform_config . skip_config && adapter. get_name ( ) . is_ok ( ) {
61+ let address = config
62+ . address
63+ . unwrap_or ( IpAddr :: V4 ( Ipv4Addr :: new ( 10 , 1 , 0 , 2 ) ) ) ;
64+ let mask = config
65+ . netmask
66+ . unwrap_or ( IpAddr :: V4 ( Ipv4Addr :: new ( 255 , 255 , 255 , 0 ) ) ) ;
67+ let gateway = config. destination . map ( IpAddr :: from) ;
68+ adapter. set_network_addresses_tuple ( address, mask, gateway) ?;
69+ #[ cfg( feature = "wintun-dns" ) ]
70+ if let Some ( dns_servers) = & config. platform_config . dns_servers {
71+ adapter. set_dns_servers ( dns_servers) ?;
72+ }
7073 }
74+
7175 let mtu = config. mtu . unwrap_or ( crate :: DEFAULT_MTU ) ;
7276
7377 let session = adapter. start_session (
@@ -85,8 +89,10 @@ impl Device {
8589 name : tun_name. to_string ( ) ,
8690 } ;
8791
88- // This is not needed since we use netsh to set the address.
89- device. configure ( config) ?;
92+ if !config. platform_config . skip_config && adapter. get_name ( ) . is_ok ( ) {
93+ // This is not needed since we use netsh to set the address.
94+ device. configure ( config) ?;
95+ }
9096
9197 Ok ( device)
9298 }
0 commit comments