Skip to content

Commit 090f993

Browse files
authored
Merge pull request #31 from mudler/pin/water
Improve windows support
2 parents 2538123 + c1f1b42 commit 090f993

File tree

10 files changed

+70
-30
lines changed

10 files changed

+70
-30
lines changed

.goreleaser.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ builds:
1010
- linux
1111
- windows
1212
- darwin
13+
- freebsd
1314
goarch:
1415
- amd64
1516
- arm
@@ -25,6 +26,7 @@ archives:
2526
darwin: Darwin
2627
linux: Linux
2728
windows: Windows
29+
freebsd: FreeBSD
2830
386: i386
2931
amd64: x86_64
3032
checksum:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ require (
2525
github.com/miekg/dns v1.1.50
2626
github.com/mitchellh/copystructure v1.2.0 // indirect
2727
github.com/mudler/go-processmanager v0.0.0-20220724164624-c45b5c61312d
28+
github.com/mudler/water v0.0.0-20221010214108-8c7313014ce0
2829
github.com/multiformats/go-multiaddr v0.7.0
2930
github.com/onsi/ginkgo/v2 v2.1.1
3031
github.com/onsi/gomega v1.17.0
3132
github.com/peterbourgon/diskv v2.0.1+incompatible
3233
github.com/pkg/errors v0.9.1
3334
github.com/shopspring/decimal v1.3.1 // indirect
3435
github.com/songgao/packets v0.0.0-20160404182456-549a10cd4091
35-
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8
3636
github.com/spf13/cast v1.5.0 // indirect
3737
github.com/urfave/cli v1.22.10
3838
github.com/vishvananda/netlink v1.1.0

go.sum

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,8 @@ github.com/mudler/go-processmanager v0.0.0-20220724164624-c45b5c61312d h1:/lAg9v
543543
github.com/mudler/go-processmanager v0.0.0-20220724164624-c45b5c61312d/go.mod h1:HGGAOJhipApckwNV8ZTliRJqxctUv3xRY+zbQEwuytc=
544544
github.com/mudler/gosigar v0.14.3-0.20220502202347-34be910bdaaf h1:hNa6C3a7+14a2qwMkYZbq94ddebYc8CloF2KOVytf+A=
545545
github.com/mudler/gosigar v0.14.3-0.20220502202347-34be910bdaaf/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs=
546+
github.com/mudler/water v0.0.0-20221010214108-8c7313014ce0 h1:Qh6ghkMgTu6siFbTf7L3IszJmshMhXxNL4V+t7IIA6w=
547+
github.com/mudler/water v0.0.0-20221010214108-8c7313014ce0/go.mod h1:nViSE8jcOcraZwhi34joEqn7HYFISgs0M8/YujzY5Xk=
546548
github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA=
547549
github.com/multiformats/go-base32 v0.0.4/go.mod h1:jNLFzjPZtp3aIARHbJRZIaPuspdH0J6q39uUM5pnABM=
548550
github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aGkbLYxPE=
@@ -715,8 +717,6 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9
715717
github.com/smola/gocompat v0.2.0/go.mod h1:1B0MlxbmoZNo3h8guHp8HztB3BSYR5itql9qtVc0ypY=
716718
github.com/songgao/packets v0.0.0-20160404182456-549a10cd4091 h1:1zN6ImoqhSJhN8hGXFaJlSC8msLmIbX8bFqOfWLKw0w=
717719
github.com/songgao/packets v0.0.0-20160404182456-549a10cd4091/go.mod h1:N20Z5Y8oye9a7HmytmZ+tr8Q2vlP0tAHP13kTHzwvQY=
718-
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 h1:TG/diQgUe0pntT/2D9tmUCz4VNwm9MfrtPr0SU2qSX8=
719-
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8/go.mod h1:P5HUIBuIWKbyjl083/loAegFkfbFNx5i2qEP4CNbm7E=
720720
github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE=
721721
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
722722
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 h1:RC6RW7j+1+HkWaX/Yh71Ee5ZHaHYt7ZP4sQgUrm6cDU=
@@ -841,6 +841,7 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm
841841
golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
842842
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
843843
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
844+
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
844845
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
845846
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM=
846847
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
@@ -1030,12 +1031,14 @@ golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBc
10301031
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
10311032
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
10321033
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1034+
golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
10331035
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
10341036
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
10351037
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
10361038
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
10371039
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
10381040
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1041+
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
10391042
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
10401043
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY=
10411044
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -1117,6 +1120,10 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
11171120
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
11181121
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
11191122
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
1123+
golang.zx2c4.com/wintun v0.0.0-20211104114900-415007cec224 h1:Ug9qvr1myri/zFN6xL17LSCBGFDnphBBhzmILHsM5TY=
1124+
golang.zx2c4.com/wintun v0.0.0-20211104114900-415007cec224/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI=
1125+
golang.zx2c4.com/wireguard v0.0.0-20220703234212-c31a7b1ab478 h1:vDy//hdR+GnROE3OdYbQKt9rdtNdHkDtONvpRwmls/0=
1126+
golang.zx2c4.com/wireguard v0.0.0-20220703234212-c31a7b1ab478/go.mod h1:bVQfyl2sCM/QIIGHpWbFGfHPuDvqnCNkT6MQLTCjO/U=
11201127
google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
11211128
google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
11221129
google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y=

pkg/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ import (
3939
"github.com/mudler/edgevpn/pkg/trustzone"
4040
"github.com/mudler/edgevpn/pkg/trustzone/authprovider/ecdsa"
4141
"github.com/mudler/edgevpn/pkg/vpn"
42+
"github.com/mudler/water"
4243
"github.com/peterbourgon/diskv"
43-
"github.com/songgao/water"
4444
)
4545

4646
// Config is the config struct for the node and the default EdgeVPN services

pkg/vpn/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"time"
1818

1919
"github.com/ipfs/go-log"
20-
"github.com/songgao/water"
20+
"github.com/mudler/water"
2121
)
2222

2323
type Config struct {

pkg/vpn/interface.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//go:build !windows && !darwin
2-
// +build !windows,!darwin
1+
//go:build !windows && !darwin && !freebsd
2+
// +build !windows,!darwin,!freebsd
33

44
/*
55
Copyright © 2021-2022 Ettore Di Giacinto <[email protected]>
@@ -17,7 +17,7 @@ limitations under the License.
1717
package vpn
1818

1919
import (
20-
"github.com/songgao/water"
20+
"github.com/mudler/water"
2121
"github.com/vishvananda/netlink"
2222
)
2323

pkg/vpn/interface_darwin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
package vpn
1818

1919
import (
20-
"github.com/songgao/water"
20+
"github.com/mudler/water"
2121
"github.com/vishvananda/netlink"
2222
)
2323

pkg/vpn/interface_freebsd.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//go:build freebsd
2+
// +build freebsd
3+
4+
/*
5+
Copyright © 2021-2022 Ettore Di Giacinto <[email protected]>
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package vpn
18+
19+
import (
20+
"fmt"
21+
"github.com/mudler/water"
22+
"os/exec"
23+
)
24+
25+
func createInterface(c *Config) (*water.Interface, error) {
26+
config := water.Config{
27+
DeviceType: c.DeviceType,
28+
}
29+
config.Name = c.InterfaceName
30+
31+
return water.New(config)
32+
}
33+
34+
func prepareInterface(c *Config) error {
35+
err := sh(fmt.Sprintf("ifconfig %s create", c.InterfaceName))
36+
if err != nil {
37+
return err
38+
}
39+
err = sh(fmt.Sprintf("ifconfig %s inet %s %s netmask %s", c.InterfaceName, c.InterfaceAddress, c.InterfaceAddress, "255.255.255.0"))
40+
if err != nil {
41+
return err
42+
}
43+
return sh(fmt.Sprintf("ifconfig %s up", c.InterfaceName))
44+
}
45+
46+
func sh(c string) (err error) {
47+
_, err = exec.Command("/bin/sh", "-c", c).CombinedOutput()
48+
return
49+
}

pkg/vpn/interface_windows.go

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ package vpn
1919
import (
2020
"fmt"
2121
"log"
22-
"net"
2322
"os/exec"
2423

25-
"github.com/songgao/water"
24+
"github.com/mudler/water"
2625
)
2726

2827
func prepareInterface(c *Config) error {
@@ -38,27 +37,10 @@ func prepareInterface(c *Config) error {
3837
}
3938

4039
func createInterface(c *Config) (*water.Interface, error) {
41-
// TUN on Windows requires address and network to be set on device creation stage
42-
// We also set network to 0.0.0.0/0 so we able to reach networks behind the node
43-
// https://github.com/songgao/water/blob/master/params_windows.go
44-
// https://gitlab.com/openconnect/openconnect/-/blob/master/tun-win32.c
45-
ip, _, err := net.ParseCIDR(c.InterfaceAddress)
46-
if err != nil {
47-
return nil, err
48-
}
49-
network := net.IPNet{
50-
IP: ip,
51-
Mask: net.IPv4Mask(0, 0, 0, 0),
52-
}
5340
config := water.Config{
5441
DeviceType: c.DeviceType,
55-
PlatformSpecificParams: water.PlatformSpecificParams{
56-
ComponentID: "tap0901",
57-
InterfaceName: c.InterfaceName,
58-
Network: network.String(),
59-
},
6042
}
61-
43+
config.Name = c.InterfaceName
6244
return water.New(config)
6345
}
6446

pkg/vpn/vpn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ import (
3737
"github.com/mudler/edgevpn/pkg/stream"
3838
"github.com/mudler/edgevpn/pkg/types"
3939

40+
"github.com/mudler/water"
4041
"github.com/pkg/errors"
4142
"github.com/songgao/packets/ethernet"
42-
"github.com/songgao/water"
4343
)
4444

4545
type streamManager interface {

0 commit comments

Comments
 (0)