From e7ca929c4a60baa21e7f26d401c65a0b83618081 Mon Sep 17 00:00:00 2001 From: jager Date: Sun, 30 Jan 2022 15:58:14 +0800 Subject: [PATCH] client ip --- .gitignore | 2 +- Makefile | 2 +- cmd/idata/main.go | 2 +- internal/api/api.go | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index bb35fcb..16984a9 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,4 @@ builder logs - +static \ No newline at end of file diff --git a/Makefile b/Makefile index 6d15888..bc57a36 100644 --- a/Makefile +++ b/Makefile @@ -34,4 +34,4 @@ ps: -@ps -ef | grep ./builder/idata | grep -v grep push: - -@scp builder/* root@119.29.105.154:/root/idata/builder/ \ No newline at end of file + -@scp builder/* root@119.29.105.154:/root/idata/bin/ \ No newline at end of file diff --git a/cmd/idata/main.go b/cmd/idata/main.go index 440f0c2..fdc30c5 100644 --- a/cmd/idata/main.go +++ b/cmd/idata/main.go @@ -30,7 +30,7 @@ import ( const appName = "idata" func main() { - rand.Seed(time.Now().Unix()) + rand.Seed(time.Now().UnixNano()) ctx, wait := flags.Parse(appName) defer wait() diff --git a/internal/api/api.go b/internal/api/api.go index c65c961..00712f8 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -37,9 +37,10 @@ func Registry(engine *gin.Engine) { apiR.GET("/soup", soup.GetRandSoup) apiR.GET("/almanac", almanac.Almanac) apiR.GET("/dirty_word", dirty.IsDirtyWord) + apiR.Static("/video", "./static/") } func myIp(ctx *gin.Context) { - addr := ctx.Request.RemoteAddr + addr := ctx.ClientIP() ctx.String(http.StatusOK, addr) }