mirror of
https://github.com/yggdrasil-network/water.git
synced 2025-05-20 00:45:09 +03:00
Fixed TUN issue.
This commit is contained in:
parent
4faff02c97
commit
b78551478a
1 changed files with 10 additions and 9 deletions
|
@ -115,15 +115,6 @@ func openDev(isTAP bool) (ifce *Interface, err error) {
|
||||||
var bytesReturned uint32
|
var bytesReturned uint32
|
||||||
rdbbuf := make([]byte, syscall.MAXIMUM_REPARSE_DATA_BUFFER_SIZE)
|
rdbbuf := make([]byte, syscall.MAXIMUM_REPARSE_DATA_BUFFER_SIZE)
|
||||||
|
|
||||||
//TUN
|
|
||||||
if !isTAP {
|
|
||||||
code2 := []byte{0x0a, 0x03, 0x00, 0x01, 0x0a, 0x03, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00}
|
|
||||||
err = syscall.DeviceIoControl(file, tap_ioctl_config_tun, &code2[0], uint32(12), &rdbbuf[0], uint32(len(rdbbuf)), &bytesReturned, nil)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// find the mac address of tap device, use this to find the name of interface
|
// find the mac address of tap device, use this to find the name of interface
|
||||||
mac := make([]byte, 6)
|
mac := make([]byte, 6)
|
||||||
err = syscall.DeviceIoControl(file, tap_win_ioctl_get_mac, &mac[0], uint32(len(mac)), &mac[0], uint32(len(mac)), &bytesReturned, nil)
|
err = syscall.DeviceIoControl(file, tap_win_ioctl_get_mac, &mac[0], uint32(len(mac)), &mac[0], uint32(len(mac)), &bytesReturned, nil)
|
||||||
|
@ -140,6 +131,16 @@ func openDev(isTAP bool) (ifce *Interface, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TUN
|
||||||
|
if !isTAP {
|
||||||
|
code2 := []byte{0x0a, 0x03, 0x00, 0x01, 0x0a, 0x03, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00}
|
||||||
|
err = syscall.DeviceIoControl(file, tap_ioctl_config_tun, &code2[0], uint32(12), &rdbbuf[0], uint32(len(rdbbuf)), &bytesReturned, nil)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// find the name of tap interface(u need it to set the ip or other command)
|
// find the name of tap interface(u need it to set the ip or other command)
|
||||||
ifces, err := net.Interfaces()
|
ifces, err := net.Interfaces()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue