func main() { useLocalServer := flag.Bool("useLocalServer", false, "Uses localhost server if true") flag.Parse() var client *goagent.MitroCoreClient var err error if *useLocalServer { client, err = goagent.NewClientInsecure("https://*****:*****@lectorius.com" data.SecretId = 18 data.CriticalData.Password = "******" data.CriticalData.OldPassword = "******" data.CriticalData.Note = "note" serialized, err := json.Marshal(data) panicIfError(err) // TODO: Add signature so this can actually get executed correctly? request := goagent.UpdateSecretFromAgentRequest{string(serialized), ""} err = client.UpdateSecretFromAgent(&request) panicIfError(err) fmt.Println("SUCCESS? (I think)") }
func main() { useLocalServer := flag.Bool("useLocalServer", false, "Uses localhost server if true") skipChangePasswords := flag.Bool("skipChangePasswords", false, "Does not change passwords on the real service if true") httpsPort := flag.Int("httpsPort", 8444, "Port number to listen on") httpPort := flag.Int("httpPort", 8445, "Port number to listen on") flag.Parse() var client *goagent.MitroCoreClient var err error if *useLocalServer { log.Print("WARNING: using insecure local server (error if not testing)") client, err = goagent.NewClientInsecure("https://localhost:8443") } else { client, err = goagent.NewClient("https://www.mitro.co") } if err != nil { panic(err.Error()) } changePassword := goagent.ChangePassword if *skipChangePasswords { log.Print("WARNING: not actually changing passwords (error if not testing)") changePassword = fakeChangePassword } server := ChangePasswordAgent{client, changePassword} http.Handle("/ChangePassword", &errorHandler{server.request}) httpAddr := fmt.Sprintf(":%d", *httpPort) u, err := url.Parse("http://localhost" + httpAddr) if err != nil { panic(err.Error()) } go serveHTTPSProxy(u, *httpsPort) log.Printf("serving on https://localhost:%d", *httpsPort) log.Printf("serving on http://localhost%s", httpAddr) err = http.ListenAndServe(httpAddr, nil) if err != nil { panic(err.Error()) } }