6 Commits
Author SHA1 Message Date
Li4n0 ac44c7e30b chore(release): 0.7.1 2023-06-02 00:36:44 +08:00
Li4n0 bf8a43fa87 fix: fix the error that the maximum length of http rule response body is 191 when using mysql 2023-06-02 00:36:36 +08:00
Li4n0 284db90c16 chore(release): 0.7.0 2023-05-23 23:28:53 +08:00
Li4n0 223c14ab33 feat: add value field to the dns log (#67)
record resolve value of dns log to facilitate the observation of dns rebinding.
2023-05-23 23:27:50 +08:00
Li4n0 c53ec79ccd ci: disable cgo 2023-04-15 19:44:52 +08:00
Li4n0 7dde3936d1 chore: chore(release): 0.6.0 2023-03-24 22:54:44 +08:00
10 changed files with 59 additions and 23 deletions
+4
View File
@@ -23,6 +23,10 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: create dist directory - name: create dist directory
run: mkdir frontend/dist && touch frontend/dist/revsuit 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 - name: Run golangci-lint
uses: golangci/golangci-lint-action@v3 uses: golangci/golangci-lint-action@v3
with: with:
+5 -5
View File
@@ -28,15 +28,15 @@ jobs:
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3) run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)
- name: compile linux amd64 - name: compile linux amd64
run: GOARCH="amd64" go build -ldflags="-s -w -X 'github.com/li4n0/revsuit/pkg/server.VERSION=${{ steps.get_version.outputs.VERSION }}'" -tags netgo -trimpath -o "bin/revsuit_linux_amd64" ./cmd/revsuit/revsuit.go run: CGO_ENABLE=0 GOARCH="amd64" go build -ldflags="-s -w -X 'github.com/li4n0/revsuit/pkg/server.VERSION=${{ steps.get_version.outputs.VERSION }}'" -tags netgo -trimpath -o "bin/revsuit_linux_amd64" ./cmd/revsuit/revsuit.go
- name: compile linux arm64 - name: compile linux arm64
run: GOARCH="arm64" go build -ldflags="-s -w -X 'github.com/li4n0/revsuit/pkg/server.VERSION=${{ steps.get_version.outputs.VERSION }}'" -tags netgo -trimpath -o "bin/revsuit_linux_arm64" ./cmd/revsuit/revsuit.go run: CGO_ENABLE=0 GOARCH="arm64" go build -ldflags="-s -w -X 'github.com/li4n0/revsuit/pkg/server.VERSION=${{ steps.get_version.outputs.VERSION }}'" -tags netgo -trimpath -o "bin/revsuit_linux_arm64" ./cmd/revsuit/revsuit.go
- name: compile darwin amd64 - name: compile darwin amd64
run: GOOS="darwin" GOARCH="amd64" go build -ldflags="-s -w -X 'github.com/li4n0/revsuit/pkg/server.VERSION=${{ steps.get_version.outputs.VERSION }}'" -trimpath -o "bin/revsuit_darwin_amd64" ./cmd/revsuit/revsuit.go run: CGO_ENABLE=0 GOOS="darwin" GOARCH="amd64" go build -ldflags="-s -w -X 'github.com/li4n0/revsuit/pkg/server.VERSION=${{ steps.get_version.outputs.VERSION }}'" -trimpath -o "bin/revsuit_darwin_amd64" ./cmd/revsuit/revsuit.go
- name: compile darwin arm64 - name: compile darwin arm64
run: GOOS="darwin" GOARCH="arm64" go build -ldflags="-s -w -X 'github.com/li4n0/revsuit/pkg/server.VERSION=${{ steps.get_version.outputs.VERSION }}'" -trimpath -o "bin/revsuit_darwin_arm64" ./cmd/revsuit/revsuit.go run: CGO_ENABLE=0 GOOS="darwin" GOARCH="arm64" go build -ldflags="-s -w -X 'github.com/li4n0/revsuit/pkg/server.VERSION=${{ steps.get_version.outputs.VERSION }}'" -trimpath -o "bin/revsuit_darwin_arm64" ./cmd/revsuit/revsuit.go
- name: compile windows amd64 - name: compile windows amd64
run: GOOS="windows" GOARCH="amd64" go build -ldflags="-s -w -X 'github.com/li4n0/revsuit/pkg/server.VERSION=${{ steps.get_version.outputs.VERSION }}' " -trimpath -o "bin/revsuit_windows_amd64.exe" ./cmd/revsuit/revsuit.go run: CGO_ENABLE=0 GOOS="windows" GOARCH="amd64" go build -ldflags="-s -w -X 'github.com/li4n0/revsuit/pkg/server.VERSION=${{ steps.get_version.outputs.VERSION }}' " -trimpath -o "bin/revsuit_windows_amd64.exe" ./cmd/revsuit/revsuit.go
- name: Upload the artifacts - name: Upload the artifacts
uses: li4n0/upload-release-action@v2 uses: li4n0/upload-release-action@v2
+15 -1
View File
@@ -2,12 +2,26 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [0.7.1](https://github.com/Li4n0/revsuit/compare/v0.7.0...v0.7.1) (2023-06-01)
### Bug Fixes
* fix the error that the maximum length of http rule response body is 191 when using mysql ([bf8a43f](https://github.com/Li4n0/revsuit/commit/bf8a43fa875327c3191499a214c420bfa78334d0))
## [0.7.0](https://github.com/Li4n0/revsuit/compare/v0.6.0...v0.7.0) (2023-05-23)
### Features
* add `value` field to the dns log ([#67](https://github.com/Li4n0/revsuit/issues/67)) ([223c14a](https://github.com/Li4n0/revsuit/commit/223c14ab33757e06b0d8177091982582e08e70c4))
## [0.6.0](https://github.com/Li4n0/revsuit/compare/v0.5.2...v0.6.0) (2023-03-24) ## [0.6.0](https://github.com/Li4n0/revsuit/compare/v0.5.2...v0.6.0) (2023-03-24)
### Features ### Features
* support for using `Flag-Filter` request headers to filter the flags that the client expects to receive ([#64](https://github.com/Li4n0/revsuit/issues/64)) ([b33de11](https://github.com/Li4n0/revsuit/commit/b33de11ba8f126b03a45ad15cae69331ad59b865)) * support for using `Flag-Filter` request headers to filter the flags that the client expects to receive ([#64](https://github.com/Li4n0/revsuit/issues/64)) ([b33de11](https://github.com/Li4n0/revsuit/commit/b33de11ba8f126b03a45ad15cae69331ad59b865)) (Thanks to @whwlsfb)
### Bug Fixes ### Bug Fixes
BIN
View File
Binary file not shown.
+2 -2
View File
@@ -2,7 +2,7 @@ import axios from 'axios'
import {store} from "@/main"; import {store} from "@/main";
const service = axios.create({ const service = axios.create({
baseURL: location.pathname.slice(0, -'/admin/'.length) + "/api", // api的base_url baseURL: "../api", // api的base_url
timeout: 5000, // request timeout timeout: 5000, // request timeout
validateStatus: function (status) { validateStatus: function (status) {
if (status === 403) { if (status === 403) {
@@ -12,4 +12,4 @@ const service = axios.create({
} }
}) })
export default service export default service
+9
View File
@@ -82,6 +82,15 @@ const columns = [
filterIcon: 'filterIcon', filterIcon: 'filterIcon',
}, },
}, },
{
title: 'VALUE',
dataIndex: 'value',
key: 'value',
scopedSlots: {
filterDropdown: 'filterDropdown',
filterIcon: 'filterIcon',
},
},
{ {
title: 'REMOTE IP', title: 'REMOTE IP',
key: 'remote_ip', key: 'remote_ip',
+1 -1
View File
@@ -10,7 +10,7 @@ module.exports = {
devServer: { devServer: {
proxy: { proxy: {
'/api': { '/api': {
target: 'http://localhost:10000', target: 'http://127.0.0.1:10000/revsuit/',
} }
}, },
}, },
+16 -12
View File
@@ -126,7 +126,7 @@ func (s *Server) newZone(name string) *newdns.Zone {
"ns2.hostmaster.com.", "ns2.hostmaster.com.",
"ns3.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] ip := strings.Split(remoteAddr, ":")[0]
for _, _rule := range s.getRules() { for _, _rule := range s.getRules() {
@@ -135,12 +135,24 @@ func (s *Server) newZone(name string) *newdns.Zone {
continue 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 { if err != nil {
log.Warn("DNS record(rule_id:%s) created failed :%s", _rule.Name, err) log.Warn("DNS record(rule_id:%s) created failed :%s", _rule.Name, err)
return nil, nil 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. //only send to client or notify user when this connection recorded first time.
var count int64 var count int64
@@ -168,15 +180,7 @@ func (s *Server) newZone(name string) *newdns.Zone {
}() }()
} }
} }
if _rule.Value != "" { return set, err
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 nil, nil return nil, nil
+6 -1
View File
@@ -17,6 +17,7 @@ var _ record.Record = (*Record)(nil)
type Record struct { type Record struct {
Domain string `gorm:"index" form:"domain" json:"domain"` Domain string `gorm:"index" form:"domain" json:"domain"`
Value string `form:"value" json:"value"`
record.BaseRecord record.BaseRecord
Rule Rule `gorm:"foreignKey:RuleName;references:Name;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" form:"-" json:"-" notice:"-"` 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) 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{ r = &Record{
BaseRecord: record.BaseRecord{ BaseRecord: record.BaseRecord{
Flag: flag, Flag: flag,
@@ -39,6 +40,7 @@ func newRecord(rule *Rule, flag, domain, remoteIp, ipArea string) (r *Record, er
RequestTime: time.Now(), RequestTime: time.Now(),
}, },
Domain: domain, Domain: domain,
Value: value,
Rule: *rule, Rule: *rule,
} }
@@ -89,6 +91,9 @@ func Records(c *gin.Context) {
if dnsRecord.RuleName != "" { if dnsRecord.RuleName != "" {
db.Where("rule_name = ?", dnsRecord.RuleName) db.Where("rule_name = ?", dnsRecord.RuleName)
} }
if dnsRecord.Value != "" {
db.Where("address= ?", dnsRecord.Value)
}
//Delete records //Delete records
if c.Request.Method == http.MethodDelete { if c.Request.Method == http.MethodDelete {
+1 -1
View File
@@ -15,7 +15,7 @@ type Rule struct {
rule.BaseRule `yaml:",inline"` rule.BaseRule `yaml:",inline"`
ResponseStatusCode string `gorm:"index;default:200;not null" form:"response_status_code" json:"response_status_code" yaml:"response_status_code"` ResponseStatusCode string `gorm:"index;default:200;not null" form:"response_status_code" json:"response_status_code" yaml:"response_status_code"`
ResponseHeaders database.MapField `form:"response_headers" json:"response_headers" yaml:"response_headers"` ResponseHeaders database.MapField `form:"response_headers" json:"response_headers" yaml:"response_headers"`
ResponseBody string `gorm:"default:Hello RevSuit!" form:"response_body" json:"response_body" yaml:"response_body"` ResponseBody string `gorm:"type:longtext" form:"response_body" json:"response_body" yaml:"response_body"`
} }
func (Rule) TableName() string { func (Rule) TableName() string {