diff --git a/server_apps.go b/server_apps.go index 2c972a300c6f9e503671b252129ccc3aa3e7eeb7..e058e324cf7eff237d4af9798dc59e9f7205a00b 100644 --- a/server_apps.go +++ b/server_apps.go @@ -6,6 +6,7 @@ import ( "bytes" "compress/gzip" "context" + "crypto/md5" "encoding/json" "fmt" "io" @@ -39,6 +40,7 @@ type appInfo struct { version int commit string stars int + flow3rSeed string commitObj *object.Commit zip []byte @@ -358,6 +360,16 @@ func (s *server) getAppInfo(ctx context.Context, pathInRepo, repo string) (*appI return nil, fmt.Errorf("targzing failed: %w", err) } app.targz = tbytes + + // Calculate an 8 digit flow3r seed which can be used to install the + // app. This is based on md5 so ambitious hack3rs can force a certain + // app seed :) + flow3rSeedMd5 := md5.Sum([]byte(repo)) + app.flow3rSeed = ""; + for i := 0; i < 8; i++ { + app.flow3rSeed += string(flow3rSeedMd5[i] % 5 + byte('0')) + } + return app, nil } @@ -473,6 +485,7 @@ func (s *server) handleApps(w http.ResponseWriter, r *http.Request) { Description string `json:"description"` Version int `json:"version"` Stars int `json:"stars"` + Flow3rSeed string `json:"flow3rSeed"` } type res struct { @@ -499,6 +512,7 @@ func (s *server) handleApps(w http.ResponseWriter, r *http.Request) { Description: a.appInfo.description, Version: a.appInfo.version, Stars: a.appInfo.stars, + Flow3rSeed: a.appInfo.flow3rSeed, }) } w.Header().Add("Access-Control-Allow-Origin", "*")