water icon indicating copy to clipboard operation
water copied to clipboard

cannot find the path specified

Open da1234cao opened this issue 9 months ago • 0 comments

environment

I installed the latest version(3.4.2) of openvpn.

image

code

package main

import (
	"log"

	"github.com/songgao/packets/ethernet"
	"github.com/songgao/water"
)

func main() {
	ifce, err := water.New(water.Config{
		DeviceType: water.TAP,
		PlatformSpecificParams: struct {
			ComponentID   string
			InterfaceName string
			Network       string
		}{ComponentID: "ovpn-dco",
			Network: "192.168.1.10/24"},
	})
	if err != nil {
		log.Fatal(err)
	}
	var frame ethernet.Frame

	for {
		frame.Resize(1500)
		n, err := ifce.Read([]byte(frame))
		if err != nil {
			log.Fatal(err)
		}
		frame = frame[:n]
		log.Printf("Dst: %s\n", frame.Destination())
		log.Printf("Src: %s\n", frame.Source())
		log.Printf("Ethertype: % x\n", frame.Ethertype())
		log.Printf("Payload: % x\n", frame.Payload())
	}
}

Report an error

The system cannot find the path specified.
exit status 1

Error location in source code

	path := "\\\\.\\Global\\" + deviceid + ".tap"
	pathp, err := syscall.UTF16PtrFromString(path)
	if err != nil {
		return nil, err
	}
	// type Handle uintptr
	file, err := syscall.CreateFile(pathp, syscall.GENERIC_READ|syscall.GENERIC_WRITE, uint32(syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE), nil, syscall.OPEN_EXISTING, syscall.FILE_ATTRIBUTE_SYSTEM|syscall.FILE_FLAG_OVERLAPPED, 0)

The value of path is \\.\\Global\\{4EA9AC56-CACA-437E-9C91-C555078DA422}.tap.

Is there something wrong with this path? what should I do

da1234cao avatar Sep 11 '23 14:09 da1234cao