Files
openlan/pkg/api/switcher.go
2022-07-29 23:38:54 +08:00

33 lines
612 B
Go
Executable File

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,
}
}