Skip to content

Commit

Permalink
Fix gorilla mux startup panic. Bump dependencies
Browse files Browse the repository at this point in the history
- fix startup panic due to change in regexp matching in gorilla/mux
- bump sjcl and clipboard.js
- bump to go.uuid
  • Loading branch information
jhaals committed May 4, 2017
1 parent d89ee30 commit 9645214
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-route.min.js" integrity="sha256-cSGSOcFF66XhVJmkBJLDSHDSYEd32PmWU4Wpc+0oRXk= sha384-vKUG6ZisndNtIFOTSdC1VoTcFLTD9Iv5KMkeIAYhTVQvXaDs6zCW1M3ceLyVccge sha512-nQ5xr3a2uSzXywQV3u71CO+D02Lw126IFf8aj5epptUpmtRwDzI4ri+DbZBYQOpGWnmWIYHHQ1Ybyo4qg0i/7A==" crossorigin="anonymous"></script>

<script type="text/javascript" src="js/app.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.5.12/clipboard.min.js" integrity="sha256-YPxFEfHAzLj9n2T+2UXAKGNCRUINk0BexppujiVhRH0= sha384-zD0rXhmVlFWUQYNE6qhnghclEAj+YgdpXMO/izgNBWhg9CZTYfQx/LlgPCUfSH7V sha512-KFWecP2K4Gw2jaWso5S9+6pOt0/Kb9O5QI/itUPLoXajRaRqLXVMPfyBWtf75VB0DO7hBhbyMINtXdLfiYrqWQ==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sjcl/1.0.0/sjcl.min.js" integrity="sha256-UC26B+OwjcmDTkG0Sn5QqmxxJMGtiTMa3hsqp4m0JdI= sha384-4ZQxwTQVe6JKB1ZW/OMGW4b82BLHuCAhJoMCHS9TKe3pflXqmyezPpR5AnxqBqs0 sha512-w+6QCvB8/xlf0o6j69H2R2am+X7PR4isJxWRXDDrRXOPLaf4r0wqHZL9rR72SWM6jPUCUD8jteKqbOULtemUcw==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.6.1/clipboard.min.js" integrity="sha384-5Xf4OcJaQulbWLJD5/jIRdA35xOLc089T+KA+CcwO/azAqGzJQLaOeHiAAbl8XSf" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sjcl/1.0.6/sjcl.min.js" integrity="sha384-uUk05Hm5S/G7X2TUGZj9GIX4zH0Z/Enc47TkjSCCJCoR0jOdAVlEWvstJgRdF/AG" crossorigin="anonymous"></script>

<!-- Custom CSS -->
<style>
Expand Down
9 changes: 4 additions & 5 deletions yopass.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/bradfitz/gomemcache/memcache"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"github.com/pborman/uuid"
"github.com/satori/go.uuid"
)

// Database interface
Expand Down Expand Up @@ -91,7 +91,7 @@ func saveHandler(response http.ResponseWriter, request *http.Request,
}

// Generate new UUID and store secret in memcache with specified expiration
uuid := uuid.NewUUID()
uuid := uuid.NewV4()
err = db.Set(uuid.String(), secret.Message, secret.Expiration)
if err != nil {
http.Error(response, `{"message": "Failed to store secret in database"}`, http.StatusInternalServerError)
Expand All @@ -106,7 +106,6 @@ func saveHandler(response http.ResponseWriter, request *http.Request,
// Handle GET requests
func getHandler(response http.ResponseWriter, request *http.Request, db Database) {
response.Header().Set("Content-type", "application/json")

secret, err := db.Get(mux.Vars(request)["uuid"])
if err != nil {
if err.Error() == "memcache: cache miss" {
Expand Down Expand Up @@ -147,12 +146,12 @@ func main() {

mx := mux.NewRouter()
// GET secret
mx.HandleFunc("/secret/{uuid:([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})}",
mx.HandleFunc("/secret/{uuid:(?:[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12})}",
func(response http.ResponseWriter, request *http.Request) {
getHandler(response, request, mc)
}).Methods("GET")
// Check secret status
mx.HandleFunc("/secret/{uuid:([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})}",
mx.HandleFunc("/secret/{uuid:(?:[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12})}",
func(response http.ResponseWriter, request *http.Request) {
messageStatus(response, request, mc)
}).Methods("HEAD")
Expand Down

0 comments on commit 9645214

Please sign in to comment.