├── models └── object.go ├── screenshot └── joke.png ├── static ├── font │ ├── FontAwesome.otf │ ├── fontawesome-webfont.eot │ ├── fontawesome-webfont.ttf │ └── fontawesome-webfont.woff ├── img │ ├── glyphicons-halflings.png │ └── glyphicons-halflings-white.png ├── css │ ├── main.css │ ├── bootstrap-responsive.min.css │ ├── font-awesome.min.css │ ├── bootstrap-responsive.css │ ├── font-awesome.css │ └── index.html └── js │ ├── main.js │ └── vendor │ ├── bootbox.min.js │ ├── modernizr-2.6.2-respond-1.1.0.min.js │ └── bootstrap.min.js ├── controllers ├── index.go ├── auth.go └── dns.go ├── conf └── app.conf ├── main.go ├── README.md └── views ├── layout.html └── dns.html /models/object.go: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /screenshot/joke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kenshinx/joke/HEAD/screenshot/joke.png -------------------------------------------------------------------------------- /static/font/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kenshinx/joke/HEAD/static/font/FontAwesome.otf -------------------------------------------------------------------------------- /static/font/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kenshinx/joke/HEAD/static/font/fontawesome-webfont.eot -------------------------------------------------------------------------------- /static/font/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kenshinx/joke/HEAD/static/font/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /static/font/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kenshinx/joke/HEAD/static/font/fontawesome-webfont.woff -------------------------------------------------------------------------------- /static/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kenshinx/joke/HEAD/static/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /static/img/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kenshinx/joke/HEAD/static/img/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /controllers/index.go: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import "github.com/astaxie/beego" 4 | 5 | type IndexController struct { 6 | beego.Controller 7 | } 8 | 9 | func (c *IndexController) Get() { 10 | c.Redirect("/dns", 302) 11 | } 12 | -------------------------------------------------------------------------------- /static/css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #f2f2f2; 3 | } 4 | 5 | table.redis-state > tbody > tr > td { 6 | width: 60%; 7 | height: 30px; 8 | font-family: Georgia,"Times New Roman",Times,serif; 9 | font-size: 18px; 10 | } 11 | 12 | table.hosts-record{ 13 | font-size: large; 14 | } 15 | 16 | table >tbody#record-list >tr > td.action{ 17 | width: 20%; 18 | } 19 | 20 | .redis-label{ 21 | font-size: 15px; 22 | } 23 | -------------------------------------------------------------------------------- /conf/app.conf: -------------------------------------------------------------------------------- 1 | 2 | #[beego] 3 | appname = Joke 4 | httpaddr = "127.0.0.1" 5 | httpport = 1223 6 | runmode = "dev" 7 | autorender = true 8 | autorecover = true 9 | viewspath = "views" 10 | 11 | 12 | #[auth] 13 | #username:password. 14 | #basic_auth = "joke:hello" 15 | 16 | 17 | #[redis] 18 | redisaddr = "127.0.0.1:6379" 19 | redisdb = 0 20 | redispassword = "" 21 | bindkey = "godns:hosts" 22 | 23 | 24 | 25 | #[log] 26 | stdout = true 27 | logfile = "logs/joke.log" 28 | logrorate = true 29 | -------------------------------------------------------------------------------- /controllers/auth.go: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import ( 4 | "github.com/astaxie/beego" 5 | "github.com/astaxie/beego/context" 6 | auth "github.com/kenshinx/go-http-auth" 7 | "strings" 8 | ) 9 | 10 | func Secret(user, realm string) string { 11 | s := strings.SplitN(beego.AppConfig.String("basic_auth"), ":", 2) 12 | if len(s) < 2 { 13 | panic("basic auth: " + beego.AppConfig.String("basic_auth") + " formatting error") 14 | } 15 | if user == s[0] { 16 | return auth.GenSHAPassword(s[1]) 17 | } 18 | return "" 19 | } 20 | 21 | func CheckAuth(ctx *context.Context) { 22 | if beego.AppConfig.String("basic_auth") != "" { 23 | a := auth.NewBasicAuthenticator("joke.sina", Secret) 24 | if username := a.CheckAuth(ctx.Request); username == "" { 25 | a.RequireAuth(ctx.ResponseWriter, ctx.Request) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | 7 | "github.com/astaxie/beego" 8 | "github.com/kenshinx/joke/controllers" 9 | ) 10 | 11 | /* 12 | Joke: The web console of godns 13 | */ 14 | 15 | const ( 16 | Author = "kenshin" 17 | Version = "0.1.1" 18 | ) 19 | 20 | func main() { 21 | initConfig() 22 | initLogger() 23 | 24 | beego.Router("/", &controllers.IndexController{}) 25 | beego.Router("/dns", &controllers.DNSController{}) 26 | beego.Router("/dns/del", &controllers.DNSDelController{}) 27 | beego.Run() 28 | } 29 | 30 | func initConfig() { 31 | var configFile string 32 | 33 | flag.StringVar(&configFile, "c", "./conf/app.conf", "Path to the application configuration file") 34 | flag.Parse() 35 | 36 | if err := beego.LoadAppConfig("ini", configFile); err != nil { 37 | panic(err) 38 | } 39 | } 40 | 41 | func initLogger() { 42 | console, _ := beego.AppConfig.Bool("stdout") 43 | if !console { 44 | beego.BeeLogger.DelLogger("console") 45 | } 46 | 47 | if beego.AppConfig.String("logfile") != "" { 48 | cfg := fmt.Sprintf(`{"filename":"%s"}`, beego.AppConfig.String("logfile")) 49 | beego.BeeLogger.SetLogger("file", cfg) 50 | } 51 | 52 | beego.BeeLogger.SetLevel(beego.LevelDebug) 53 | beego.BeeLogger.EnableFuncCallDepth(false) 54 | } 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Joke 2 | ===== 3 | The web console for [godns](https://github.com/kenshinx/godns) 4 | 5 | ### Running 6 | 7 | #### Developement 8 | 9 | ``` 10 | $ go get github.com/kenshinx/joke 11 | $ go get github.com/astaxie/bee 12 | 13 | $ cd $GOPATH/src/github.com/kenshinx/joke 14 | 15 | $ bee run joke 16 | 17 | ``` 18 | 19 | *http://127.0.0.1:1223* 20 | 21 | 22 | #### Productive 23 | 24 | Compile first 25 | 26 | ``` 27 | $ go get github.com/kenshinx/joke 28 | $ cd $GOPATH/src/github.com/kenshinx/joke 29 | $ go build 30 | ``` 31 | 32 | Deploy strongly suggest supervisord. 33 | 34 | ``` 35 | 36 | [program:joke] 37 | command=/var/joke/joke 38 | autostart=true 39 | autorestart=true 40 | user=joke 41 | directory=/var/joke 42 | stdout_logfile_maxbytes = 50MB 43 | stdout_logfile_backups = 20 44 | stdout_logfile = /var/log/joke.log 45 | 46 | ``` 47 | 48 | 49 | ## Configuration 50 | 51 | `conf/app.conf` 52 | 53 | Override the default location with the `-c` flag : `joke -c path/to/config`. 54 | 55 | ``` 56 | 57 | #[joke] 58 | appname = Joke 59 | httpaddr = "127.0.0.1" 60 | httpport = 1223 61 | runmode = "dev" 62 | autorender = false 63 | autorecover = true 64 | viewspath = "views" 65 | 66 | 67 | #[auth] 68 | #username:password. 69 | #basic_auth = "joke:hello" 70 | 71 | 72 | #[redis] 73 | redisaddr = "127.0.0.1:6379" 74 | redisdb = 0 75 | redispassword = "" 76 | bindkey = "godns:hosts" 77 | 78 | 79 | 80 | #[log] 81 | stdout = true 82 | logfile = "logs/joke.log" 83 | logrorate = true 84 | 85 | 86 | ``` 87 | 88 | 89 | ## Auth 90 | 91 | Support http basic auth 92 | 93 | 94 | ## Screenshot 95 | 96 | *http://127.0.0.1:1223* 97 | 98 |  99 | 100 | 101 | ### Dependence 102 | 103 | * [github.com/astaxie/beego](https://github.com/astaxie/beego) 104 | * [github.com/hoisie/redis](https://github.com/hoisie/redis) 105 | -------------------------------------------------------------------------------- /views/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 || Domain | 14 |IP | 15 |Action | 16 |
|---|---|---|
| {{$k}} | 25 |{{$v}} | 26 |27 | 30 | 33 | | 34 |
Crisp like a new sheet of paper
93 |225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 |
233 |237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 |
245 |310 | 311 | 312 | 313 | 314 |
315 |Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
404 |Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam id dolor id nibh ultricies vehicula.
410 |This line of text is meant to be treated as fine print.
411 |The following snippet of text is rendered as bold text.
412 |The following snippet of text is rendered as italicized text.
413 |An abbreviation of the word attribute is attr.
414 |Fusce dapibus, tellus ac cursus commodo, tortor mauris nibh.
422 |Nullam id dolor id nibh ultricies vehicula ut id elit.
423 |Etiam porta sem malesuada magna mollis euismod.
424 |Donec ullamcorper nulla non metus auctor fringilla.
425 |Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
426 |Maecenas sed diam eget risus varius blandit sit amet non magna.
427 |442 |445 |Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
443 | Someone famous in Source Title 444 |
448 |451 |Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
449 | Someone famous in Source Title 450 |
| # | 470 |Column heading | 471 |Column heading | 472 |Column heading | 473 |
|---|---|---|---|
| 1 | 478 |Column content | 479 |Column content | 480 |Column content | 481 |
| 2 | 484 |Column content | 485 |Column content | 486 |Column content | 487 |
| 3 | 490 |Column content | 491 |Column content | 492 |Column content | 493 |
| 4 | 496 |Column content | 497 |Column content | 498 |Column content | 499 |
| 5 | 502 |Column content | 503 |Column content | 504 |Column content | 505 |
| 6 | 508 |Column content | 509 |Column content | 510 |Column content | 511 |
| 7 | 514 |Column content | 515 |Column content | 516 |Column content | 517 |
Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.
698 |Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit.
701 |Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork.
704 |Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-to-table VHS viral locavore cosby sweater.
707 |Best check yo self, you're not looking too good. Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
847 |This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.
977 | 978 |Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
1027 | 1028 | 1029 |Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
1031 | 1032 |