mirror of
https://github.com/Li4n0/revsuit.git
synced 2026-09-21 22:30:46 +08:00
feat: add value field to the dns log (#67)
record resolve value of dns log to facilitate the observation of dns rebinding.
This commit is contained in:
@@ -23,6 +23,10 @@ jobs:
|
||||
uses: actions/checkout@v2
|
||||
- name: create dist directory
|
||||
run: mkdir frontend/dist && touch frontend/dist/revsuit
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.19.x
|
||||
- name: Run golangci-lint
|
||||
uses: golangci/golangci-lint-action@v3
|
||||
with:
|
||||
|
||||
@@ -2,7 +2,7 @@ import axios from 'axios'
|
||||
import {store} from "@/main";
|
||||
|
||||
const service = axios.create({
|
||||
baseURL: location.pathname.slice(0, -'/admin/'.length) + "/api", // api的base_url
|
||||
baseURL: "../api", // api的base_url
|
||||
timeout: 5000, // request timeout
|
||||
validateStatus: function (status) {
|
||||
if (status === 403) {
|
||||
|
||||
@@ -82,6 +82,15 @@ const columns = [
|
||||
filterIcon: 'filterIcon',
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'VALUE',
|
||||
dataIndex: 'value',
|
||||
key: 'value',
|
||||
scopedSlots: {
|
||||
filterDropdown: 'filterDropdown',
|
||||
filterIcon: 'filterIcon',
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'REMOTE IP',
|
||||
key: 'remote_ip',
|
||||
|
||||
@@ -10,7 +10,7 @@ module.exports = {
|
||||
devServer: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:10000',
|
||||
target: 'http://127.0.0.1:10000/revsuit/',
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
+16
-12
@@ -126,7 +126,7 @@ func (s *Server) newZone(name string) *newdns.Zone {
|
||||
"ns2.hostmaster.com.",
|
||||
"ns3.hostmaster.com.",
|
||||
},
|
||||
Handler: func(lookedName, remoteAddr string) ([]newdns.Set, error) {
|
||||
Handler: func(lookedName, remoteAddr string) (set []newdns.Set, err error) {
|
||||
ip := strings.Split(remoteAddr, ":")[0]
|
||||
|
||||
for _, _rule := range s.getRules() {
|
||||
@@ -135,12 +135,24 @@ func (s *Server) newZone(name string) *newdns.Zone {
|
||||
continue
|
||||
}
|
||||
|
||||
r, err := newRecord(_rule, flag, domain, ip, ipinfo.Area(ip))
|
||||
if _rule.Value != "" {
|
||||
_type := _rule.Type
|
||||
if _rule.Type == newdns.REBINDING {
|
||||
_type = newdns.A
|
||||
}
|
||||
set = newSet(_rule, name, rule.CompileTpl(_rule.Value, vars), ip, _type)
|
||||
}
|
||||
|
||||
var value string
|
||||
if len(set) > 0 && len(set[0].Records) > 0 {
|
||||
value = set[0].Records[0].Address
|
||||
}
|
||||
r, err := newRecord(_rule, flag, domain, value, ip, ipinfo.Area(ip))
|
||||
if err != nil {
|
||||
log.Warn("DNS record(rule_id:%s) created failed :%s", _rule.Name, err)
|
||||
return nil, nil
|
||||
}
|
||||
log.Info("DNS record[id:%d rule:%s remote_ip:%s] has been created", r.ID, _rule.Name, ip)
|
||||
log.Info("DNS record[id:%d rule:%s remote_ip:%s, value:%s] has been created", r.ID, _rule.Name, ip, value)
|
||||
|
||||
//only send to client or notify user when this connection recorded first time.
|
||||
var count int64
|
||||
@@ -168,15 +180,7 @@ func (s *Server) newZone(name string) *newdns.Zone {
|
||||
}()
|
||||
}
|
||||
}
|
||||
if _rule.Value != "" {
|
||||
value := rule.CompileTpl(_rule.Value, vars)
|
||||
_type := _rule.Type
|
||||
if _rule.Type == newdns.REBINDING {
|
||||
_type = newdns.A
|
||||
}
|
||||
|
||||
return newSet(_rule, name, value, ip, _type), nil
|
||||
}
|
||||
return set, err
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
|
||||
+6
-1
@@ -17,6 +17,7 @@ var _ record.Record = (*Record)(nil)
|
||||
|
||||
type Record struct {
|
||||
Domain string `gorm:"index" form:"domain" json:"domain"`
|
||||
Value string `form:"value" json:"value"`
|
||||
|
||||
record.BaseRecord
|
||||
Rule Rule `gorm:"foreignKey:RuleName;references:Name;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" form:"-" json:"-" notice:"-"`
|
||||
@@ -30,7 +31,7 @@ func (r Record) Notice() {
|
||||
notice.Notice(r)
|
||||
}
|
||||
|
||||
func newRecord(rule *Rule, flag, domain, remoteIp, ipArea string) (r *Record, err error) {
|
||||
func newRecord(rule *Rule, flag, domain, value, remoteIp, ipArea string) (r *Record, err error) {
|
||||
r = &Record{
|
||||
BaseRecord: record.BaseRecord{
|
||||
Flag: flag,
|
||||
@@ -39,6 +40,7 @@ func newRecord(rule *Rule, flag, domain, remoteIp, ipArea string) (r *Record, er
|
||||
RequestTime: time.Now(),
|
||||
},
|
||||
Domain: domain,
|
||||
Value: value,
|
||||
Rule: *rule,
|
||||
}
|
||||
|
||||
@@ -89,6 +91,9 @@ func Records(c *gin.Context) {
|
||||
if dnsRecord.RuleName != "" {
|
||||
db.Where("rule_name = ?", dnsRecord.RuleName)
|
||||
}
|
||||
if dnsRecord.Value != "" {
|
||||
db.Where("address= ?", dnsRecord.Value)
|
||||
}
|
||||
|
||||
//Delete records
|
||||
if c.Request.Method == http.MethodDelete {
|
||||
|
||||
Reference in New Issue
Block a user