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/core"
|
||||||
"github.com/yggdrasil-network/yggdrasil-go/src/multicast"
|
"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"
|
"github.com/yggdrasil-network/yggdrasil-go/src/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
type node struct {
|
type node struct {
|
||||||
core *core.Core
|
core *core.Core
|
||||||
tuntap *tuntap.TunAdapter
|
tun *tun.TunAdapter
|
||||||
multicast *multicast.Multicast
|
multicast *multicast.Multicast
|
||||||
admin *admin.AdminSocket
|
admin *admin.AdminSocket
|
||||||
}
|
}
|
||||||
@ -219,7 +219,7 @@ func run(args yggArgs, ctx context.Context, done chan struct{}) {
|
|||||||
return
|
return
|
||||||
case args.autoconf:
|
case args.autoconf:
|
||||||
// Use an autoconf-generated config, this will give us random keys and
|
// 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()
|
cfg = defaults.GenerateConfig()
|
||||||
case args.useconffile != "" || args.useconf:
|
case args.useconffile != "" || args.useconf:
|
||||||
// Read the configuration from either stdin or from the filesystem
|
// 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.
|
// Setup the TUN module.
|
||||||
{
|
{
|
||||||
options := []tuntap.SetupOption{
|
options := []tun.SetupOption{
|
||||||
tuntap.InterfaceName(cfg.IfName),
|
tun.InterfaceName(cfg.IfName),
|
||||||
tuntap.InterfaceMTU(cfg.IfMTU),
|
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)
|
panic(err)
|
||||||
}
|
}
|
||||||
if n.admin != nil && n.tuntap != nil {
|
if n.admin != nil && n.tun != nil {
|
||||||
n.tuntap.SetupAdminHandlers(n.admin)
|
n.tun.SetupAdminHandlers(n.admin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,7 +378,7 @@ func run(args yggArgs, ctx context.Context, done chan struct{}) {
|
|||||||
func (n *node) shutdown() {
|
func (n *node) shutdown() {
|
||||||
_ = n.admin.Stop()
|
_ = n.admin.Stop()
|
||||||
_ = n.multicast.Stop()
|
_ = n.multicast.Stop()
|
||||||
_ = n.tuntap.Stop()
|
_ = n.tun.Stop()
|
||||||
n.core.Stop()
|
n.core.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
"github.com/yggdrasil-network/yggdrasil-go/src/admin"
|
"github.com/yggdrasil-network/yggdrasil-go/src/admin"
|
||||||
"github.com/yggdrasil-network/yggdrasil-go/src/core"
|
"github.com/yggdrasil-network/yggdrasil-go/src/core"
|
||||||
"github.com/yggdrasil-network/yggdrasil-go/src/multicast"
|
"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"
|
"github.com/yggdrasil-network/yggdrasil-go/src/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ func run() int {
|
|||||||
table.Render()
|
table.Render()
|
||||||
|
|
||||||
case "gettun":
|
case "gettun":
|
||||||
var resp tuntap.GetTUNResponse
|
var resp tun.GetTUNResponse
|
||||||
if err := json.Unmarshal(recv.Response, &resp); err != nil {
|
if err := json.Unmarshal(recv.Response, &resp); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ type platformDefaultParameters struct {
|
|||||||
// Multicast interfaces
|
// Multicast interfaces
|
||||||
DefaultMulticastInterfaces []MulticastInterfaceConfig
|
DefaultMulticastInterfaces []MulticastInterfaceConfig
|
||||||
|
|
||||||
// TUN/TAP
|
// TUN
|
||||||
MaximumIfMTU uint64
|
MaximumIfMTU uint64
|
||||||
DefaultIfMTU uint64
|
DefaultIfMTU uint64
|
||||||
DefaultIfName string
|
DefaultIfName string
|
||||||
|
@ -19,7 +19,7 @@ func getDefaults() platformDefaultParameters {
|
|||||||
{Regex: "bridge.*", Beacon: true, Listen: true},
|
{Regex: "bridge.*", Beacon: true, Listen: true},
|
||||||
},
|
},
|
||||||
|
|
||||||
// TUN/TAP
|
// TUN
|
||||||
MaximumIfMTU: 65535,
|
MaximumIfMTU: 65535,
|
||||||
DefaultIfMTU: 65535,
|
DefaultIfMTU: 65535,
|
||||||
DefaultIfName: "auto",
|
DefaultIfName: "auto",
|
||||||
|
@ -18,7 +18,7 @@ func getDefaults() platformDefaultParameters {
|
|||||||
{Regex: ".*", Beacon: true, Listen: true},
|
{Regex: ".*", Beacon: true, Listen: true},
|
||||||
},
|
},
|
||||||
|
|
||||||
// TUN/TAP
|
// TUN
|
||||||
MaximumIfMTU: 32767,
|
MaximumIfMTU: 32767,
|
||||||
DefaultIfMTU: 32767,
|
DefaultIfMTU: 32767,
|
||||||
DefaultIfName: "/dev/tun0",
|
DefaultIfName: "/dev/tun0",
|
||||||
|
@ -18,7 +18,7 @@ func getDefaults() platformDefaultParameters {
|
|||||||
{Regex: ".*", Beacon: true, Listen: true},
|
{Regex: ".*", Beacon: true, Listen: true},
|
||||||
},
|
},
|
||||||
|
|
||||||
// TUN/TAP
|
// TUN
|
||||||
MaximumIfMTU: 65535,
|
MaximumIfMTU: 65535,
|
||||||
DefaultIfMTU: 65535,
|
DefaultIfMTU: 65535,
|
||||||
DefaultIfName: "auto",
|
DefaultIfName: "auto",
|
||||||
|
@ -18,7 +18,7 @@ func getDefaults() platformDefaultParameters {
|
|||||||
{Regex: ".*", Beacon: true, Listen: true},
|
{Regex: ".*", Beacon: true, Listen: true},
|
||||||
},
|
},
|
||||||
|
|
||||||
// TUN/TAP
|
// TUN
|
||||||
MaximumIfMTU: 16384,
|
MaximumIfMTU: 16384,
|
||||||
DefaultIfMTU: 16384,
|
DefaultIfMTU: 16384,
|
||||||
DefaultIfName: "tun0",
|
DefaultIfName: "tun0",
|
||||||
|
@ -18,7 +18,7 @@ func getDefaults() platformDefaultParameters {
|
|||||||
{Regex: ".*", Beacon: true, Listen: true},
|
{Regex: ".*", Beacon: true, Listen: true},
|
||||||
},
|
},
|
||||||
|
|
||||||
// TUN/TAP
|
// TUN
|
||||||
MaximumIfMTU: 65535,
|
MaximumIfMTU: 65535,
|
||||||
DefaultIfMTU: 65535,
|
DefaultIfMTU: 65535,
|
||||||
DefaultIfName: "none",
|
DefaultIfName: "none",
|
||||||
|
@ -18,7 +18,7 @@ func getDefaults() platformDefaultParameters {
|
|||||||
{Regex: ".*", Beacon: true, Listen: true},
|
{Regex: ".*", Beacon: true, Listen: true},
|
||||||
},
|
},
|
||||||
|
|
||||||
// TUN/TAP
|
// TUN
|
||||||
MaximumIfMTU: 65535,
|
MaximumIfMTU: 65535,
|
||||||
DefaultIfMTU: 65535,
|
DefaultIfMTU: 65535,
|
||||||
DefaultIfName: "Yggdrasil",
|
DefaultIfName: "Yggdrasil",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package tuntap
|
package tun
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
@ -1,4 +1,4 @@
|
|||||||
package tuntap
|
package tun
|
||||||
|
|
||||||
const TUN_OFFSET_BYTES = 4
|
const TUN_OFFSET_BYTES = 4
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package tuntap
|
package tun
|
||||||
|
|
||||||
func (m *TunAdapter) _applyOption(opt SetupOption) {
|
func (m *TunAdapter) _applyOption(opt SetupOption) {
|
||||||
switch v := opt.(type) {
|
switch v := opt.(type) {
|
@ -1,10 +1,7 @@
|
|||||||
package tuntap
|
package tun
|
||||||
|
|
||||||
// This manages the tun driver to send/recv packets to/from applications
|
// 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: Connection timeouts (call Conn.Close() when we want to time out)
|
||||||
// TODO: Don't block in reader on writes that are pending searches
|
// TODO: Don't block in reader on writes that are pending searches
|
||||||
|
|
||||||
@ -13,8 +10,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
//"sync"
|
|
||||||
|
|
||||||
"github.com/Arceliar/phony"
|
"github.com/Arceliar/phony"
|
||||||
"golang.zx2c4.com/wireguard/tun"
|
"golang.zx2c4.com/wireguard/tun"
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
//go:build openbsd || freebsd
|
//go:build openbsd || freebsd
|
||||||
// +build openbsd freebsd
|
// +build openbsd freebsd
|
||||||
|
|
||||||
package tuntap
|
package tun
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
@ -1,7 +1,7 @@
|
|||||||
//go:build !mobile
|
//go:build !mobile
|
||||||
// +build !mobile
|
// +build !mobile
|
||||||
|
|
||||||
package tuntap
|
package tun
|
||||||
|
|
||||||
// The darwin platform specific tun parts
|
// The darwin platform specific tun parts
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
//go:build !mobile
|
//go:build !mobile
|
||||||
// +build !mobile
|
// +build !mobile
|
||||||
|
|
||||||
package tuntap
|
package tun
|
||||||
|
|
||||||
// The linux platform specific tun parts
|
// 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)
|
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"
|
// 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
|
// to exist on the system, but this will fail if Netlink is not present in the
|
||||||
// kernel (it nearly always is).
|
// kernel (it nearly always is).
|
@ -1,7 +1,7 @@
|
|||||||
//go:build !linux && !darwin && !windows && !openbsd && !freebsd && !mobile
|
//go:build !linux && !darwin && !windows && !openbsd && !freebsd && !mobile
|
||||||
// +build !linux,!darwin,!windows,!openbsd,!freebsd,!mobile
|
// +build !linux,!darwin,!windows,!openbsd,!freebsd,!mobile
|
||||||
|
|
||||||
package tuntap
|
package tun
|
||||||
|
|
||||||
// This is to catch unsupported platforms
|
// This is to catch unsupported platforms
|
||||||
// If your platform supports tun devices, you could try configuring it manually
|
// If your platform supports tun devices, you could try configuring it manually
|
@ -1,7 +1,7 @@
|
|||||||
//go:build windows
|
//go:build windows
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package tuntap
|
package tun
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"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 {
|
func (tun *TunAdapter) setupMTU(mtu uint64) error {
|
||||||
if tun.iface == nil || tun.Name() == "" {
|
if tun.iface == nil || tun.Name() == "" {
|
||||||
return errors.New("Can't configure MTU as TUN adapter is not present")
|
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
|
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 {
|
func (tun *TunAdapter) setupAddress(addr string) error {
|
||||||
if tun.iface == nil || tun.Name() == "" {
|
if tun.iface == nil || tun.Name() == "" {
|
||||||
return errors.New("Can't configure IPv6 address as TUN adapter is not present")
|
return errors.New("Can't configure IPv6 address as TUN adapter is not present")
|
Loading…
Reference in New Issue
Block a user