fea: ipsec tunnel cli.

This commit is contained in:
Daniel Ding
2024-06-17 14:32:32 +08:00
parent 7c27b06b4e
commit 8799004044
20 changed files with 489 additions and 372 deletions

View File

@@ -1,5 +1,7 @@
package config
import "fmt"
type Output struct {
Segment int `json:"segment"`
Protocol string `json:"protocol,omitempty"` // gre, vxlan, etc.
@@ -8,3 +10,21 @@ type Output struct {
Link string `json:"link,omitempty"` // link name
Secret string `json:"secret"`
}
func (o *Output) Id() string {
return fmt.Sprintf("%s-%s-%d", o.Protocol, o.Remote, o.Segment)
}
func (o *Output) GenName() {
if o.Link == "" {
if o.Protocol == "gre" {
o.Link = fmt.Sprintf("%s%d", "gre", o.Segment)
} else if o.Protocol == "vxlan" {
o.Link = fmt.Sprintf("%s%d", "vxlan", o.Segment)
} else if o.Segment > 0 {
o.Link = fmt.Sprintf("%s.%d", o.Remote, o.Segment)
} else {
o.Link = o.Remote
}
}
}