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

@@ -27,7 +27,7 @@ func newTunFromFd(deviceFd int, cidr *net.IPNet, defaultMTU int, routes []route,
ifce = &Tun{
ReadWriteCloser: file,
fd: int(file.Fd()),
Device: "tun0",
Device: "android",
Cidr: cidr,
DefaultMTU: defaultMTU,
TXQueueLen: txQueueLen,
@@ -64,6 +64,13 @@ func (c *Tun) WriteRaw(b []byte) error {
}
func (c Tun) Activate() error {
c.Device = "android"
return nil
}
func (c *Tun) CidrNet() *net.IPNet {
return c.Cidr
}
func (c *Tun) DeviceName() string {
return c.Device
}