StartServer starts the HTTP server with the specified configuration.
(c *config.Config)
| 30 | |
| 31 | // StartServer starts the HTTP server with the specified configuration. |
| 32 | func StartServer(c *config.Config) error { |
| 33 | var err error |
| 34 | apiConfig := c.API |
| 35 | if strings.HasPrefix(apiConfig.Transport, `npipe:///`) { |
| 36 | usr, err := user.Current() |
| 37 | if err != nil { |
| 38 | return fmt.Errorf("failed to retrieve the current user: %v", err) |
| 39 | } |
| 40 | // Named pipe security and access rights. |
| 41 | // We create the pipe and the specific users should only be able to write to it. |
| 42 | // See docs: https://docs.microsoft.com/en-us/windows/win32/ipc/named-pipe-security-and-access-rights |
| 43 | // String definition: https://docs.microsoft.com/en-us/windows/win32/secauthz/ace-strings |
| 44 | // Give generic read/write access to the specified user. |
| 45 | descriptor := "D:P(A;;GA;;;" + usr.Uid + ")" |
| 46 | listener, err = MakePipeListener(apiConfig.Transport, descriptor) |
| 47 | if err != nil { |
| 48 | return err |
| 49 | } |
| 50 | } else { |
| 51 | listener, err = makeTCPListener(apiConfig.Transport) |
| 52 | } |
| 53 | if err != nil { |
| 54 | return err |
| 55 | } |
| 56 | |
| 57 | setupServer(listener, c) |
| 58 | |
| 59 | return nil |
| 60 | } |
| 61 | |
| 62 | // CloseServer shutdowns the server by stopping the listener. |
| 63 | func CloseServer() error { |
no test coverage detected