Skip to content
Snippets Groups Projects

Allow to reset key store and stop key fetching

Merged Malte Bauch requested to merge qkdnm-set-key-store into master
Files
22
@@ -38,7 +38,7 @@ func main() {
@@ -38,7 +38,7 @@ func main() {
router := http.NewServeMux()
router := http.NewServeMux()
router.HandleFunc("/api/v1/keys/push_ksa_key", handlePushKsaKey)
router.HandleFunc("/api/v1/keys/push_ksa_key", handlePushKsaKey)
router.HandleFunc("/debug/get_log_file", getLogFile)
router.HandleFunc("/debug/get_log_file", logFileRequest)
server := &http.Server{
server := &http.Server{
Addr: ":4444",
Addr: ":4444",
@@ -77,7 +77,25 @@ func main() {
@@ -77,7 +77,25 @@ func main() {
}
}
}
}
func getLogFile(w http.ResponseWriter, r *http.Request) {
func logFileRequest(w http.ResponseWriter, r *http.Request) {
 
if r.Method == http.MethodDelete {
 
if _, err := os.Stat("akms-simulator.log"); err == nil {
 
err := os.Remove("akms-simulator.log")
 
if err != nil {
 
logrus.Errorf("Error deleting log file: %s", err)
 
w.WriteHeader(http.StatusInternalServerError)
 
return
 
}
 
}
 
logrus.Info("Log file deleted or never existed in the first place")
 
w.WriteHeader(http.StatusNoContent)
 
return
 
} else if r.Method != http.MethodGet {
 
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
 
logrus.Errorf("Method not allowed: %s", r.Method)
 
return
 
}
 
logrus.Info("Log file requested")
logrus.Info("Log file requested")
http.ServeFile(w, r, "akms-simulator.log")
http.ServeFile(w, r, "akms-simulator.log")
}
}
Loading