fix: fix some bugs (#17)

This commit is contained in:
Li4n0
2021-05-18 22:45:18 +08:00
committed by GitHub
parent 5b63e90390
commit bc6e3962f8
23 changed files with 151 additions and 121 deletions
+23 -20
View File
@@ -126,29 +126,32 @@ func (s *Server) newZone(name string) *newdns.Zone {
}
log.Info("DNS record[id:%d rule:%s remote_ip:%s] has been created", r.ID, _rule.Name, ip)
//only send to client when this connection recorded first time.
if _rule.PushToClient {
if flagGroup != "" {
var count int64
database.DB.Where("rule_name=? and domain like ?", _rule.Name, "%"+flagGroup+"%").Model(&Record{}).Count(&count)
if count <= 1 {
r.PushToClient()
log.Trace("DNS record[id:%d, flagGroup:%s] has been put to client message queue", r.ID, flagGroup)
}
} else {
//only send to client or notify user when this connection recorded first time.
var count int64
if flagGroup != "" {
database.DB.Where("rule_name=? and domain like ?", _rule.Name, "%"+flagGroup+"%").Model(&Record{}).Count(&count)
}
if count <= 1 {
if _rule.PushToClient {
r.PushToClient()
log.Trace("DNS record[id:%d, flag:%s] has been put to client message queue", r.ID, flag)
if flagGroup != "" {
log.Trace("DNS record[id:%d, flagGroup:%s] has been put to client message queue", r.ID, flagGroup)
} else {
log.Trace("DNS record[id:%d] has been put to client message queue", r.ID)
}
}
//send notice
if _rule.Notice {
go func() {
r.Notice()
if flagGroup != "" {
log.Trace("DNS record[id:%d, flagGroup:%s] notice has been sent", r.ID, flagGroup)
} else {
log.Trace("DNS record[id:%d] notice has been sent", r.ID)
}
}()
}
}
//send notice
if _rule.Notice {
go func() {
r.Notice()
log.Trace("DNS record[id:%d] notice has been sent", r.ID)
}()
}
if _rule.Value != "" {
value := rule.CompileTpl(_rule.Value, vars)
_type := _rule.Type
+1 -1
View File
@@ -13,7 +13,7 @@ import (
)
type Rule struct {
rule.BaseRule `yaml:""`
rule.BaseRule `yaml:",inline"`
Type newdns.Type `gorm:"default:1" form:"type" json:"type"`
Value string `form:"value" json:"value"`
TTL time.Duration `gorm:"ttl;default:10" form:"ttl" json:"ttl"`