-
-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: persistent wintun with GUID option (#301)
Fixes: #300
- Loading branch information
Showing
5 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//go:build unix | ||
|
||
package engine | ||
|
||
import ( | ||
"net/url" | ||
|
||
"github.com/xjasonlyu/tun2socks/v2/core/device" | ||
"github.com/xjasonlyu/tun2socks/v2/core/device/tun" | ||
) | ||
|
||
func parseTUN(u *url.URL, mtu uint32) (device.Device, error) { | ||
return tun.Open(u.Host, mtu) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package engine | ||
|
||
import ( | ||
"net/url" | ||
|
||
"github.com/gorilla/schema" | ||
"golang.org/x/sys/windows" | ||
wun "golang.zx2c4.com/wireguard/tun" | ||
|
||
"github.com/xjasonlyu/tun2socks/v2/core/device" | ||
"github.com/xjasonlyu/tun2socks/v2/core/device/tun" | ||
"github.com/xjasonlyu/tun2socks/v2/internal/version" | ||
) | ||
|
||
func init() { | ||
wun.WintunTunnelType = version.Name | ||
} | ||
|
||
func parseTUN(u *url.URL, mtu uint32) (device.Device, error) { | ||
opts := struct { | ||
GUID string | ||
}{} | ||
if err := schema.NewDecoder().Decode(&opts, u.Query()); err != nil { | ||
return nil, err | ||
} | ||
if opts.GUID != "" { | ||
guid, err := windows.GUIDFromString(opts.GUID) | ||
if err != nil { | ||
return nil, err | ||
} | ||
wun.WintunStaticRequestedGUID = &guid | ||
} | ||
return tun.Open(u.Host, mtu) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters