Esempio n. 1
0
File: radio.go Progetto: jsli/ota
func (c Radio) LogVisitorByIP() revel.Result {
	rdal, err := models.NewRedisDal()
	if err != nil {
		return nil
	}
	defer rdal.Close()
	ip := policy.FilterIp(c.Request.RemoteAddr)
	rdal.Incr(ip)
	return nil
}
Esempio n. 2
0
File: stat.go Progetto: jsli/ota
func (c Stat) Self() revel.Result {
	rdal, err := models.NewRedisDal()
	if err != nil {
		return c.RenderJson(err)
	}
	defer rdal.Close()
	ip := policy.FilterIp(c.Request.RemoteAddr)
	counter, err := rdal.Get(ip)
	if err != nil {
		return c.RenderJson(err)
	}

	result := models.StatSelfResult{}
	result.IP = ip
	result.Counter, _ = strconv.Atoi(counter)

	return c.RenderJson(result)
}