Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
mangenotwork committed Sep 19, 2023
1 parent 3a486ef commit 1baea40
Show file tree
Hide file tree
Showing 17 changed files with 223 additions and 37 deletions.
19 changes: 10 additions & 9 deletions TODOLIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
- master 设计"网站" 实体 ok
- 证书信息获取,dns扫描 ok
- IP属地获取,ipc查询 ok
- tool : 获取证书 + 历史记录
- tool : 查询dns + 历史记录
- tool : Whois查询 + 历史记录
- tool : ip信息查询 + 历史记录
- tool : 本机ip信息 + 历史记录
- tool : 获取网站的T, D, K, 图标 + 历史记录
- tool : 采集网站信息 + 历史记录
- tool : 查询备案 + 历史记录
- tool : 获取网站的T, D, K, 图标 ok
- tool : ip信息查询 ok
- tool : 查询dns ok
- tool : Whois查询 ok
- tool : 查询备案 ok
- tool : 在线ping ok
- tool : 获取证书 ok
- tool : 网站信息获取 ok
- master 添加网站
- master 获取网站基础信息
- master 任务表
- monitor 每次启动拉一次监测任务表
- master 获取monitor在线情况
- master 获取monitor在线情况
-
40 changes: 40 additions & 0 deletions master/dao/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
type History interface {
Set(value any) error
Get() ([]any, error)
Clear() error
}

const (
Expand Down Expand Up @@ -65,6 +66,11 @@ func (h *historyWebsiteTDKI) Get() ([]any, error) {
return value, err
}

func (h *historyWebsiteTDKI) Clear() error {
list := make([]any, 0)
return DB.Set(HistoryWebsiteTDKITable, HistoryWebsiteTDKIKeyName, list)
}

type historyIP struct{}

func (h *historyIP) Set(value any) error {
Expand All @@ -79,6 +85,11 @@ func (h *historyIP) Get() ([]any, error) {
return value, err
}

func (h *historyIP) Clear() error {
list := make([]any, 0)
return DB.Set(HistoryIpTable, HistoryIpKeyName, list)
}

type historyNsLookUp struct{}

func (h *historyNsLookUp) Set(value any) error {
Expand All @@ -93,6 +104,11 @@ func (h *historyNsLookUp) Get() ([]any, error) {
return value, err
}

func (h *historyNsLookUp) Clear() error {
list := make([]any, 0)
return DB.Set(HistoryNsLookUpTable, HistoryNsLookUpKeyName, list)
}

type historyWhois struct{}

func (h *historyWhois) Set(value any) error {
Expand All @@ -107,6 +123,11 @@ func (h *historyWhois) Get() ([]any, error) {
return value, err
}

func (h *historyWhois) Clear() error {
list := make([]any, 0)
return DB.Set(HistoryWhoisTable, HistoryWhoisKeyName, list)
}

type historyICP struct{}

func (h *historyICP) Set(value any) error {
Expand All @@ -121,6 +142,11 @@ func (h *historyICP) Get() ([]any, error) {
return value, err
}

func (h *historyICP) Clear() error {
list := make([]any, 0)
return DB.Set(HistoryICPTable, HistoryICPKeyName, list)
}

type historyPing struct{}

func (h *historyPing) Set(value any) error {
Expand All @@ -135,6 +161,11 @@ func (h *historyPing) Get() ([]any, error) {
return value, err
}

func (h *historyPing) Clear() error {
list := make([]any, 0)
return DB.Set(HistoryPingTable, HistoryPingKeyName, list)
}

type historySSL struct{}

func (h *historySSL) Set(value any) error {
Expand All @@ -149,6 +180,11 @@ func (h *historySSL) Get() ([]any, error) {
return value, err
}

func (h *historySSL) Clear() error {
list := make([]any, 0)
return DB.Set(HistorySSLTable, HistorySSLKeyName, list)
}

type historyWebsiteInfo struct{}

func (h *historyWebsiteInfo) Set(value any) error {
Expand All @@ -162,3 +198,7 @@ func (h *historyWebsiteInfo) Get() ([]any, error) {
err := DB.Get(HistoryWebsiteInfoTable, HistoryWebsiteInfoKeyName, &value)
return value, err
}

func (h *historyWebsiteInfo) Clear() error {
return DB.Set(HistoryWebsiteInfoTable, HistoryWebsiteInfoKeyName, make([]any, 0))
}
35 changes: 35 additions & 0 deletions master/dao/ping.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package dao

import (
"fmt"
"github.com/mangenotwork/common/utils"
gt "github.com/mangenotwork/gathertool"
"time"
)

type PingRse struct {
Item int `json:"item"`
Date string `json:"date"`
Ms string `json:"ms"`
Err string `json:"err"`
}

func Ping(ip string) []*PingRse {
rse := make([]*PingRse, 0)
for i := 0; i < 4; i++ {
ping, err := gt.Ping(ip)
errStr := ""
if err != nil {
errStr = err.Error()
}

rse = append(rse, &PingRse{
Item: i + 1,
Date: utils.NowDate(),
Ms: fmt.Sprintf("%.2f ms", float64(ping)/1000000),
Err: errStr,
})
time.Sleep(500 * time.Millisecond)
}
return rse
}
Binary file modified master/data.db
Binary file not shown.
25 changes: 24 additions & 1 deletion master/handler/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,22 @@ func ToolHistoryGet(c *ginHelper.GinCtx) {
return
}

func ToolHistoryClear(c *ginHelper.GinCtx) {
toolID := c.GetQueryInt("toolID")
h, err := dao.NewHistory(toolID)
if err != nil {
c.APIOutPutError(err, err.Error())
return
}
err = h.Clear()
if err != nil {
c.APIOutPutError(err, err.Error())
return
}
c.APIOutPut("", "成功")
return
}

func GetSSLCertificate(c *ginHelper.GinCtx) {
caseUrl := c.GetQuery("url")
if len(caseUrl) < 1 {
Expand Down Expand Up @@ -250,5 +266,12 @@ func GetICP(c *ginHelper.GinCtx) {
}

func Ping(c *ginHelper.GinCtx) {

ip := c.GetQuery("ip")
if len(ip) < 1 {
c.APIOutPutError(fmt.Errorf("参数为空"), "参数为空")
return
}
data := dao.Ping(ip)
c.APIOutPut(data, "")
return
}
1 change: 1 addition & 0 deletions master/routers/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func API() {
// tool
api.POST("/tool/history", ginHelper.Handle(handler.ToolHistorySet)) // 记录历史记录
api.GET("/tool/history", ginHelper.Handle(handler.ToolHistoryGet)) // 获取历史记录
api.GET("/tool/history/clear", ginHelper.Handle(handler.ToolHistoryClear)) // 清空历史记录
api.GET("/tool/certificate", ginHelper.Handle(handler.GetSSLCertificate)) // 获取证书
api.GET("/tool/nsLookUp", ginHelper.Handle(handler.DNSLookUp)) // 查询dns
api.GET("/tool/nsLookUp/all", ginHelper.Handle(handler.DNSLookUpAll)) // 查询dns
Expand Down
73 changes: 66 additions & 7 deletions master/static/js/tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const app = createApp({
history: {
add: function (id, value) { return "/api/tool/history?toolID="+id+"&value="+value; },
get: function (id) { return "/api/tool/history?toolID="+id; },
clear: function (id) {return "/api/tool/history/clear?toolID="+id; },
data: [],
},
objFidWebsiteTDKI: {
Expand Down Expand Up @@ -41,10 +42,10 @@ const app = createApp({
api: function (){ return "/api/tool/icp?host=" + this.host; },
rse: {},
},
objFidPing: { // TODO...
objFidPing: {
id: FidPing,
host: "",
api: function (){ return "/api/tool/icp?host=" + this.host; },
ip: "",
api: function (){ return "/api/tool/ping?ip=" + this.ip; },
rse: {},
},
objFidSSL: {
Expand Down Expand Up @@ -80,6 +81,12 @@ const app = createApp({
console.log(data)
});
},
clearHistory: function (id) {
let t = this;
common.AjaxGet(t.history.clear(id), function (data){
t.history.data = data.data;
});
},
open: function (fid) {
let t = this;
t.getHistory(fid);
Expand Down Expand Up @@ -138,6 +145,12 @@ const app = createApp({
t.submitFidWebsiteTDKI();
},

clearFidWebsiteTDKIHistory: function () {
let t = this;
t.clearHistory(t.objFidWebsiteTDKI.id);
t.getHistory(t.objFidWebsiteTDKI.id);
},

submitFidIp: function () {
let t = this;
if (t.objFidIp.ip === "") {
Expand All @@ -157,6 +170,12 @@ const app = createApp({
t.submitFidIp();
},

clearFidIpHistory: function () {
let t = this;
t.clearHistory(t.objFidIp.id);
t.getHistory(t.objFidIp.id);
},

submitFidNsLookUp: function () {
let t = this;
if (t.objFidNsLookUp.host === "") {
Expand All @@ -180,6 +199,12 @@ const app = createApp({
t.submitFidNsLookUp();
},

clearFidNsLookUpHistory: function () {
let t = this;
t.clearHistory(t.objFidNsLookUp.id);
t.getHistory(t.objFidNsLookUp.id);
},

submitFidWhois: function () {
let t = this;
if (t.objFidWhois.host === "") {
Expand All @@ -199,6 +224,12 @@ const app = createApp({
t.submitFidWhois();
},

clearFidWhoisHistory: function () {
let t = this;
t.clearHistory(t.objFidWhois.id);
t.getHistory(t.objFidWhois.id);
},

submitFidICP: function () {
let t = this;
if (t.objFidICP.host === "") {
Expand All @@ -218,25 +249,41 @@ const app = createApp({
t.submitFidICP();
},

clearFidICPHistory: function () {
let t = this;
t.clearHistory(t.objFidICP.id);
t.getHistory(t.objFidICP.id);
},

submitFidPing: function () {
let t = this;
if (t.objFidPing.host === "") {
common.ToastShow("请输入Host!");
if (t.objFidPing.ip === "") {
common.ToastShow("请输入IP!");
return
}
$("#FidPingRse").hide();
$("#FidPingLoading").show();
common.AjaxGet(t.objFidPing.api(), function (data){
t.objFidPing.rse = data.data;
t.setHistory(t.objFidPing.id, t.objFidPing.host);
$("#FidPingRse").show();
$("#FidPingLoading").hide();
t.setHistory(t.objFidPing.id, t.objFidPing.ip);
t.getHistory(t.objFidPing.id);
});
},

gotoFidPing: function (value) {
let t = this;
t.objFidPing.host = value;
t.objFidPing.ip = value;
t.submitFidPing();
},

clearFidPingHistory: function () {
let t = this;
t.clearHistory(t.objFidPing.id);
t.getHistory(t.objFidPing.id);
},

submitFidSSL: function () {
let t = this;
if (t.objFidSSL.url === "") {
Expand All @@ -256,6 +303,12 @@ const app = createApp({
t.submitFidSSL();
},

clearFidSSLHistory: function () {
let t = this;
t.clearHistory(t.objFidSSL.id);
t.getHistory(t.objFidSSL.id);
},

submitFidWebsiteInfo: function () {
let t = this;
if (t.objFidWebsiteInfo.host === "") {
Expand All @@ -275,6 +328,12 @@ const app = createApp({
t.submitFidWebsiteInfo();
},

clearFidWebsiteInfoHistory: function () {
let t = this;
t.clearHistory(t.objFidWebsiteInfo.id);
t.getHistory(t.objFidWebsiteInfo.id);
},

},
computed: {
},
Expand Down
4 changes: 0 additions & 4 deletions master/views/page/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,4 @@
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script src="/static/js/public.js?v={[ .TimeStamp ]}"></script>
<script src="/static/js/home.js?v={[ .TimeStamp ]}"></script>
<script>
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))
</script>
{[ template "__end__.html" . ]}
4 changes: 4 additions & 0 deletions master/views/public/__end__.html
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
<script>
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))
</script>
</html>
3 changes: 2 additions & 1 deletion master/views/section/tool_FidICP_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ <h1 class="modal-title fs-5" id="FidICPModalLabel">ICP查询</h1>
</div>
</div>
<div style="margin-top: 48px;">
历史记录:
<span style="font-size: 21px;">历史记录</span>
<a @click="clearFidICPHistory" data-bs-toggle="tooltip" data-bs-title="清空历史记录" style="margin-left: 24px;cursor: pointer;">{[ SVG "trash-fill" 18 18 ]}</a>
<ul class="list-group list-group-flush" style="height: 160px;overflow: auto;padding: 2px;">
<template v-for="item in history.data">
<li class="list-group-item" @click="gotoFidICP(item)" style="cursor: pointer;">{{item}}</li>
Expand Down
Loading

0 comments on commit 1baea40

Please sign in to comment.