mirror of
https://github.com/luscis/openlan.git
synced 2025-11-01 13:02:41 +08:00
clone from danieldin95
This commit is contained in:
32
pkg/api/switcher.go
Executable file
32
pkg/api/switcher.go
Executable 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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user