mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2024-11-21 23:03:08 +01:00
First release
This commit is contained in:
parent
9e8e3ddc13
commit
d8f7cb1b60
6
Makefile
6
Makefile
@ -9,7 +9,7 @@ MAKEFLAGS += --no-print-directory
|
||||
|
||||
generate-version-and-build:
|
||||
@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")" && \
|
||||
[ "$$(cat version.go 2>/dev/null)" != "$$ver" ] && \
|
||||
echo "$$ver" > version.go && \
|
||||
@ -25,13 +25,14 @@ etherguard-go: $(wildcard *.go) $(wildcard */*.go)
|
||||
|
||||
vpp:
|
||||
@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")" && \
|
||||
[ "$$(cat version.go 2>/dev/null)" != "$$ver" ] && \
|
||||
echo "$$ver" > version.go && \
|
||||
git update-index --assume-unchanged version.go || true
|
||||
@$(MAKE) etherguard-go-vpp
|
||||
|
||||
etherguard-go-vpp: export CGO_CFLAGS ?= -I/usr/include/memif
|
||||
etherguard-go-vpp: $(wildcard *.go) $(wildcard */*.go)
|
||||
go mod download && \
|
||||
go mod tidy && \
|
||||
@ -47,5 +48,6 @@ test:
|
||||
|
||||
clean:
|
||||
rm -f etherguard-go
|
||||
rm -f etherguard-go-vpp
|
||||
|
||||
.PHONY: all clean test install generate-version-and-build
|
||||
|
@ -2,7 +2,7 @@ interface:
|
||||
itype: stdio
|
||||
name: tap1
|
||||
vppifaceid: 1
|
||||
vppbridgeid: 0
|
||||
vppbridgeid: 4242
|
||||
macaddrprefix: AA:BB:CC:DD:EE
|
||||
mtu: 1400
|
||||
recvaddr: 127.0.0.1:4001
|
||||
|
@ -2,7 +2,7 @@ interface:
|
||||
itype: stdio
|
||||
name: tap2
|
||||
vppifaceid: 2
|
||||
vppbridgeid: 0
|
||||
vppbridgeid: 4242
|
||||
macaddrprefix: AA:BB:CC:DD:EE
|
||||
mtu: 1400
|
||||
recvaddr: 127.0.0.1:4002
|
||||
|
@ -2,7 +2,7 @@ interface:
|
||||
itype: stdio
|
||||
name: tap3
|
||||
vppifaceid: 3
|
||||
vppbridgeid: 0
|
||||
vppbridgeid: 4242
|
||||
macaddrprefix: AA:BB:CC:DD:EE
|
||||
mtu: 1400
|
||||
recvaddr: 127.0.0.1:4003
|
||||
|
@ -2,7 +2,7 @@ interface:
|
||||
itype: stdio
|
||||
name: tap4
|
||||
vppifaceid: 4
|
||||
vppbridgeid: 0
|
||||
vppbridgeid: 4242
|
||||
macaddrprefix: AA:BB:CC:DD:EE
|
||||
mtu: 1400
|
||||
recvaddr: 127.0.0.1:4004
|
||||
|
@ -2,7 +2,7 @@ interface:
|
||||
itype: stdio
|
||||
name: tap5
|
||||
vppifaceid: 5
|
||||
vppbridgeid: 0
|
||||
vppbridgeid: 4242
|
||||
macaddrprefix: AA:BB:CC:DD:EE
|
||||
mtu: 1400
|
||||
recvaddr: 127.0.0.1:4005
|
||||
|
@ -2,7 +2,7 @@ interface:
|
||||
itype: stdio
|
||||
name: tap6
|
||||
vppifaceid: 6
|
||||
vppbridgeid: 0
|
||||
vppbridgeid: 4242
|
||||
macaddrprefix: AA:BB:CC:DD:EE
|
||||
mtu: 1400
|
||||
recvaddr: 127.0.0.1:4006
|
||||
|
@ -2,7 +2,7 @@ interface:
|
||||
itype: stdio
|
||||
name: tap1
|
||||
vppifaceid: 1
|
||||
vppbridgeid: 0
|
||||
vppbridgeid: 4242
|
||||
macaddrprefix: AA:BB:CC:DD:EE
|
||||
mtu: 1400
|
||||
recvaddr: 127.0.0.1:4001
|
||||
|
@ -2,7 +2,7 @@ interface:
|
||||
itype: stdio
|
||||
name: tap2
|
||||
vppifaceid: 2
|
||||
vppbridgeid: 0
|
||||
vppbridgeid: 4242
|
||||
macaddrprefix: AA:BB:CC:DD:EE
|
||||
mtu: 1400
|
||||
recvaddr: 127.0.0.1:4002
|
||||
|
@ -2,7 +2,7 @@ interface:
|
||||
itype: stdio
|
||||
name: tap3
|
||||
vppifaceid: 3
|
||||
vppbridgeid: 0
|
||||
vppbridgeid: 4242
|
||||
macaddrprefix: AA:BB:CC:DD:EE
|
||||
mtu: 1400
|
||||
recvaddr: 127.0.0.1:4003
|
||||
|
@ -2,7 +2,7 @@ interface:
|
||||
itype: stdio
|
||||
name: tap4
|
||||
vppifaceid: 4
|
||||
vppbridgeid: 0
|
||||
vppbridgeid: 4242
|
||||
macaddrprefix: AA:BB:CC:DD:EE
|
||||
mtu: 1400
|
||||
recvaddr: 127.0.0.1:4004
|
||||
|
@ -2,7 +2,7 @@ interface:
|
||||
itype: stdio
|
||||
name: tap5
|
||||
vppifaceid: 5
|
||||
vppbridgeid: 0
|
||||
vppbridgeid: 4242
|
||||
macaddrprefix: AA:BB:CC:DD:EE
|
||||
mtu: 1400
|
||||
recvaddr: 127.0.0.1:4005
|
||||
|
@ -2,7 +2,7 @@ interface:
|
||||
itype: stdio
|
||||
name: tap6
|
||||
vppifaceid: 6
|
||||
vppbridgeid: 0
|
||||
vppbridgeid: 4242
|
||||
macaddrprefix: AA:BB:CC:DD:EE
|
||||
mtu: 1400
|
||||
recvaddr: 127.0.0.1:4006
|
||||
|
@ -1,5 +1,5 @@
|
||||
interface:
|
||||
itype: vpp
|
||||
itype: stdio
|
||||
name: tap1
|
||||
vppifaceid: 1
|
||||
vppbridgeid: 4242
|
||||
|
3
main.go
3
main.go
@ -16,6 +16,7 @@ import (
|
||||
|
||||
"github.com/KusakabeSi/EtherGuardVPN/ipc"
|
||||
"github.com/KusakabeSi/EtherGuardVPN/path"
|
||||
"github.com/KusakabeSi/EtherGuardVPN/tap"
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
@ -54,7 +55,7 @@ var (
|
||||
func main() {
|
||||
flag.Parse()
|
||||
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
|
||||
}
|
||||
if *help == true {
|
||||
|
@ -42,8 +42,8 @@ func (g *IG) RoutineSyncTime() {
|
||||
return
|
||||
}
|
||||
for {
|
||||
time.Sleep(S2TD(g.ntp_info.SyncTimeInterval))
|
||||
g.SyncTimeMultiple(g.ntp_info.MaxServerUse)
|
||||
time.Sleep(S2TD(g.ntp_info.SyncTimeInterval))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ import (
|
||||
const (
|
||||
ENV_VPP_MEMIF_SOCKET_DIR = "VPP_MEMIF_SOCKET_DIR"
|
||||
ENV_VPP_SOCKET_PATH = "VPP_API_SOCKET_PATH"
|
||||
VPP_SUPPORT = "VPP support enabled"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -183,16 +184,18 @@ func CreateVppTAP(iconfig config.InterfaceConf, loglevel string) (tapdev Device,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//set interface l2 bridge memif1/1 4242
|
||||
_, err = l2service.SwInterfaceSetL2Bridge(context.Background(), &l2.SwInterfaceSetL2Bridge{
|
||||
RxSwIfIndex: tap.SwIfIndex,
|
||||
BdID: iconfig.VPPBridgeID,
|
||||
PortType: l2.L2_API_PORT_TYPE_NORMAL,
|
||||
Shg: 0,
|
||||
Enable: true,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if iconfig.VPPBridgeID != 0 {
|
||||
//set interface l2 bridge memif1/1 4242
|
||||
_, err = l2service.SwInterfaceSetL2Bridge(context.Background(), &l2.SwInterfaceSetL2Bridge{
|
||||
RxSwIfIndex: tap.SwIfIndex,
|
||||
BdID: iconfig.VPPBridgeID,
|
||||
PortType: l2.L2_API_PORT_TYPE_NORMAL,
|
||||
Shg: 0,
|
||||
Enable: true,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
//init libmemif
|
||||
libmemif.Init(tap.name)
|
||||
|
@ -8,6 +8,10 @@ import (
|
||||
"github.com/KusakabeSi/EtherGuardVPN/config"
|
||||
)
|
||||
|
||||
const (
|
||||
VPP_SUPPORT = "No VPP support"
|
||||
)
|
||||
|
||||
type VppTap struct {
|
||||
stopRead chan struct{}
|
||||
events chan Event
|
||||
@ -15,7 +19,7 @@ type VppTap struct {
|
||||
|
||||
// New creates and returns a new TUN interface for the application.
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user