clone from danieldin95

This commit is contained in:
sicheng
2022-07-29 23:38:54 +08:00
commit ac4f79bbf4
1931 changed files with 568263 additions and 0 deletions

32
pkg/api/switcher.go Executable file
View File

@@ -0,0 +1,32 @@
package api
import (
"github.com/luscis/openlan/pkg/config"
"github.com/luscis/openlan/pkg/libol"
"github.com/luscis/openlan/pkg/network"
"github.com/luscis/openlan/pkg/schema"
)
type Switcher interface {
UUID() string
UpTime() int64
Alias() string
Config() *config.Switch
Server() libol.SocketServer
Firewall() *network.FireWall
Reload()
Save()
}
func NewWorkerSchema(s Switcher) schema.Worker {
protocol := ""
if cfg := s.Config(); cfg != nil {
protocol = cfg.Protocol
}
return schema.Worker{
UUID: s.UUID(),
Uptime: s.UpTime(),
Alias: s.Alias(),
Protocol: protocol,
}
}