func main() { flag.Parse() logger.Info("Starting daemon.") interrupt := make(chan os.Signal, 1) signal.Notify(interrupt, os.Interrupt, os.Kill, syscall.SIGTERM) api, err := apiclient.New(&apiclient.Config{ APIBase: *apiBase, InstanceBase: *instanceBase, UserAgent: userAgent, Timeout: apiTimeout, }) if err != nil { logger.Fatalf("Init failed: %v.", err) } srv := &server.Server{store.New(api, &store.Config{ AccountRefreshFrequency: accountRefreshFrequency, AccountRefreshCooldown: accountRefreshCooldown, KeyRefreshFrequency: keyRefreshFrequency, KeyRefreshCooldown: keyRefreshCooldown, })} go func() { err := srv.Serve() logger.Fatalf("Server failed: %v.", err) }() for { select { case sig := <-interrupt: logger.Fatalf("Got interrupt: %v.", sig) } } }
func main() { if len(os.Args) != 2 { logger.Fatal("Invalid username argument to authorized keys command.") } client := &server.Client{} keys, err := client.AuthorizedKeys(os.Args[1]) if err != nil { logger.Fatalf("Authorized keys command failed: %v.", err) } for _, k := range keys { fmt.Println(k) } }