gfwproxyshadowsocksdocker-imagegogolanggvisornatnetworksocks4socks5tcpip-stacktortun-devicetun2sockstunneludpwireguard
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
724 B
34 lines
724 B
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)
|
|
}
|
|
|