mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2024-11-21 23:03:08 +01:00
no-vpp version
This commit is contained in:
parent
4443b8bddf
commit
5fbb065897
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
go.sum
|
||||
etherguard-go
|
||||
etherguard-go-vpp
|
||||
vendor
|
||||
.ipynb_checkpoints
|
3
.vscode/launch.json
vendored
3
.vscode/launch.json
vendored
@ -10,8 +10,9 @@
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"program": "${workspaceFolder}",
|
||||
"buildFlags": "-tags=vpp",
|
||||
"env": {"CGO_CFLAGS":"-I/usr/include/memif"},
|
||||
"args":["-config","example_config/static_mode/path.txt","-mode","solve"/*,"-example"*/],
|
||||
"args":["-config","example_config/super_mode/n1.yaml","-mode","edge"/*,"-example"*/],
|
||||
}
|
||||
]
|
||||
}
|
16
Makefile
16
Makefile
@ -17,6 +17,22 @@ generate-version-and-build:
|
||||
@$(MAKE) etherguard-go
|
||||
|
||||
etherguard-go: $(wildcard *.go) $(wildcard */*.go)
|
||||
go mod download && \
|
||||
go mod tidy && \
|
||||
go mod vendor && \
|
||||
patch -p0 -i govpp_remove_crcstring_check.patch && \
|
||||
go build -v -tags novpp -o "$@"
|
||||
|
||||
vpp:
|
||||
@export GIT_CEILING_DIRECTORIES="$(realpath $(CURDIR)/..)" && \
|
||||
tag="$$(git describe --dirty 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: $(wildcard *.go) $(wildcard */*.go)
|
||||
go mod download && \
|
||||
go mod tidy && \
|
||||
go mod vendor && \
|
||||
|
@ -95,7 +95,7 @@ func (device *Device) NewPeer(pk NoisePublicKey, id config.Vertex) (*Peer, error
|
||||
|
||||
// create peer
|
||||
if device.LogLevel.LogControl {
|
||||
fmt.Println("Create peer with ID : " + id.ToString() + " and PubKey:" + base64.StdEncoding.EncodeToString(pk[:]))
|
||||
fmt.Println("Control: Create peer with ID : " + id.ToString() + " and PubKey:" + base64.StdEncoding.EncodeToString(pk[:]))
|
||||
}
|
||||
peer := new(Peer)
|
||||
peer.Lock()
|
||||
|
@ -1,8 +1,8 @@
|
||||
interface:
|
||||
itype: stdio
|
||||
itype: vpp
|
||||
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
main.go
2
main.go
@ -54,7 +54,7 @@ var (
|
||||
func main() {
|
||||
flag.Parse()
|
||||
if *version == true {
|
||||
fmt.Printf("wireguard-go v%s\n\nUserspace WireGuard daemon for %s-%s.\nInformation available at https://www.wireguard.com.\nCopyright (C) Jason A. Donenfeld <Jason@zx2c4.com>.\n", Version, runtime.GOOS, runtime.GOARCH)
|
||||
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)
|
||||
return
|
||||
}
|
||||
if *help == true {
|
||||
|
26
main_edge.go
26
main_edge.go
@ -108,18 +108,18 @@ func printExampleEdgeConf() {
|
||||
}
|
||||
g := path.NewGraph(3, false, tconfig.DynamicRoute.P2P.GraphRecalculateSetting, tconfig.DynamicRoute.NTPconfig, false)
|
||||
|
||||
g.UpdateLentancy(1, 2, path.S2TD(0.5), false,false)
|
||||
g.UpdateLentancy(2, 1, path.S2TD(0.5), false,false)
|
||||
g.UpdateLentancy(2, 3, path.S2TD(0.5), false,false)
|
||||
g.UpdateLentancy(3, 2, path.S2TD(0.5), false,false)
|
||||
g.UpdateLentancy(2, 4, path.S2TD(0.5), false,false)
|
||||
g.UpdateLentancy(4, 2, path.S2TD(0.5), false,false)
|
||||
g.UpdateLentancy(3, 4, path.S2TD(0.5), false,false)
|
||||
g.UpdateLentancy(4, 3, path.S2TD(0.5), false,false)
|
||||
g.UpdateLentancy(5, 3, path.S2TD(0.5), false,false)
|
||||
g.UpdateLentancy(3, 5, path.S2TD(0.5), false,false)
|
||||
g.UpdateLentancy(6, 4, path.S2TD(0.5), false,false)
|
||||
g.UpdateLentancy(4, 6, path.S2TD(0.5), false,false)
|
||||
g.UpdateLentancy(1, 2, path.S2TD(0.5), false, false)
|
||||
g.UpdateLentancy(2, 1, path.S2TD(0.5), false, false)
|
||||
g.UpdateLentancy(2, 3, path.S2TD(0.5), false, false)
|
||||
g.UpdateLentancy(3, 2, path.S2TD(0.5), false, false)
|
||||
g.UpdateLentancy(2, 4, path.S2TD(0.5), false, false)
|
||||
g.UpdateLentancy(4, 2, path.S2TD(0.5), false, false)
|
||||
g.UpdateLentancy(3, 4, path.S2TD(0.5), false, false)
|
||||
g.UpdateLentancy(4, 3, path.S2TD(0.5), false, false)
|
||||
g.UpdateLentancy(5, 3, path.S2TD(0.5), false, false)
|
||||
g.UpdateLentancy(3, 5, path.S2TD(0.5), false, false)
|
||||
g.UpdateLentancy(6, 4, path.S2TD(0.5), false, false)
|
||||
g.UpdateLentancy(4, 6, path.S2TD(0.5), false, false)
|
||||
_, next := path.FloydWarshall(g)
|
||||
tconfig.NextHopTable = next
|
||||
toprint, _ := yaml.Marshal(tconfig)
|
||||
@ -155,6 +155,8 @@ func Edge(configPath string, useUAPI bool, printExample bool) (err error) {
|
||||
logLevel = device.LogLevelError
|
||||
case "silent":
|
||||
logLevel = device.LogLevelSilent
|
||||
default:
|
||||
logLevel = device.LogLevelError
|
||||
}
|
||||
logger := device.NewLogger(
|
||||
logLevel,
|
||||
|
@ -88,6 +88,8 @@ func Super(configPath string, useUAPI bool, printExample bool) (err error) {
|
||||
logLevel = device.LogLevelError
|
||||
case "silent":
|
||||
logLevel = device.LogLevelSilent
|
||||
default:
|
||||
logLevel = device.LogLevelError
|
||||
}
|
||||
|
||||
logger4 := device.NewLogger(
|
||||
|
@ -1,3 +1,5 @@
|
||||
//+build !novpp
|
||||
|
||||
package tap
|
||||
|
||||
import (
|
||||
@ -135,6 +137,7 @@ func CreateVppTAP(iconfig config.InterfaceConf, loglevel string) (tapdev Device,
|
||||
memifSockPath: path.Join(vppMemifSocketDir, iconfig.Name+".sock"),
|
||||
secret: config.RandomStr(16, iconfig.Name),
|
||||
logger: log,
|
||||
RxintChNext: make(chan uint8, 1<<6),
|
||||
errors: make(chan error, 1<<5),
|
||||
events: make(chan Event, 1<<4),
|
||||
}
|
||||
@ -235,8 +238,8 @@ func CreateVppTAP(iconfig config.InterfaceConf, loglevel string) (tapdev Device,
|
||||
tap.RxintCh = memif.GetInterruptChan()
|
||||
tap.RxintErrCh = memif.GetInterruptErrorChan()
|
||||
tap.TxQueues = len(details.TxQueues)
|
||||
tapdev.Events() <- EventUp
|
||||
return
|
||||
tap.events <- EventUp
|
||||
return tap, nil
|
||||
}
|
||||
|
||||
// SetMTU sets the Maximum Tansmission Unit Size for a
|
||||
@ -323,8 +326,6 @@ func (tap *VppTap) Close() error {
|
||||
|
||||
memifservice := memif.NewServiceClient(conn)
|
||||
|
||||
tap.memif.Close()
|
||||
libmemif.Cleanup()
|
||||
// delete interface memif memif1/1
|
||||
_, err = memifservice.MemifDelete(context.Background(), &memif.MemifDelete{
|
||||
SwIfIndex: tap.SwIfIndex,
|
||||
@ -335,7 +336,10 @@ func (tap *VppTap) Close() error {
|
||||
SocketID: tap.ifuid,
|
||||
SocketFilename: tap.memifSockPath,
|
||||
})
|
||||
go tap.memif.Close()
|
||||
go libmemif.Cleanup()
|
||||
tap.events <- EventDown
|
||||
close(tap.errors)
|
||||
close(tap.events)
|
||||
return nil
|
||||
} // stops the device and closes the event channel
|
||||
|
41
tap/tap_vpp_fake.go
Normal file
41
tap/tap_vpp_fake.go
Normal file
@ -0,0 +1,41 @@
|
||||
//+build novpp
|
||||
|
||||
package tap
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/KusakabeSi/EtherGuardVPN/config"
|
||||
)
|
||||
|
||||
type VppTap struct {
|
||||
stopRead chan struct{}
|
||||
events chan Event
|
||||
}
|
||||
|
||||
// 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.")
|
||||
}
|
||||
|
||||
func (tap *VppTap) Read([]byte, int) (int, error) {
|
||||
return 0, errors.New("Device stopped")
|
||||
}
|
||||
func (tap *VppTap) Write(packet []byte, size int) (int, error) {
|
||||
return size, nil
|
||||
}
|
||||
func (tap *VppTap) Flush() error {
|
||||
return nil
|
||||
}
|
||||
func (tap *VppTap) MTU() (int, error) {
|
||||
return 1500, nil
|
||||
}
|
||||
func (tap *VppTap) Name() (string, error) {
|
||||
return "Invalid device", nil
|
||||
}
|
||||
func (tap *VppTap) Events() chan Event {
|
||||
return tap.events
|
||||
}
|
||||
func (tap *VppTap) Close() error {
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user