mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2025-02-26 04:00:47 +01:00
PostScript
This commit is contained in:
parent
a8d5a2a602
commit
61df11f9f0
@ -70,6 +70,7 @@ Usage of ./etherguard-go:
|
||||
5. `tap`: Read/Write to tap device from linux.
|
||||
Paramaters: `name`,`macaddrprefix`,`vppifaceid`,`mtu`
|
||||
2. `name` : Device name
|
||||
3. `postscript`: run script after etherguard initialized.
|
||||
3. `vppifaceid`: Interface ID。Muse be unique in same VPP runtime
|
||||
4. `vppbridgeid`: VPP Bridge ID. Fill 0 if you don't use it.
|
||||
5. `macaddrprefix`: Mac address Prefix.
|
||||
|
@ -91,6 +91,7 @@ Usage of ./etherguard-go-vpp:
|
||||
3. `noL2`: 拔掉L2 Header的模式。
|
||||
但是本VPN會查詢L2用作選路,所以會變成一律廣播
|
||||
2. `nodeid`: 節點ID。節點之間辨識身分用的,同一網路內節點ID不能重複
|
||||
3. `postscript`: etherguard初始化完畢之後要跑的腳本.
|
||||
3. `nodename`: 節點名稱
|
||||
4. `defaultttl`: 預設ttl(etherguard層使用,和乙太層不共通)
|
||||
5. `l2fibtimeout`: MacAddr-> NodeID 查找表的 timeout(秒)
|
||||
|
@ -20,6 +20,7 @@ type EdgeConfig struct {
|
||||
Interface InterfaceConf
|
||||
NodeID Vertex
|
||||
NodeName string
|
||||
PostScript string
|
||||
DefaultTTL uint8
|
||||
L2FIBTimeout float64
|
||||
PrivKey string
|
||||
@ -33,6 +34,7 @@ type EdgeConfig struct {
|
||||
|
||||
type SuperConfig struct {
|
||||
NodeName string
|
||||
PostScript string
|
||||
PrivKeyV4 string
|
||||
PrivKeyV6 string
|
||||
ListenPort int
|
||||
|
2
example_config/echo.sh
Executable file
2
example_config/echo.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
echo "echo.sh" "$@"
|
@ -9,6 +9,7 @@ interface:
|
||||
sendaddr: 127.0.0.1:5001
|
||||
l2headermode: kbdbg
|
||||
nodeid: 1
|
||||
postscript: example_config/echo.sh test
|
||||
nodename: Node01
|
||||
defaultttl: 200
|
||||
l2fibtimeout: 3600
|
||||
|
@ -10,6 +10,7 @@ interface:
|
||||
l2headermode: kbdbg
|
||||
nodeid: 2
|
||||
nodename: Node02
|
||||
postscript: example_config/echo.sh test
|
||||
defaultttl: 200
|
||||
l2fibtimeout: 3600
|
||||
privkey: OH8BsVUU2Rqzeu9B2J5GPG8PUmxWfX8uVvNFZKhVF3o=
|
||||
|
@ -1,4 +1,5 @@
|
||||
nodename: NodeSuper
|
||||
postscript: example_config/echo.sh test
|
||||
privkeyv4: mL5IW0GuqbjgDeOJuPHBU2iJzBPNKhaNEXbIGwwYWWk=
|
||||
privkeyv6: +EdOKIoBp/EvIusHDsvXhV1RJYbyN3Qr8nxlz35wl3I=
|
||||
listenport: 3000
|
||||
|
1
go.mod
1
go.mod
@ -8,6 +8,7 @@ require (
|
||||
github.com/KusakabeSi/go-cache v0.0.0-20210823132304-22b5b1d22b41
|
||||
github.com/beevik/ntp v0.3.0
|
||||
github.com/google/gopacket v1.1.19
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
|
||||
github.com/sirupsen/logrus v1.6.0
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1
|
||||
|
23
main_edge.go
23
main_edge.go
@ -11,10 +11,13 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"syscall"
|
||||
|
||||
"github.com/google/shlex"
|
||||
|
||||
"github.com/KusakabeSi/EtherGuardVPN/config"
|
||||
"github.com/KusakabeSi/EtherGuardVPN/conn"
|
||||
"github.com/KusakabeSi/EtherGuardVPN/device"
|
||||
@ -40,6 +43,7 @@ func printExampleEdgeConf() {
|
||||
},
|
||||
NodeID: 1,
|
||||
NodeName: "Node01",
|
||||
PostScript: "",
|
||||
DefaultTTL: 200,
|
||||
L2FIBTimeout: 3600,
|
||||
PrivKey: "6GyDagZKhbm5WNqMiRHhkf43RlbMJ34IieTlIuvfJ1M=",
|
||||
@ -318,8 +322,25 @@ func Edge(configPath string, useUAPI bool, printExample bool, bindmode string) (
|
||||
startUAPI(NodeName, logger, the_device, errs)
|
||||
}
|
||||
|
||||
// wait for program to terminate
|
||||
if econfig.PostScript != "" {
|
||||
cmdarg, err := shlex.Split(econfig.PostScript)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error parse PostScript %v\n", err)
|
||||
}
|
||||
if econfig.LogLevel.LogInternal {
|
||||
fmt.Printf("PostScript: exec.Command(%v)\n", cmdarg)
|
||||
}
|
||||
cmd := exec.Command(cmdarg[0], cmdarg[1:]...)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("exec.Command(%v) failed with %v\n", cmdarg, err)
|
||||
}
|
||||
if econfig.LogLevel.LogInternal {
|
||||
fmt.Printf("PostScript output: %s\n", string(out))
|
||||
}
|
||||
}
|
||||
|
||||
// wait for program to terminate
|
||||
signal.Notify(term, syscall.SIGTERM)
|
||||
signal.Notify(term, os.Interrupt)
|
||||
|
||||
|
@ -16,11 +16,14 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/google/shlex"
|
||||
|
||||
"github.com/KusakabeSi/EtherGuardVPN/config"
|
||||
"github.com/KusakabeSi/EtherGuardVPN/conn"
|
||||
"github.com/KusakabeSi/EtherGuardVPN/device"
|
||||
@ -66,6 +69,7 @@ func printExampleSuperConf() {
|
||||
|
||||
sconfig := config.SuperConfig{
|
||||
NodeName: "NodeSuper",
|
||||
PostScript: "",
|
||||
PrivKeyV4: "mL5IW0GuqbjgDeOJuPHBU2iJzBPNKhaNEXbIGwwYWWk=",
|
||||
PrivKeyV6: "+EdOKIoBp/EvIusHDsvXhV1RJYbyN3Qr8nxlz35wl3I=",
|
||||
ListenPort: 3000,
|
||||
@ -240,14 +244,32 @@ func Super(configPath string, useUAPI bool, printExample bool, bindmode string)
|
||||
}
|
||||
defer uapi6.Close()
|
||||
}
|
||||
signal.Notify(term, syscall.SIGTERM)
|
||||
signal.Notify(term, os.Interrupt)
|
||||
|
||||
go Event_server_event_hendler(http_graph, http_super_chains)
|
||||
go RoutinePushSettings(path.S2TD(sconfig.RePushConfigInterval))
|
||||
go RoutineTimeoutCheck()
|
||||
go HttpServer(sconfig.ListenPort, "/api")
|
||||
|
||||
if sconfig.PostScript != "" {
|
||||
cmdarg, err := shlex.Split(sconfig.PostScript)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error parse PostScript %v\n", err)
|
||||
}
|
||||
if sconfig.LogLevel.LogInternal {
|
||||
fmt.Printf("PostScript: exec.Command(%v)\n", cmdarg)
|
||||
}
|
||||
cmd := exec.Command(cmdarg[0], cmdarg[1:]...)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("exec.Command(%v) failed with %v\n", cmdarg, err)
|
||||
}
|
||||
if sconfig.LogLevel.LogInternal {
|
||||
fmt.Printf("PostScript output: %s\n", string(out))
|
||||
}
|
||||
}
|
||||
|
||||
signal.Notify(term, syscall.SIGTERM)
|
||||
signal.Notify(term, os.Interrupt)
|
||||
select {
|
||||
case <-term:
|
||||
case <-errs:
|
||||
|
Loading…
Reference in New Issue
Block a user