diff --git a/main.go b/main.go index 36b179e..ee0fa42 100644 --- a/main.go +++ b/main.go @@ -11,11 +11,14 @@ import ( "path/filepath" "strconv" "strings" + "sync" "time" "github.com/joho/godotenv" ) +var mu sync.Mutex + func ipAddrFromRemoteAddr(s string) string { idx := strings.LastIndex(s, ":") if idx == -1 { @@ -64,6 +67,10 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) { files := r.MultipartForm.File["file"] + // Serialize access to the YubiKey + mu.Lock() + defer mu.Unlock() + for _, fileHeader := range files { file, err := fileHeader.Open() if err != nil {