diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 133fc80..5b2d0b1 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -28,7 +28,7 @@ - Rules + Rules HTTP Rules @@ -54,12 +54,43 @@ :type="collapsed ? 'menu-unfold' : 'menu-fold'" @click="() => (collapsed = !collapsed)" /> + +
+ + + + + + + + + + + + + + + + + + + + + +
+ - + @@ -68,15 +99,53 @@ + + \ No newline at end of file diff --git a/frontend/src/components/Icon.vue b/frontend/src/components/Icon.vue new file mode 100644 index 0000000..4d808de --- /dev/null +++ b/frontend/src/components/Icon.vue @@ -0,0 +1,23 @@ + + + \ No newline at end of file diff --git a/frontend/src/main.js b/frontend/src/main.js index 8c411f9..8985a65 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -8,7 +8,9 @@ import '@/utils/index' Vue.config.productionTip = false; Vue.use(Antd); -export const store = Vue.observable({authed: localStorage.getItem("token")}) +export const store = Vue.observable({ + authed: true, +}) /* eslint-disable no-new */ new Vue({ router: router, diff --git a/frontend/src/views/logs/Dns.vue b/frontend/src/views/logs/Dns.vue index 3ca7077..cb63fcf 100644 --- a/frontend/src/views/logs/Dns.vue +++ b/frontend/src/views/logs/Dns.vue @@ -7,41 +7,16 @@ @change="handleTableChange" :rowClassName="(record, index) => index % 2 === 0 ? '' : 'gray-table-row'" > -
- - - Search - - - Reset - -
+ :set-selected-keys="setSelectedKeys" + :selected-keys="selectedKeys" + :clear-filters="clearFilters" + :column="column" + :filters="filters" + :fetch="fetch" + /> { let result = res.data.result this.data = result.data const pagination = {...this.pagination}; - // Read total count from server - // pagination.total = data.totalCount; + pagination.total = result.count; this.pagination = pagination; this.loading = false @@ -165,10 +141,18 @@ export default { console.error(e) } }) - } + }, }, mounted() { - this.fetch({page: "1"}); + this.fetch(); }, + watch: { + 'store.authed'() { + this.fetch() + } + }, + components: { + FilterDropdown + } } \ No newline at end of file diff --git a/frontend/src/views/logs/Ftp.vue b/frontend/src/views/logs/Ftp.vue index 16bea1a..25a4e84 100644 --- a/frontend/src/views/logs/Ftp.vue +++ b/frontend/src/views/logs/Ftp.vue @@ -23,41 +23,16 @@ FINISHED -
- - - Search - - - Reset - -
+ :set-selected-keys="setSelectedKeys" + :selected-keys="selectedKeys" + :clear-filters="clearFilters" + :column="column" + :filters="filters" + :fetch="fetch" + /> { let result = res.data.result this.data = result.data const pagination = {...this.pagination}; - // Read total count from server - // pagination.total = data.totalCount; + pagination.total = result.count; this.pagination = pagination; this.loading = false @@ -211,10 +199,18 @@ export default { console.error(e) } }) - } + }, }, mounted() { - this.fetch({page: "1"}); + this.fetch(); }, + watch: { + 'store.authed'() { + this.fetch() + } + }, + components: { + FilterDropdown + } } \ No newline at end of file diff --git a/frontend/src/views/logs/Http.vue b/frontend/src/views/logs/Http.vue index 17d2a87..ba313a6 100644 --- a/frontend/src/views/logs/Http.vue +++ b/frontend/src/views/logs/Http.vue @@ -7,41 +7,16 @@ @change="handleTableChange" :rowClassName="(record, index) => index % 2 === 0 ? '' : 'gray-table-row'" > -
- - - Search - - - Reset - -
+ :set-selected-keys="setSelectedKeys" + :selected-keys="selectedKeys" + :clear-filters="clearFilters" + :column="column" + :filters="filters" + :fetch="fetch" + /> { let result = res.data.result this.data = result.data const pagination = {...this.pagination}; - // Read total count from server - // pagination.total = data.totalCount; + pagination.total = result.count; this.pagination = pagination; this.loading = false @@ -198,10 +174,18 @@ export default { console.error(e) } }) - } + }, }, mounted() { - this.fetch({page: "1"}); + this.fetch(); }, + watch: { + 'store.authed'() { + this.fetch() + } + }, + components: { + FilterDropdown + } } \ No newline at end of file diff --git a/frontend/src/views/logs/Mysql.vue b/frontend/src/views/logs/Mysql.vue index 16aa894..fad7463 100644 --- a/frontend/src/views/logs/Mysql.vue +++ b/frontend/src/views/logs/Mysql.vue @@ -27,41 +27,16 @@ False -
- - - Search - - - Reset - -
+ :set-selected-keys="setSelectedKeys" + :selected-keys="selectedKeys" + :clear-filters="clearFilters" + :column="column" + :filters="filters" + :fetch="fetch" + /> { let result = res.data.result this.data = result.data const pagination = {...this.pagination}; - // Read total count from server - // pagination.total = data.totalCount; + pagination.total = result.count; this.pagination = pagination; this.loading = false @@ -241,10 +217,18 @@ export default { console.error(e) } }) - } + }, }, mounted() { - this.fetch({page: "1"}); + this.fetch(); }, + watch: { + 'store.authed'() { + this.fetch() + } + }, + components: { + FilterDropdown + } } \ No newline at end of file diff --git a/frontend/src/views/logs/Rmi.vue b/frontend/src/views/logs/Rmi.vue index 5e41abc..0d16798 100644 --- a/frontend/src/views/logs/Rmi.vue +++ b/frontend/src/views/logs/Rmi.vue @@ -7,41 +7,16 @@ @change="handleTableChange" :rowClassName="(record, index) => index % 2 === 0 ? '' : 'gray-table-row'" > -
- - - Search - - - Reset - -
+ :set-selected-keys="setSelectedKeys" + :selected-keys="selectedKeys" + :clear-filters="clearFilters" + :column="column" + :filters="filters" + :fetch="fetch" + /> { let result = res.data.result this.data = result.data const pagination = {...this.pagination}; - // Read total count from server - // pagination.total = data.totalCount; + pagination.total = result.count; this.pagination = pagination; this.loading = false @@ -162,10 +142,18 @@ export default { console.error(e) } }) - } + }, }, mounted() { - this.fetch({page: "1"}); + this.fetch(); }, + watch: { + 'store.authed'() { + this.fetch() + } + }, + components: { + FilterDropdown + } } \ No newline at end of file diff --git a/frontend/src/views/rules/Dns.vue b/frontend/src/views/rules/Dns.vue index 6821fca..551fbc5 100644 --- a/frontend/src/views/rules/Dns.vue +++ b/frontend/src/views/rules/Dns.vue @@ -288,6 +288,7 @@ export default { name: 'DnsRules', data() { return { + store, data: [], formVisible: false, pagination: {current: 1}, @@ -311,18 +312,17 @@ export default { this.fetch(); }, fetch: function () { - this.loading = true; let params = { ...this.filters, page: this.pagination.current, order: this.order } + this.loading = true; getDnsRule(params).then(res => { let result = res.data.result this.data = result.data const pagination = {...this.pagination}; - // Read total count from server - // pagination.total = data.totalCount; + pagination.total = result.count; this.pagination = pagination; this.loading = false @@ -430,6 +430,11 @@ export default { mounted() { this.fetch({page: "1"}); }, + watch: { + 'store.authed'() { + this.fetch() + } + }, components: { BasicRule, } diff --git a/frontend/src/views/rules/Ftp.vue b/frontend/src/views/rules/Ftp.vue index 7e65b0e..3c0543f 100644 --- a/frontend/src/views/rules/Ftp.vue +++ b/frontend/src/views/rules/Ftp.vue @@ -210,6 +210,7 @@ export default { name: 'FtpRules', data() { return { + store, data: [], formVisible: false, pagination: {current: 1}, @@ -230,18 +231,17 @@ export default { this.fetch(); }, fetch: function () { - this.loading = true; let params = { ...this.filters, page: this.pagination.current, order: this.order } + this.loading = true; getFtpRule(params).then(res => { let result = res.data.result this.data = result.data const pagination = {...this.pagination}; - // Read total count from server - // pagination.total = data.totalCount; + pagination.total = result.count; this.pagination = pagination; this.loading = false @@ -349,6 +349,11 @@ export default { mounted() { this.fetch({page: "1"}); }, + watch: { + 'store.authed'() { + this.fetch() + } + }, components: { BasicRule, } diff --git a/frontend/src/views/rules/Http.vue b/frontend/src/views/rules/Http.vue index c20fa40..e9d66c7 100644 --- a/frontend/src/views/rules/Http.vue +++ b/frontend/src/views/rules/Http.vue @@ -274,6 +274,7 @@ export default { name: 'HttpRules', data() { return { + store, data: [], formVisible: false, pagination: {current: 1}, @@ -341,18 +342,17 @@ export default { this.fetch(); }, fetch: function () { - this.loading = true; let params = { ...this.filters, page: this.pagination.current, order: this.order } + this.loading = true; getHttpRule(params).then(res => { let result = res.data.result this.data = result.data const pagination = {...this.pagination}; - // Read total count from server - // pagination.total = data.totalCount; + pagination.total = result.count; this.pagination = pagination; this.loading = false @@ -497,6 +497,11 @@ export default { mounted() { this.fetch({page: "1"}); }, + watch: { + 'store.authed'() { + this.fetch() + } + }, components: { BasicRule, } diff --git a/frontend/src/views/rules/Mysql.vue b/frontend/src/views/rules/Mysql.vue index 1aed9ad..963a283 100644 --- a/frontend/src/views/rules/Mysql.vue +++ b/frontend/src/views/rules/Mysql.vue @@ -248,6 +248,7 @@ export default { name: 'MysqlRules', data() { return { + store, data: [], formVisible: false, pagination: {current: 1}, @@ -270,18 +271,17 @@ export default { this.fetch(); }, fetch: function () { - this.loading = true; let params = { ...this.filters, page: this.pagination.current, order: this.order } + this.loading = true; getMysqlRule(params).then(res => { let result = res.data.result this.data = result.data const pagination = {...this.pagination}; - // Read total count from server - // pagination.total = data.totalCount; + pagination.total = result.count; this.pagination = pagination; this.loading = false @@ -420,6 +420,11 @@ export default { mounted() { this.fetch({page: "1"}); }, + watch: { + 'store.authed'() { + this.fetch() + } + }, components: { BasicRule, } diff --git a/frontend/src/views/rules/Rmi.vue b/frontend/src/views/rules/Rmi.vue index c2f0d25..ad576b8 100644 --- a/frontend/src/views/rules/Rmi.vue +++ b/frontend/src/views/rules/Rmi.vue @@ -185,6 +185,7 @@ export default { name: 'RmiRules', data() { return { + store, data: [], formVisible: false, pagination: {current: 1}, @@ -205,18 +206,16 @@ export default { this.fetch(); }, fetch: function () { - this.loading = true; let params = { ...this.filters, page: this.pagination.current, order: this.order } + this.loading = true; getRmiRule(params).then(res => { let result = res.data.result this.data = result.data const pagination = {...this.pagination}; - // Read total count from server - // pagination.total = data.totalCount; pagination.total = result.count; this.pagination = pagination; this.loading = false @@ -319,11 +318,16 @@ export default { handleCancel() { this.form = {} this.closeDrawer() - } + }, }, mounted() { this.fetch({page: "1"}); }, + watch: { + 'store.authed'() { + this.fetch() + } + }, components: { BasicRule, } diff --git a/frontend/vue.config.js b/frontend/vue.config.js index 023a897..0dede54 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -17,6 +17,7 @@ module.exports = { } }, }, + runtimeCompiler: true, filenameHashing: false, publicPath: '' } diff --git a/pkg/ftp/record.go b/pkg/ftp/record.go index 94364d0..6a3cbac 100644 --- a/pkg/ftp/record.go +++ b/pkg/ftp/record.go @@ -67,6 +67,12 @@ func ListRecords(c *gin.Context) { if ftpRecord.Flag != "" { db.Where("flag = ?", ftpRecord.Flag) } + if ftpRecord.User != "" { + db.Where("user like ?", "%"+ftpRecord.User+"%") + } + if ftpRecord.Password != "" { + db.Where("password like ?", "%"+ftpRecord.Password+"%") + } if ftpRecord.Path != "" { db.Where("path like ?", "%"+ftpRecord.Path+"%") } diff --git a/pkg/server/controller.go b/pkg/server/controller.go index cda8545..aa15daf 100644 --- a/pkg/server/controller.go +++ b/pkg/server/controller.go @@ -2,17 +2,23 @@ package server import ( "io" + "net/http" "github.com/gin-gonic/gin" "github.com/li4n0/revsuit/internal/record" log "unknwon.dev/clog/v2" ) -func ping(c *gin.Context) { +func auth(c *gin.Context) { + c.SetSameSite(http.SameSiteLaxMode) c.SetCookie("token", c.Request.Header["Token"][0], 0, "/revsuit/api/", c.Request.Host, true, true) c.String(200, "pong") } +func ping(c *gin.Context) { + c.String(200, "pong") +} + func events(c *gin.Context) { log.Info("Receive connection from %v", c.Request.RemoteAddr) c.Stream(func(w io.Writer) bool { diff --git a/pkg/server/router.go b/pkg/server/router.go index a2fbe66..a7c0328 100644 --- a/pkg/server/router.go +++ b/pkg/server/router.go @@ -38,6 +38,7 @@ func (revsuit *Revsuit) registerPlatformRouter() { revsuit.http.ApiGroup = api //platform routers + api.GET("/auth", auth) api.GET("/events", events) api.GET("/ping", ping) }