Skip to content

Commit

Permalink
🤖 Re-enable darwin
Browse files Browse the repository at this point in the history
Fixes #9
  • Loading branch information
mudler committed May 2, 2022
1 parent 7abadf6 commit fa5c374
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 13 deletions.
7 changes: 1 addition & 6 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ builds:
- arm
- 386
- arm64
ignore:
- goos: darwin
goarch: arm64
- goos: darwin
goarch: amd64
source:
enabled: true
name_template: '{{ .ProjectName }}-{{ .Tag }}-source'
Expand All @@ -42,4 +37,4 @@ changelog:
exclude:
- '^docs:'
- '^test:'
- '^Merge pull request'
- '^Merge pull request'
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/Masterminds/sprig/v3 v3.2.2
github.com/benbjohnson/clock v1.3.0
github.com/c-robinson/iplib v1.0.3
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/gookit/color v1.5.0 // indirect
Expand Down Expand Up @@ -44,3 +44,5 @@ require (
golang.org/x/net v0.0.0-20220418201149-a630d4f3e7a2
gopkg.in/yaml.v2 v2.4.0
)

replace github.com/elastic/gosigar => github.com/mudler/gosigar v0.14.3-0.20220502202347-34be910bdaaf
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,6 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/elastic/gosigar v0.12.0/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs=
github.com/elastic/gosigar v0.14.2 h1:Dg80n8cr90OZ7x+bAax/QjoW/XqTI11RmA79ZwIm9/4=
github.com/elastic/gosigar v0.14.2/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs=
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
Expand Down Expand Up @@ -883,6 +880,8 @@ github.com/mudler/go-isterminal v0.0.0-20211031135732-5e4e06fc5a58 h1:bMXak5giXx
github.com/mudler/go-isterminal v0.0.0-20211031135732-5e4e06fc5a58/go.mod h1:bZC4k76DbPOxOcMq6Z9oEKAZrOhsfh9jAZ9Hu3qVAQI=
github.com/mudler/go-processmanager v0.0.0-20211226182900-899fbb0b97f6 h1:LiWUDzDh/DkFYhUeIIdWPuMt/LsEVD3vc/QKDVXlWAY=
github.com/mudler/go-processmanager v0.0.0-20211226182900-899fbb0b97f6/go.mod h1:HGGAOJhipApckwNV8ZTliRJqxctUv3xRY+zbQEwuytc=
github.com/mudler/gosigar v0.14.3-0.20220502202347-34be910bdaaf h1:hNa6C3a7+14a2qwMkYZbq94ddebYc8CloF2KOVytf+A=
github.com/mudler/gosigar v0.14.3-0.20220502202347-34be910bdaaf/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs=
github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA=
github.com/multiformats/go-base32 v0.0.4 h1:+qMh4a2f37b4xTNs6mqitDinryCI+tfO2dRVMN9mjSE=
github.com/multiformats/go-base32 v0.0.4/go.mod h1:jNLFzjPZtp3aIARHbJRZIaPuspdH0J6q39uUM5pnABM=
Expand Down
3 changes: 2 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"math/bits"
"os"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -311,7 +312,7 @@ func (c Config) ToOpts(l *logger.Logger) ([]node.Option, []vpn.Option, error) {
libp2pOpts = append(libp2pOpts, libp2p.ConnectionManager(cm))
}

if !c.Limit.Enable {
if !c.Limit.Enable || runtime.GOOS == "darwin" {
libp2pOpts = append(libp2pOpts, libp2p.ResourceManager(network.NullResourceManager))
} else {
var limiter *rcmgr.BasicLimiter
Expand Down
4 changes: 2 additions & 2 deletions pkg/vpn/interface.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !windows
// +build !windows
//go:build !windows && !darwin
// +build !windows,!darwin

// Copyright © 2021 Ettore Di Giacinto <[email protected]>
//
Expand Down
60 changes: 60 additions & 0 deletions pkg/vpn/interface_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//go:build darwin
// +build darwin

// Copyright © 2021 Ettore Di Giacinto <[email protected]>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, see <http://www.gnu.org/licenses/>.

package vpn

import (
"github.com/songgao/water"
"github.com/vishvananda/netlink"
)

func createInterface(c *Config) (*water.Interface, error) {
config := water.Config{
DeviceType: c.DeviceType,
}
config.Name = c.InterfaceName

return water.New(config)
}

func prepareInterface(c *Config) error {
link, err := netlink.LinkByName(c.InterfaceName)
if err != nil {
return err
}
addr, err := netlink.ParseAddr(c.InterfaceAddress)
if err != nil {
return err
}

err = netlink.LinkSetMTU(link, c.InterfaceMTU)
if err != nil {
return err
}

err = netlink.AddrAdd(link, addr)
if err != nil {
return err
}

err = netlink.LinkSetUp(link)
if err != nil {
return err
}
return nil
}

0 comments on commit fa5c374

Please sign in to comment.