github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/ChaparKhane/server.go (about) 1 /* For license and copyright information please see LEGAL file in repository */ 2 3 package chaparkhane 4 5 // DefaultServer use as default server. 6 var DefaultServer = &defaultServer 7 var defaultServer Server 8 9 // Server store 10 type Server struct { 11 Status int // States locate in this file. 12 Manifest Manifest 13 Services services 14 UserConnections userConnections 15 RouterConnections routerConnections 16 Security security 17 } 18 19 // Server Status 20 const ( 21 // ServerStateStop indicate server had been stopped 22 ServerStateStop int = iota 23 // ServerStateRunning indicate server is working 24 ServerStateRunning 25 // ServerStateStopping indicate server want to stop 26 ServerStateStopping 27 // ServerStateStarting indicate server plan to start and working on it 28 ServerStateStarting 29 ) 30 31 // Init method use to initialize related object with default data to prevent from panic! 32 func (s *Server) Init() { 33 if s == nil { 34 s = DefaultServer 35 } 36 s.Services.init() 37 s.UserConnections.init() 38 } 39 40 // Start will start the server. 41 func (s *Server) Start() (err error) { 42 43 return 44 } 45 46 // New XP node calculate path (latency and capacity) to all exiting node and send new information to all exiting node 47 // XPs can recalculate path and tell others about any change just if any change to their physical links! 48 // - multiple routes to the same place to be assigned the same cost and will cause traffic to be distributed evenly over those routes 49 50 // var err error 51 // err = gp.CheckPacket() 52 // if err != nil { 53 // // Send response or just ignore packet 54 // // TODO : DDOS!!?? 55 // return 56 // }