github.com/cloud-foundations/dominator@v0.0.0-20221004181915-6e4fee580046/hypervisor/tftpbootd/api.go (about) 1 package tftpbootd 2 3 import ( 4 "net" 5 "sync" 6 "time" 7 8 "github.com/Cloud-Foundations/Dominator/lib/filesystem" 9 "github.com/Cloud-Foundations/Dominator/lib/log" 10 "github.com/Cloud-Foundations/Dominator/lib/srpc" 11 "github.com/pin/tftp" 12 ) 13 14 type cachedFileSystem struct { 15 deleteTimer *time.Timer 16 fileSystem *filesystem.FileSystem 17 } 18 19 type TftpbootServer struct { 20 closeClientTimer *time.Timer 21 imageServerAddress string 22 logger log.DebugLogger 23 tftpdServer *tftp.Server 24 lock sync.Mutex 25 cachedFileSystems map[string]*cachedFileSystem // Key: image stream. 26 filesForIPs map[string]map[string][]byte 27 imageServerClientInUse bool 28 imageStreamName string 29 imageServerClientLock sync.Mutex 30 imageServerClient *srpc.Client 31 } 32 33 func New(imageServerAddress, imageStreamName string, 34 logger log.DebugLogger) (*TftpbootServer, error) { 35 return newServer(imageServerAddress, imageStreamName, logger) 36 } 37 38 func (s *TftpbootServer) RegisterFiles(ipAddr net.IP, files map[string][]byte) { 39 s.registerFiles(ipAddr, files) 40 } 41 42 func (s *TftpbootServer) SetImageStreamName(name string) { 43 s.setImageStreamName(name) 44 } 45 46 func (s *TftpbootServer) UnregisterFiles(ipAddr net.IP) { 47 s.unregisterFiles(ipAddr) 48 }