Make Interface.Inside an interface type (#252)

This commit updates the Interface.Inside type to be a new interface
type instead of a *Tun. This will allow for an inside interface
that does not use a tun device, such as a single-binary client that
can run without elevated privileges.
This commit is contained in:
forfuncsake
2020-07-28 22:53:16 +10:00
committed by GitHub
parent 4756c9613d
commit 9b06748506
7 changed files with 63 additions and 6 deletions

View File

@ -2,6 +2,8 @@ package nebula
import (
"errors"
"io"
"net"
"os"
"time"
@ -10,10 +12,18 @@ import (
const mtu = 9001
type Inside interface {
io.ReadWriteCloser
Activate() error
CidrNet() *net.IPNet
DeviceName() string
WriteRaw([]byte) error
}
type InterfaceConfig struct {
HostMap *HostMap
Outside *udpConn
Inside *Tun
Inside Inside
certState *CertState
Cipher string
Firewall *Firewall
@ -31,7 +41,7 @@ type InterfaceConfig struct {
type Interface struct {
hostMap *HostMap
outside *udpConn
inside *Tun
inside Inside
certState *CertState
cipher string
firewall *Firewall
@ -101,7 +111,7 @@ func (f *Interface) Run(tunRoutines, udpRoutines int, buildVersion string) {
l.WithError(err).Error("Failed to get udp listen address")
}
l.WithField("interface", f.inside.Device).WithField("network", f.inside.Cidr.String()).
l.WithField("interface", f.inside.DeviceName()).WithField("network", f.inside.CidrNet().String()).
WithField("build", buildVersion).WithField("udpAddr", addr).
Info("Nebula interface is active")