Start the overlay package with the old Inside interface (#576)
This commit is contained in:
		
							
								
								
									
										15
									
								
								interface.go
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								interface.go
									
									
									
									
									
								
							| @@ -4,7 +4,6 @@ import ( | |||||||
| 	"context" | 	"context" | ||||||
| 	"errors" | 	"errors" | ||||||
| 	"io" | 	"io" | ||||||
| 	"net" |  | ||||||
| 	"os" | 	"os" | ||||||
| 	"runtime" | 	"runtime" | ||||||
| 	"sync/atomic" | 	"sync/atomic" | ||||||
| @@ -16,24 +15,16 @@ import ( | |||||||
| 	"github.com/slackhq/nebula/config" | 	"github.com/slackhq/nebula/config" | ||||||
| 	"github.com/slackhq/nebula/firewall" | 	"github.com/slackhq/nebula/firewall" | ||||||
| 	"github.com/slackhq/nebula/iputil" | 	"github.com/slackhq/nebula/iputil" | ||||||
|  | 	"github.com/slackhq/nebula/overlay" | ||||||
| 	"github.com/slackhq/nebula/udp" | 	"github.com/slackhq/nebula/udp" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| const mtu = 9001 | const mtu = 9001 | ||||||
|  |  | ||||||
| type Inside interface { |  | ||||||
| 	io.ReadWriteCloser |  | ||||||
| 	Activate() error |  | ||||||
| 	CidrNet() *net.IPNet |  | ||||||
| 	DeviceName() string |  | ||||||
| 	WriteRaw([]byte) error |  | ||||||
| 	NewMultiQueueReader() (io.ReadWriteCloser, error) |  | ||||||
| } |  | ||||||
|  |  | ||||||
| type InterfaceConfig struct { | type InterfaceConfig struct { | ||||||
| 	HostMap                 *HostMap | 	HostMap                 *HostMap | ||||||
| 	Outside                 *udp.Conn | 	Outside                 *udp.Conn | ||||||
| 	Inside                  Inside | 	Inside                  overlay.Device | ||||||
| 	certState               *CertState | 	certState               *CertState | ||||||
| 	Cipher                  string | 	Cipher                  string | ||||||
| 	Firewall                *Firewall | 	Firewall                *Firewall | ||||||
| @@ -57,7 +48,7 @@ type InterfaceConfig struct { | |||||||
| type Interface struct { | type Interface struct { | ||||||
| 	hostMap            *HostMap | 	hostMap            *HostMap | ||||||
| 	outside            *udp.Conn | 	outside            *udp.Conn | ||||||
| 	inside             Inside | 	inside             overlay.Device | ||||||
| 	certState          *CertState | 	certState          *CertState | ||||||
| 	cipher             string | 	cipher             string | ||||||
| 	firewall           *Firewall | 	firewall           *Firewall | ||||||
|   | |||||||
							
								
								
									
										3
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								main.go
									
									
									
									
									
								
							| @@ -10,6 +10,7 @@ import ( | |||||||
| 	"github.com/sirupsen/logrus" | 	"github.com/sirupsen/logrus" | ||||||
| 	"github.com/slackhq/nebula/config" | 	"github.com/slackhq/nebula/config" | ||||||
| 	"github.com/slackhq/nebula/iputil" | 	"github.com/slackhq/nebula/iputil" | ||||||
|  | 	"github.com/slackhq/nebula/overlay" | ||||||
| 	"github.com/slackhq/nebula/sshd" | 	"github.com/slackhq/nebula/sshd" | ||||||
| 	"github.com/slackhq/nebula/udp" | 	"github.com/slackhq/nebula/udp" | ||||||
| 	"github.com/slackhq/nebula/util" | 	"github.com/slackhq/nebula/util" | ||||||
| @@ -137,7 +138,7 @@ func Main(c *config.C, configTest bool, buildVersion string, logger *logrus.Logg | |||||||
| 		l.WithField("duration", conntrackCacheTimeout).Info("Using routine-local conntrack cache") | 		l.WithField("duration", conntrackCacheTimeout).Info("Using routine-local conntrack cache") | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	var tun Inside | 	var tun overlay.Device | ||||||
| 	if !configTest { | 	if !configTest { | ||||||
| 		c.CatchHUP(ctx) | 		c.CatchHUP(ctx) | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								overlay/device.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								overlay/device.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | |||||||
|  | package overlay | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"io" | ||||||
|  | 	"net" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type Device interface { | ||||||
|  | 	io.ReadWriteCloser | ||||||
|  | 	Activate() error | ||||||
|  | 	CidrNet() *net.IPNet | ||||||
|  | 	DeviceName() string | ||||||
|  | 	WriteRaw([]byte) error | ||||||
|  | 	NewMultiQueueReader() (io.ReadWriteCloser, error) | ||||||
|  | } | ||||||
| @@ -13,10 +13,11 @@ import ( | |||||||
| 	"syscall" | 	"syscall" | ||||||
|  |  | ||||||
| 	"github.com/sirupsen/logrus" | 	"github.com/sirupsen/logrus" | ||||||
|  | 	"github.com/slackhq/nebula/overlay" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| type Tun struct { | type Tun struct { | ||||||
| 	Inside | 	overlay.Device | ||||||
| } | } | ||||||
|  |  | ||||||
| func newTunFromFd(l *logrus.Logger, deviceFd int, cidr *net.IPNet, defaultMTU int, routes []route, unsafeRoutes []route, txQueueLen int) (ifce *Tun, err error) { | func newTunFromFd(l *logrus.Logger, deviceFd int, cidr *net.IPNet, defaultMTU int, routes []route, unsafeRoutes []route, txQueueLen int) (ifce *Tun, err error) { | ||||||
| @@ -34,7 +35,7 @@ func newTun(l *logrus.Logger, deviceName string, cidr *net.IPNet, defaultMTU int | |||||||
| 		useWintun = false | 		useWintun = false | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	var inside Inside | 	var inside overlay.Device | ||||||
| 	if useWintun { | 	if useWintun { | ||||||
| 		inside, err = newWinTun(deviceName, cidr, defaultMTU, unsafeRoutes, txQueueLen) | 		inside, err = newWinTun(deviceName, cidr, defaultMTU, unsafeRoutes, txQueueLen) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| @@ -48,7 +49,7 @@ func newTun(l *logrus.Logger, deviceName string, cidr *net.IPNet, defaultMTU int | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return &Tun{ | 	return &Tun{ | ||||||
| 		Inside: inside, | 		Device: inside, | ||||||
| 	}, nil | 	}, nil | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Nate Brown
					Nate Brown