First release

This commit is contained in:
KusakabeSi 2021-08-26 12:09:07 +00:00
parent 9e8e3ddc13
commit d8f7cb1b60
18 changed files with 38 additions and 28 deletions

View File

@ -9,7 +9,7 @@ MAKEFLAGS += --no-print-directory
generate-version-and-build: generate-version-and-build:
@export GIT_CEILING_DIRECTORIES="$(realpath $(CURDIR)/..)" && \ @export GIT_CEILING_DIRECTORIES="$(realpath $(CURDIR)/..)" && \
tag="$$(git describe --dirty 2>/dev/null)" && \ tag="$$(git describe 2>/dev/null)" && \
ver="$$(printf 'package main\n\nconst Version = "%s"\n' "$$tag")" && \ ver="$$(printf 'package main\n\nconst Version = "%s"\n' "$$tag")" && \
[ "$$(cat version.go 2>/dev/null)" != "$$ver" ] && \ [ "$$(cat version.go 2>/dev/null)" != "$$ver" ] && \
echo "$$ver" > version.go && \ echo "$$ver" > version.go && \
@ -25,13 +25,14 @@ etherguard-go: $(wildcard *.go) $(wildcard */*.go)
vpp: vpp:
@export GIT_CEILING_DIRECTORIES="$(realpath $(CURDIR)/..)" && \ @export GIT_CEILING_DIRECTORIES="$(realpath $(CURDIR)/..)" && \
tag="$$(git describe --dirty 2>/dev/null)" && \ tag="$$(git describe 2>/dev/null)" && \
ver="$$(printf 'package main\n\nconst Version = "%s"\n' "$$tag")" && \ ver="$$(printf 'package main\n\nconst Version = "%s"\n' "$$tag")" && \
[ "$$(cat version.go 2>/dev/null)" != "$$ver" ] && \ [ "$$(cat version.go 2>/dev/null)" != "$$ver" ] && \
echo "$$ver" > version.go && \ echo "$$ver" > version.go && \
git update-index --assume-unchanged version.go || true git update-index --assume-unchanged version.go || true
@$(MAKE) etherguard-go-vpp @$(MAKE) etherguard-go-vpp
etherguard-go-vpp: export CGO_CFLAGS ?= -I/usr/include/memif
etherguard-go-vpp: $(wildcard *.go) $(wildcard */*.go) etherguard-go-vpp: $(wildcard *.go) $(wildcard */*.go)
go mod download && \ go mod download && \
go mod tidy && \ go mod tidy && \
@ -47,5 +48,6 @@ test:
clean: clean:
rm -f etherguard-go rm -f etherguard-go
rm -f etherguard-go-vpp
.PHONY: all clean test install generate-version-and-build .PHONY: all clean test install generate-version-and-build

View File

@ -2,7 +2,7 @@ interface:
itype: stdio itype: stdio
name: tap1 name: tap1
vppifaceid: 1 vppifaceid: 1
vppbridgeid: 0 vppbridgeid: 4242
macaddrprefix: AA:BB:CC:DD:EE macaddrprefix: AA:BB:CC:DD:EE
mtu: 1400 mtu: 1400
recvaddr: 127.0.0.1:4001 recvaddr: 127.0.0.1:4001

View File

@ -2,7 +2,7 @@ interface:
itype: stdio itype: stdio
name: tap2 name: tap2
vppifaceid: 2 vppifaceid: 2
vppbridgeid: 0 vppbridgeid: 4242
macaddrprefix: AA:BB:CC:DD:EE macaddrprefix: AA:BB:CC:DD:EE
mtu: 1400 mtu: 1400
recvaddr: 127.0.0.1:4002 recvaddr: 127.0.0.1:4002

View File

@ -2,7 +2,7 @@ interface:
itype: stdio itype: stdio
name: tap3 name: tap3
vppifaceid: 3 vppifaceid: 3
vppbridgeid: 0 vppbridgeid: 4242
macaddrprefix: AA:BB:CC:DD:EE macaddrprefix: AA:BB:CC:DD:EE
mtu: 1400 mtu: 1400
recvaddr: 127.0.0.1:4003 recvaddr: 127.0.0.1:4003

View File

@ -2,7 +2,7 @@ interface:
itype: stdio itype: stdio
name: tap4 name: tap4
vppifaceid: 4 vppifaceid: 4
vppbridgeid: 0 vppbridgeid: 4242
macaddrprefix: AA:BB:CC:DD:EE macaddrprefix: AA:BB:CC:DD:EE
mtu: 1400 mtu: 1400
recvaddr: 127.0.0.1:4004 recvaddr: 127.0.0.1:4004

View File

@ -2,7 +2,7 @@ interface:
itype: stdio itype: stdio
name: tap5 name: tap5
vppifaceid: 5 vppifaceid: 5
vppbridgeid: 0 vppbridgeid: 4242
macaddrprefix: AA:BB:CC:DD:EE macaddrprefix: AA:BB:CC:DD:EE
mtu: 1400 mtu: 1400
recvaddr: 127.0.0.1:4005 recvaddr: 127.0.0.1:4005

View File

@ -2,7 +2,7 @@ interface:
itype: stdio itype: stdio
name: tap6 name: tap6
vppifaceid: 6 vppifaceid: 6
vppbridgeid: 0 vppbridgeid: 4242
macaddrprefix: AA:BB:CC:DD:EE macaddrprefix: AA:BB:CC:DD:EE
mtu: 1400 mtu: 1400
recvaddr: 127.0.0.1:4006 recvaddr: 127.0.0.1:4006

View File

@ -2,7 +2,7 @@ interface:
itype: stdio itype: stdio
name: tap1 name: tap1
vppifaceid: 1 vppifaceid: 1
vppbridgeid: 0 vppbridgeid: 4242
macaddrprefix: AA:BB:CC:DD:EE macaddrprefix: AA:BB:CC:DD:EE
mtu: 1400 mtu: 1400
recvaddr: 127.0.0.1:4001 recvaddr: 127.0.0.1:4001

View File

@ -2,7 +2,7 @@ interface:
itype: stdio itype: stdio
name: tap2 name: tap2
vppifaceid: 2 vppifaceid: 2
vppbridgeid: 0 vppbridgeid: 4242
macaddrprefix: AA:BB:CC:DD:EE macaddrprefix: AA:BB:CC:DD:EE
mtu: 1400 mtu: 1400
recvaddr: 127.0.0.1:4002 recvaddr: 127.0.0.1:4002

View File

@ -2,7 +2,7 @@ interface:
itype: stdio itype: stdio
name: tap3 name: tap3
vppifaceid: 3 vppifaceid: 3
vppbridgeid: 0 vppbridgeid: 4242
macaddrprefix: AA:BB:CC:DD:EE macaddrprefix: AA:BB:CC:DD:EE
mtu: 1400 mtu: 1400
recvaddr: 127.0.0.1:4003 recvaddr: 127.0.0.1:4003

View File

@ -2,7 +2,7 @@ interface:
itype: stdio itype: stdio
name: tap4 name: tap4
vppifaceid: 4 vppifaceid: 4
vppbridgeid: 0 vppbridgeid: 4242
macaddrprefix: AA:BB:CC:DD:EE macaddrprefix: AA:BB:CC:DD:EE
mtu: 1400 mtu: 1400
recvaddr: 127.0.0.1:4004 recvaddr: 127.0.0.1:4004

View File

@ -2,7 +2,7 @@ interface:
itype: stdio itype: stdio
name: tap5 name: tap5
vppifaceid: 5 vppifaceid: 5
vppbridgeid: 0 vppbridgeid: 4242
macaddrprefix: AA:BB:CC:DD:EE macaddrprefix: AA:BB:CC:DD:EE
mtu: 1400 mtu: 1400
recvaddr: 127.0.0.1:4005 recvaddr: 127.0.0.1:4005

View File

@ -2,7 +2,7 @@ interface:
itype: stdio itype: stdio
name: tap6 name: tap6
vppifaceid: 6 vppifaceid: 6
vppbridgeid: 0 vppbridgeid: 4242
macaddrprefix: AA:BB:CC:DD:EE macaddrprefix: AA:BB:CC:DD:EE
mtu: 1400 mtu: 1400
recvaddr: 127.0.0.1:4006 recvaddr: 127.0.0.1:4006

View File

@ -1,5 +1,5 @@
interface: interface:
itype: vpp itype: stdio
name: tap1 name: tap1
vppifaceid: 1 vppifaceid: 1
vppbridgeid: 4242 vppbridgeid: 4242

View File

@ -16,6 +16,7 @@ import (
"github.com/KusakabeSi/EtherGuardVPN/ipc" "github.com/KusakabeSi/EtherGuardVPN/ipc"
"github.com/KusakabeSi/EtherGuardVPN/path" "github.com/KusakabeSi/EtherGuardVPN/path"
"github.com/KusakabeSi/EtherGuardVPN/tap"
yaml "gopkg.in/yaml.v2" yaml "gopkg.in/yaml.v2"
) )
@ -54,7 +55,7 @@ var (
func main() { func main() {
flag.Parse() flag.Parse()
if *version == true { if *version == true {
fmt.Printf("etherguard-go v%s\n\nA mesh VPN %s-%s.\nInformation available at https://github.com/KusakabeSi/EtherGuardVPN.\nCopyright (C) Kusakabe Si <si@kskb.eu.org>.\n", Version, runtime.GOOS, runtime.GOARCH) fmt.Printf("etherguard-go v%s\n%s\n\nA full mesh VPN %s-%s.\nInformation available at https://github.com/KusakabeSi/EtherGuardVPN.\nCopyright (C) Kusakabe Si <si@kskb.eu.org>.\n", Version, tap.VPP_SUPPORT, runtime.GOOS, runtime.GOARCH)
return return
} }
if *help == true { if *help == true {

View File

@ -42,8 +42,8 @@ func (g *IG) RoutineSyncTime() {
return return
} }
for { for {
time.Sleep(S2TD(g.ntp_info.SyncTimeInterval))
g.SyncTimeMultiple(g.ntp_info.MaxServerUse) g.SyncTimeMultiple(g.ntp_info.MaxServerUse)
time.Sleep(S2TD(g.ntp_info.SyncTimeInterval))
} }
} }

View File

@ -29,6 +29,7 @@ import (
const ( const (
ENV_VPP_MEMIF_SOCKET_DIR = "VPP_MEMIF_SOCKET_DIR" ENV_VPP_MEMIF_SOCKET_DIR = "VPP_MEMIF_SOCKET_DIR"
ENV_VPP_SOCKET_PATH = "VPP_API_SOCKET_PATH" ENV_VPP_SOCKET_PATH = "VPP_API_SOCKET_PATH"
VPP_SUPPORT = "VPP support enabled"
) )
var ( var (
@ -183,16 +184,18 @@ func CreateVppTAP(iconfig config.InterfaceConf, loglevel string) (tapdev Device,
return nil, err return nil, err
} }
//set interface l2 bridge memif1/1 4242 if iconfig.VPPBridgeID != 0 {
_, err = l2service.SwInterfaceSetL2Bridge(context.Background(), &l2.SwInterfaceSetL2Bridge{ //set interface l2 bridge memif1/1 4242
RxSwIfIndex: tap.SwIfIndex, _, err = l2service.SwInterfaceSetL2Bridge(context.Background(), &l2.SwInterfaceSetL2Bridge{
BdID: iconfig.VPPBridgeID, RxSwIfIndex: tap.SwIfIndex,
PortType: l2.L2_API_PORT_TYPE_NORMAL, BdID: iconfig.VPPBridgeID,
Shg: 0, PortType: l2.L2_API_PORT_TYPE_NORMAL,
Enable: true, Shg: 0,
}) Enable: true,
if err != nil { })
return nil, err if err != nil {
return nil, err
}
} }
//init libmemif //init libmemif
libmemif.Init(tap.name) libmemif.Init(tap.name)

View File

@ -8,6 +8,10 @@ import (
"github.com/KusakabeSi/EtherGuardVPN/config" "github.com/KusakabeSi/EtherGuardVPN/config"
) )
const (
VPP_SUPPORT = "No VPP support"
)
type VppTap struct { type VppTap struct {
stopRead chan struct{} stopRead chan struct{}
events chan Event events chan Event
@ -15,7 +19,7 @@ type VppTap struct {
// New creates and returns a new TUN interface for the application. // New creates and returns a new TUN interface for the application.
func CreateVppTAP(iconfig config.InterfaceConf, loglevel string) (tapdev Device, err error) { func CreateVppTAP(iconfig config.InterfaceConf, loglevel string) (tapdev Device, err error) {
return nil, errors.New("VPP tap not compiled.") return nil, errors.New("VPP module not compiled.")
} }
func (tap *VppTap) Read([]byte, int) (int, error) { func (tap *VppTap) Read([]byte, int) (int, error) {