mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-11-23 10:05:17 +00:00
Rename tuntap
package to tun
We haven't had TAP support in ages.
This commit is contained in:
parent
217ac39e77
commit
01c44a087b
@ -32,13 +32,13 @@ import (
|
||||
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/core"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/multicast"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/tuntap"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/tun"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/version"
|
||||
)
|
||||
|
||||
type node struct {
|
||||
core *core.Core
|
||||
tuntap *tuntap.TunAdapter
|
||||
tun *tun.TunAdapter
|
||||
multicast *multicast.Multicast
|
||||
admin *admin.AdminSocket
|
||||
}
|
||||
@ -219,7 +219,7 @@ func run(args yggArgs, ctx context.Context, done chan struct{}) {
|
||||
return
|
||||
case args.autoconf:
|
||||
// Use an autoconf-generated config, this will give us random keys and
|
||||
// port numbers, and will use an automatically selected TUN/TAP interface.
|
||||
// port numbers, and will use an automatically selected TUN interface.
|
||||
cfg = defaults.GenerateConfig()
|
||||
case args.useconffile != "" || args.useconf:
|
||||
// Read the configuration from either stdin or from the filesystem
|
||||
@ -348,15 +348,15 @@ func run(args yggArgs, ctx context.Context, done chan struct{}) {
|
||||
|
||||
// Setup the TUN module.
|
||||
{
|
||||
options := []tuntap.SetupOption{
|
||||
tuntap.InterfaceName(cfg.IfName),
|
||||
tuntap.InterfaceMTU(cfg.IfMTU),
|
||||
options := []tun.SetupOption{
|
||||
tun.InterfaceName(cfg.IfName),
|
||||
tun.InterfaceMTU(cfg.IfMTU),
|
||||
}
|
||||
if n.tuntap, err = tuntap.New(ipv6rwc.NewReadWriteCloser(n.core), logger, options...); err != nil {
|
||||
if n.tun, err = tun.New(ipv6rwc.NewReadWriteCloser(n.core), logger, options...); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if n.admin != nil && n.tuntap != nil {
|
||||
n.tuntap.SetupAdminHandlers(n.admin)
|
||||
if n.admin != nil && n.tun != nil {
|
||||
n.tun.SetupAdminHandlers(n.admin)
|
||||
}
|
||||
}
|
||||
|
||||
@ -378,7 +378,7 @@ func run(args yggArgs, ctx context.Context, done chan struct{}) {
|
||||
func (n *node) shutdown() {
|
||||
_ = n.admin.Stop()
|
||||
_ = n.multicast.Stop()
|
||||
_ = n.tuntap.Stop()
|
||||
_ = n.tun.Stop()
|
||||
n.core.Stop()
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/admin"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/core"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/multicast"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/tuntap"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/tun"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/version"
|
||||
)
|
||||
|
||||
@ -256,7 +256,7 @@ func run() int {
|
||||
table.Render()
|
||||
|
||||
case "gettun":
|
||||
var resp tuntap.GetTUNResponse
|
||||
var resp tun.GetTUNResponse
|
||||
if err := json.Unmarshal(recv.Response, &resp); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ type platformDefaultParameters struct {
|
||||
// Multicast interfaces
|
||||
DefaultMulticastInterfaces []MulticastInterfaceConfig
|
||||
|
||||
// TUN/TAP
|
||||
// TUN
|
||||
MaximumIfMTU uint64
|
||||
DefaultIfMTU uint64
|
||||
DefaultIfName string
|
||||
|
@ -19,7 +19,7 @@ func getDefaults() platformDefaultParameters {
|
||||
{Regex: "bridge.*", Beacon: true, Listen: true},
|
||||
},
|
||||
|
||||
// TUN/TAP
|
||||
// TUN
|
||||
MaximumIfMTU: 65535,
|
||||
DefaultIfMTU: 65535,
|
||||
DefaultIfName: "auto",
|
||||
|
@ -18,7 +18,7 @@ func getDefaults() platformDefaultParameters {
|
||||
{Regex: ".*", Beacon: true, Listen: true},
|
||||
},
|
||||
|
||||
// TUN/TAP
|
||||
// TUN
|
||||
MaximumIfMTU: 32767,
|
||||
DefaultIfMTU: 32767,
|
||||
DefaultIfName: "/dev/tun0",
|
||||
|
@ -18,7 +18,7 @@ func getDefaults() platformDefaultParameters {
|
||||
{Regex: ".*", Beacon: true, Listen: true},
|
||||
},
|
||||
|
||||
// TUN/TAP
|
||||
// TUN
|
||||
MaximumIfMTU: 65535,
|
||||
DefaultIfMTU: 65535,
|
||||
DefaultIfName: "auto",
|
||||
|
@ -18,7 +18,7 @@ func getDefaults() platformDefaultParameters {
|
||||
{Regex: ".*", Beacon: true, Listen: true},
|
||||
},
|
||||
|
||||
// TUN/TAP
|
||||
// TUN
|
||||
MaximumIfMTU: 16384,
|
||||
DefaultIfMTU: 16384,
|
||||
DefaultIfName: "tun0",
|
||||
|
@ -18,7 +18,7 @@ func getDefaults() platformDefaultParameters {
|
||||
{Regex: ".*", Beacon: true, Listen: true},
|
||||
},
|
||||
|
||||
// TUN/TAP
|
||||
// TUN
|
||||
MaximumIfMTU: 65535,
|
||||
DefaultIfMTU: 65535,
|
||||
DefaultIfName: "none",
|
||||
|
@ -18,7 +18,7 @@ func getDefaults() platformDefaultParameters {
|
||||
{Regex: ".*", Beacon: true, Listen: true},
|
||||
},
|
||||
|
||||
// TUN/TAP
|
||||
// TUN
|
||||
MaximumIfMTU: 65535,
|
||||
DefaultIfMTU: 65535,
|
||||
DefaultIfName: "Yggdrasil",
|
||||
|
@ -1,4 +1,4 @@
|
||||
package tuntap
|
||||
package tun
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@ -1,4 +1,4 @@
|
||||
package tuntap
|
||||
package tun
|
||||
|
||||
const TUN_OFFSET_BYTES = 4
|
||||
|
@ -1,4 +1,4 @@
|
||||
package tuntap
|
||||
package tun
|
||||
|
||||
func (m *TunAdapter) _applyOption(opt SetupOption) {
|
||||
switch v := opt.(type) {
|
@ -1,10 +1,7 @@
|
||||
package tuntap
|
||||
package tun
|
||||
|
||||
// This manages the tun driver to send/recv packets to/from applications
|
||||
|
||||
// TODO: Crypto-key routing support
|
||||
// TODO: Set MTU of session properly
|
||||
// TODO: Reject packets that exceed session MTU with ICMPv6 for PMTU Discovery
|
||||
// TODO: Connection timeouts (call Conn.Close() when we want to time out)
|
||||
// TODO: Don't block in reader on writes that are pending searches
|
||||
|
||||
@ -13,8 +10,6 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
//"sync"
|
||||
|
||||
"github.com/Arceliar/phony"
|
||||
"golang.zx2c4.com/wireguard/tun"
|
||||
|
@ -1,7 +1,7 @@
|
||||
//go:build openbsd || freebsd
|
||||
// +build openbsd freebsd
|
||||
|
||||
package tuntap
|
||||
package tun
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
@ -1,7 +1,7 @@
|
||||
//go:build !mobile
|
||||
// +build !mobile
|
||||
|
||||
package tuntap
|
||||
package tun
|
||||
|
||||
// The darwin platform specific tun parts
|
||||
|
@ -1,7 +1,7 @@
|
||||
//go:build !mobile
|
||||
// +build !mobile
|
||||
|
||||
package tuntap
|
||||
package tun
|
||||
|
||||
// The linux platform specific tun parts
|
||||
|
||||
@ -28,7 +28,7 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error {
|
||||
return tun.setupAddress(addr)
|
||||
}
|
||||
|
||||
// Configures the TAP adapter with the correct IPv6 address and MTU. Netlink
|
||||
// Configures the TUN adapter with the correct IPv6 address and MTU. Netlink
|
||||
// is used to do this, so there is not a hard requirement on "ip" or "ifconfig"
|
||||
// to exist on the system, but this will fail if Netlink is not present in the
|
||||
// kernel (it nearly always is).
|
@ -1,7 +1,7 @@
|
||||
//go:build !linux && !darwin && !windows && !openbsd && !freebsd && !mobile
|
||||
// +build !linux,!darwin,!windows,!openbsd,!freebsd,!mobile
|
||||
|
||||
package tuntap
|
||||
package tun
|
||||
|
||||
// This is to catch unsupported platforms
|
||||
// If your platform supports tun devices, you could try configuring it manually
|
@ -1,7 +1,7 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package tuntap
|
||||
package tun
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -50,7 +50,7 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error {
|
||||
})
|
||||
}
|
||||
|
||||
// Sets the MTU of the TAP adapter.
|
||||
// Sets the MTU of the TUN adapter.
|
||||
func (tun *TunAdapter) setupMTU(mtu uint64) error {
|
||||
if tun.iface == nil || tun.Name() == "" {
|
||||
return errors.New("Can't configure MTU as TUN adapter is not present")
|
||||
@ -77,7 +77,7 @@ func (tun *TunAdapter) setupMTU(mtu uint64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Sets the IPv6 address of the TAP adapter.
|
||||
// Sets the IPv6 address of the TUN adapter.
|
||||
func (tun *TunAdapter) setupAddress(addr string) error {
|
||||
if tun.iface == nil || tun.Name() == "" {
|
||||
return errors.New("Can't configure IPv6 address as TUN adapter is not present")
|
Loading…
Reference in New Issue
Block a user