From d55bc9e0f993f20b2f41a7fbae3763ce91b04d7f Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Sun, 7 Feb 2016 00:24:17 -0500 Subject: [PATCH] Allow certain IPs for certain pages Former-commit-id: ff23e987f818f840742da0dcca1d9148b54329b9 [formerly 09e7073733503d998128b78be261d48cd91eee68] [formerly 4fff11f4bfd132937354ea5ffd06460de5c6fbc2 [formerly 467eb4d5b69021e37ec5e49ce2a8f35fca8f5ce5]] Former-commit-id: 14ceb7f40eb4ed9bdd20a6858ee5edcc23fc3ff8 [formerly 520934eeca459f2d94e7fa8e68ab83904549cb24] Former-commit-id: c1adb3e8ea81e13d1c0742f493a4517765846191 --- main.go | 12 +++++++++++- templates/index.tmpl | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index a3a1fd9..1db1d0b 100755 --- a/main.go +++ b/main.go @@ -9,6 +9,7 @@ import ( "os" "path" "runtime" + "strings" "time" "github.com/boltdb/bolt" @@ -21,6 +22,11 @@ import ( var db *bolt.DB var open bool var ExternalIP string +var AllowedIPs string + +func init() { + AllowedIPs = "192.168.1.13,192.168.1.12" +} func Open() error { var err error @@ -128,14 +134,18 @@ func main() { }) r.GET("/:title", func(c *gin.Context) { title := c.Param("title") + fmt.Println("------") + fmt.Println("[" + c.ClientIP() + "]") + fmt.Println("------") if title == "ws" { wshandler(c.Writer, c.Request) + } else if title == "about" && strings.Contains(AllowedIPs, c.ClientIP()) != true { + c.Redirect(302, "/about/view") } else { c.HTML(http.StatusOK, "index.tmpl", gin.H{ "Title": title, "ExternalIP": ExternalIP, }) - } }) r.GET("/:title/*option", func(c *gin.Context) { diff --git a/templates/index.tmpl b/templates/index.tmpl index 2f2a915..50ccaff 100755 --- a/templates/index.tmpl +++ b/templates/index.tmpl @@ -125,7 +125,7 @@ border: none; overflow: auto; outline: none; - font-size: x-large; + font-size: large; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none;