MCPcopy Create free account
hub / github.com/eventure/hide.client.linux / Init

Method Init

control/server.go:42–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40}
41
42func ( s *Server ) Init() ( err error ) {
43 network := "tcp" // Detect network type
44 if strings.Contains( s.Config.Address, "/" ) || strings.Contains( s.Config.Address, "@" ) { network = "unix" }
45
46 if s.listener, err = net.Listen( network, s.Config.Address ); err != nil { log.Println( "Init: [ERR] Listen failed:", err.Error() ); return }
47
48 mux := &http.ServeMux{}
49 mux.HandleFunc( "/configuration", s.configuration )
50 mux.HandleFunc( "/route", s.route )
51 mux.HandleFunc( "/connect", s.connect )
52 mux.HandleFunc( "/disconnect", s.disconnect )
53 mux.HandleFunc( "/shutdown", s.shutdown )
54 mux.HandleFunc( "/destroy", s.destroy )
55 mux.HandleFunc( "/state", s.state )
56 mux.HandleFunc( "/watch", s.watch )
57 mux.HandleFunc( "/token", s.token )
58 mux.HandleFunc( "/log", s.log )
59 mux.HandleFunc( "/serverList", s.serverList )
60 mux.HandleFunc( "/externalIps", s.externalIps )
61 mux.HandleFunc( "/version", s.version )
62 s.server = &http.Server{ Handler: mux, ReadHeaderTimeout: time.Second * 5 }
63
64 if s.Config.LineLogBufferSize > 0 {
65 log.SetFlags( log.LUTC | log.Ldate | log.Ltime )
66 log.SetOutput( NewRingLog( s.Config.LineLogBufferSize, log.Writer() ) )
67 }
68
69 if supported, err := daemon.SdNotify( false, daemon.SdNotifyReady ); supported && err != nil { // Send SystemD ready notification
70 log.Println( "Init: [ERR] SystemD notification failed:", err )
71 }
72 return
73}
74
75func ( s *Server ) Serve() ( err error ) {
76 if len( s.Config.Certificate ) > 0 && len( s.Config.Key ) > 0 {

Callers 4

mainFunction · 0.95
routeMethod · 0.45
connectMethod · 0.45
serverListMethod · 0.45

Calls 2

NewRingLogFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected