mirror of
https://github.com/vbatts/imgsrv.git
synced 2024-12-25 15:26:30 +00:00
parent
84e5af9fc2
commit
51ff306fd9
3 changed files with 9 additions and 6 deletions
|
@ -3,7 +3,6 @@ package main
|
|||
|
||||
import (
|
||||
"labix.org/v2/mgo/bson"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
/* gfs is a *mgo.GridFS defined in imgsrv.go */
|
||||
|
@ -17,7 +16,7 @@ func GetFileByFilename(filename string) (this_file File, err error) {
|
|||
}
|
||||
|
||||
func GetFileRandom() (this_file File, err error) {
|
||||
r := rand.Int63()
|
||||
r := Rand64()
|
||||
err = gfs.Find(bson.M{"random": bson.M{"$gt" : r } }).One(&this_file)
|
||||
if (err != nil) {
|
||||
return this_file, err
|
||||
|
|
5
hash.go
5
hash.go
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"hash/adler32"
|
||||
|
@ -8,6 +9,10 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
func Rand64() int64 {
|
||||
return rand.Int63()
|
||||
}
|
||||
|
||||
/* Convinience method for getting md5 sum of a string */
|
||||
func GetMd5FromString(blob string) (sum []byte) {
|
||||
h := md5.New()
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"labix.org/v2/mgo"
|
||||
"labix.org/v2/mgo/bson"
|
||||
"log"
|
||||
"math/rand"
|
||||
"mime"
|
||||
"net/http"
|
||||
"os"
|
||||
|
@ -143,7 +142,7 @@ func routeFilesPOST(w http.ResponseWriter, r *http.Request) {
|
|||
var filename string
|
||||
info := Info{
|
||||
Ip: r.RemoteAddr,
|
||||
Random: rand.Int63(),
|
||||
Random: Rand64(),
|
||||
TimeStamp: time.Now(),
|
||||
}
|
||||
|
||||
|
@ -434,7 +433,7 @@ func routeGetFromUrl(w http.ResponseWriter, r *http.Request) {
|
|||
if (r.Method == "POST") {
|
||||
info := Info{
|
||||
Ip: r.RemoteAddr,
|
||||
Random: rand.Int63(),
|
||||
Random: Rand64(),
|
||||
TimeStamp: time.Now(),
|
||||
}
|
||||
log.Println(info)
|
||||
|
@ -513,7 +512,7 @@ func routeUpload(w http.ResponseWriter, r *http.Request) {
|
|||
if (r.Method == "POST") {
|
||||
info := Info{
|
||||
Ip: r.RemoteAddr,
|
||||
Random: rand.Int63(),
|
||||
Random: Rand64(),
|
||||
TimeStamp: time.Now(),
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue