mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2024-11-21 23:03:08 +01:00
MAC address suffix now use NodeID instead of VPPIfaceID
This commit is contained in:
parent
0cff923ed6
commit
612901c16a
@ -54,7 +54,9 @@ Usage of ./etherguard-go:
|
||||
2. `name` : Device name
|
||||
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。Real Mac address=[Prefix]:[vppifaceid]。
|
||||
5. `macaddrprefix`: Mac address Prefix.
|
||||
Real Mac address=[Prefix]:[NodeID].
|
||||
If you fill full mac address here, NodeID will be ignored.
|
||||
6. `recvaddr`: Listen address for `udpsock` mode
|
||||
7. `sendaddr`: Packet send address for `udpsock` mode
|
||||
8. `l2headermode`: For debug usage, `stdio` and `udpsock` mode only
|
||||
@ -68,8 +70,7 @@ Usage of ./etherguard-go:
|
||||
4. `privkey`: Private key. Same spec as wireguard.
|
||||
5. `listenport`: UDP lesten port
|
||||
6. `loglevel`: Log Level
|
||||
1. `loglevel`: wireguard原本的log紀錄器的loglevel。
|
||||
有`debug`,`error`,`slient`三種程度
|
||||
1. `loglevel`: `debug`,`error`,`slient` for wirefuard logger.
|
||||
2. `logtransit`: Log packets that neither the source or distenation is self.
|
||||
3. `logcontrol`: Log for all Control Message.
|
||||
4. `lognormal`: Log packets that either the source or distenation is self.
|
||||
|
@ -63,8 +63,8 @@ Usage of ./etherguard-go-vpp:
|
||||
2. `name` : 裝置名稱
|
||||
3. `vppifaceid`: VPP 的 interface ID。一個VPP runtime內不能重複
|
||||
4. `vppbridgeid`: VPP 的網橋ID。不使用VPP網橋功能的話填0
|
||||
5. `macaddrprefix`: MA C地址前綴。真正的 MAC 地址=[前綴]:[vppifaceid]。
|
||||
如果填了6格長度就忽略`vppifaceid`
|
||||
5. `macaddrprefix`: MAC地址前綴。真正的 MAC 地址=[前綴]:[NodeID]。
|
||||
如果這邊填了完整6格長度,就忽略`NodeID`
|
||||
6. `recvaddr`: 僅限`udpsock`生效。收到的東西丟去 VPN 網路
|
||||
7. `sendaddr`: 僅限`udpsock`生效。VPN網路收到的東西丟去這個 udp 地址
|
||||
8. `l2headermode`: 僅限 `stdio` 和 `udpsock` 生效。debug用途,有三種模式:
|
||||
|
10
main_edge.go
10
main_edge.go
@ -181,17 +181,15 @@ func Edge(configPath string, useUAPI bool, printExample bool) (err error) {
|
||||
case "dummy":
|
||||
thetap, err = tap.CreateDummyTAP()
|
||||
case "stdio":
|
||||
tconfig.Interface.VPPIfaceID = uint32(tconfig.NodeID)
|
||||
thetap, err = tap.CreateStdIOTAP(tconfig.Interface)
|
||||
thetap, err = tap.CreateStdIOTAP(tconfig.Interface,tconfig.NodeID)
|
||||
case "udpsock":
|
||||
tconfig.Interface.VPPIfaceID = uint32(tconfig.NodeID)
|
||||
lis, _ := net.ResolveUDPAddr("udp", tconfig.Interface.RecvAddr)
|
||||
sen, _ := net.ResolveUDPAddr("udp", tconfig.Interface.SendAddr)
|
||||
thetap, err = tap.CreateUDPSockTAP(tconfig.Interface, lis, sen)
|
||||
thetap, err = tap.CreateUDPSockTAP(tconfig.Interface,tconfig.NodeID, lis, sen)
|
||||
case "vpp":
|
||||
thetap, err = tap.CreateVppTAP(tconfig.Interface, tconfig.LogLevel.LogLevel)
|
||||
thetap, err = tap.CreateVppTAP(tconfig.Interface,tconfig.NodeID,tconfig.LogLevel.LogLevel)
|
||||
case "tap":
|
||||
thetap, err = tap.CreateTAP(tconfig.Interface)
|
||||
thetap, err = tap.CreateTAP(tconfig.Interface,tconfig.NodeID)
|
||||
default:
|
||||
return errors.New("Unknow interface type:" + tconfig.Interface.Itype)
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ func (tap *NativeTap) Close() error {
|
||||
return err2
|
||||
}
|
||||
|
||||
func CreateTAP(iconfig config.InterfaceConf) (Device, error) {
|
||||
func CreateTAP(iconfig config.InterfaceConf,NodeID config.Vertex) (Device, error) {
|
||||
nfd, err := unix.Open(cloneDevicePath, os.O_RDWR, 0)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
@ -490,10 +490,10 @@ func CreateTAP(iconfig config.InterfaceConf) (Device, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return CreateTAPFromFile(fd, iconfig)
|
||||
return CreateTAPFromFile(fd, iconfig,NodeID)
|
||||
}
|
||||
|
||||
func CreateTAPFromFile(file *os.File, iconfig config.InterfaceConf) (Device, error) {
|
||||
func CreateTAPFromFile(file *os.File, iconfig config.InterfaceConf,NodeID config.Vertex) (Device, error) {
|
||||
tap := &NativeTap{
|
||||
tapFile: file,
|
||||
events: make(chan Event, 5),
|
||||
@ -533,7 +533,7 @@ func CreateTAPFromFile(file *os.File, iconfig config.InterfaceConf) (Device, err
|
||||
unix.Close(tap.netlinkSock)
|
||||
return nil, err
|
||||
}
|
||||
IfMacAddr, err := GetMacAddr(iconfig.MacAddrPrefix, iconfig.VPPIfaceID)
|
||||
IfMacAddr, err := GetMacAddr(iconfig.MacAddrPrefix, uint32(NodeID))
|
||||
if err != nil {
|
||||
fmt.Println("ERROR: Failed parse mac address:", iconfig.MacAddrPrefix)
|
||||
return nil, err
|
||||
|
@ -51,13 +51,13 @@ func Mac2charForm(m []byte) byte {
|
||||
}
|
||||
|
||||
// New creates and returns a new TUN interface for the application.
|
||||
func CreateStdIOTAP(iconfig config.InterfaceConf) (tapdev Device, err error) {
|
||||
func CreateStdIOTAP(iconfig config.InterfaceConf,NodeID config.Vertex) (tapdev Device, err error) {
|
||||
// Setup TUN Config
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
macaddr, err := GetMacAddr(iconfig.MacAddrPrefix, iconfig.VPPIfaceID)
|
||||
macaddr, err := GetMacAddr(iconfig.MacAddrPrefix,uint32(NodeID))
|
||||
if err != nil {
|
||||
fmt.Println("ERROR: Failed parse mac address:", iconfig.MacAddrPrefix)
|
||||
return nil, err
|
||||
|
@ -18,14 +18,14 @@ type UdpSockTap struct {
|
||||
}
|
||||
|
||||
// New creates and returns a new TUN interface for the application.
|
||||
func CreateUDPSockTAP(iconfig config.InterfaceConf, listenAddr *net.UDPAddr, sendAddr *net.UDPAddr) (tapdev Device, err error) {
|
||||
func CreateUDPSockTAP(iconfig config.InterfaceConf,NodeID config.Vertex, listenAddr *net.UDPAddr, sendAddr *net.UDPAddr) (tapdev Device, err error) {
|
||||
// Setup TUN Config
|
||||
|
||||
listener, err := net.ListenUDP("udp", listenAddr)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
macaddr, err := GetMacAddr(iconfig.MacAddrPrefix, iconfig.VPPIfaceID)
|
||||
macaddr, err := GetMacAddr(iconfig.MacAddrPrefix,uint32(NodeID))
|
||||
if err != nil {
|
||||
fmt.Println("ERROR: Failed parse mac address:", iconfig.MacAddrPrefix)
|
||||
return nil, err
|
||||
|
@ -63,7 +63,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) {
|
||||
func CreateVppTAP(iconfig config.InterfaceConf,NodeID config.Vertex, loglevel string) (tapdev Device, err error) {
|
||||
// Setup TUN Config
|
||||
if len(iconfig.Name) >= unix.IFNAMSIZ {
|
||||
return nil, fmt.Errorf("interface name too long: %w", unix.ENAMETOOLONG)
|
||||
@ -123,7 +123,7 @@ func CreateVppTAP(iconfig config.InterfaceConf, loglevel string) (tapdev Device,
|
||||
l2service := l2.NewServiceClient(conn)
|
||||
interfacservice := interfaces.NewServiceClient(conn)
|
||||
|
||||
IfMacAddr, err := GetMacAddr(iconfig.MacAddrPrefix, iconfig.VPPIfaceID)
|
||||
IfMacAddr, err := GetMacAddr(iconfig.MacAddrPrefix,uint32(NodeID))
|
||||
if err != nil {
|
||||
log.Fatalln("ERROR: Failed parse mac address:", iconfig.MacAddrPrefix)
|
||||
return nil, err
|
||||
|
@ -18,7 +18,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) {
|
||||
func CreateVppTAP(iconfig config.InterfaceConf,NodeID config.Vertex, loglevel string) (tapdev Device, err error) {
|
||||
return nil, errors.New("VPP module not compiled.")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user