@@ -28,7 +28,7 @@ func createTun(cfg TunConfig) (conn net.Conn, itf *net.Interface, err error) {
2828 return
2929 }
3030
31- cmd := fmt .Sprintf ("netsh interface ip set address name=%s " +
31+ cmd := fmt .Sprintf ("netsh interface ip set address name=\" %s \" " +
3232 "source=static addr=%s mask=%s gateway=none" ,
3333 ifce .Name (), ip .String (), ipMask (ipNet .Mask ))
3434 log .Log ("[tun]" , cmd )
@@ -70,7 +70,7 @@ func createTap(cfg TapConfig) (conn net.Conn, itf *net.Interface, err error) {
7070 }
7171
7272 if ip != nil && ipNet != nil {
73- cmd := fmt .Sprintf ("netsh interface ip set address name=%s " +
73+ cmd := fmt .Sprintf ("netsh interface ip set address name=\" %s \" " +
7474 "source=static addr=%s mask=%s gateway=none" ,
7575 ifce .Name (), ip .String (), ipMask (ipNet .Mask ))
7676 log .Log ("[tap]" , cmd )
@@ -105,7 +105,7 @@ func addTunRoutes(ifName string, gw string, routes ...IPRoute) error {
105105
106106 deleteRoute (ifName , route .Dest .String ())
107107
108- cmd := fmt .Sprintf ("netsh interface ip add route prefix=%s interface=%s store=active" ,
108+ cmd := fmt .Sprintf ("netsh interface ip add route prefix=%s interface=\" %s \" store=active" ,
109109 route .Dest .String (), ifName )
110110 if gw != "" {
111111 cmd += " nexthop=" + gw
@@ -127,7 +127,7 @@ func addTapRoutes(ifName string, gw string, routes ...string) error {
127127
128128 deleteRoute (ifName , route )
129129
130- cmd := fmt .Sprintf ("netsh interface ip add route prefix=%s interface=%s store=active" ,
130+ cmd := fmt .Sprintf ("netsh interface ip add route prefix=%s interface=\" %s \" store=active" ,
131131 route , ifName )
132132 if gw != "" {
133133 cmd += " nexthop=" + gw
@@ -142,7 +142,7 @@ func addTapRoutes(ifName string, gw string, routes ...string) error {
142142}
143143
144144func deleteRoute (ifName string , route string ) error {
145- cmd := fmt .Sprintf ("netsh interface ip delete route prefix=%s interface=%s store=active" ,
145+ cmd := fmt .Sprintf ("netsh interface ip delete route prefix=%s interface=\" %s \" store=active" ,
146146 route , ifName )
147147 args := strings .Split (cmd , " " )
148148 return exec .Command (args [0 ], args [1 :]... ).Run ()
0 commit comments