mirror of
https://github.com/luscis/openlan.git
synced 2025-10-24 17:30:57 +08:00
fea: ipsec tunnel cli.
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user