Skip to content

Commit

Permalink
添加分布式集群
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjinhub committed Aug 10, 2019
1 parent dde6800 commit 0a6a91c
Show file tree
Hide file tree
Showing 46 changed files with 3,957 additions and 217 deletions.
178 changes: 119 additions & 59 deletions admin/colony.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,65 +18,32 @@
background: #f5f5f5;
}

.project {
font-weight: bold;
padding-left: 5px;
}

.fa-trash-o {
color: #f00;
cursor: pointer;
}

.info {
color: #039cfd;
cursor: pointer;
font-weight: bold;
}

.label {
line-height: 11px;
}

.lb_ssh {
background-color: #434556;
}

.lb_redis {
background-color: #e44242;
}

.lb_mysql {
background-color: #cabd23;
}

.pre {
background: #2c2c31;
color: #4fe21b;
padding: 10px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
.openx {
background: #3dd209;
width: 10px;
height: 10px;
border-radius: 100%;
display: -webkit-inline-box;
margin-right: 10px;
}

.modal-body {
position: relative;
padding: 0px;
margin-bottom: -14px;
}

.modal-content {
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
}

.modal-header {
padding: 10px;
border-bottom: 1px solid #e5e5e5;
.closex {
background: #dc0e0e;
width: 10px;
height: 10px;
border-radius: 100%;
display: -webkit-inline-box;
margin-right: 10px;
}

.modal-header .close {
margin-top: 0px;
}

.agent_name{
font-weight: bold;
color: #167bcc;
}
</style>
<div class="row">
<div class="col-sm-12">
Expand All @@ -88,15 +55,21 @@ <h4 class="page-title">分布式集群</h4>
<table class="table table-hover">
<thead>
<tr>
<th width="10%">项目</th>
<th width="10%">来源 IP</th>
<th width="10%">信息</th>
<th width="10%">上钩时间</th>
<th width="1%">操作</th>
<th width="10%">集群名称</th>
<th width="10%">集群 IP</th>
<th width="10%" style="text-align: center;">WEB</th>
<th width="10%" style="text-align: center;">暗网</th>
<th width="10%" style="text-align: center;">SSH</th>
<th width="10%" style="text-align: center;">Redis</th>
<th width="10%" style="text-align: center;">Mysql</th>
<th width="10%" style="text-align: center;">Telnet</th>
<th width="10%" style="text-align: center;">Http代理</th>
</tr>
</thead>
<tbody id="tableList">
<tr style="text-align: center;"><td style="line-height: 200px;font-size: 20px;color: #a9a9a9;" colspan="5">暂无数据</td></tr>
<tr style="text-align: center;">
<td style="line-height: 200px;font-size: 20px;color: #a9a9a9;" colspan="5">暂无数据</td>
</tr>
</tbody>
</table>
</div>
Expand All @@ -105,5 +78,92 @@ <h4 class="page-title">分布式集群</h4>

{{template "footer" }}
<script>

$.ajax({
type: "GET",
url: "/get/colony/list",
dataType: "json",
success: function (e) {
var data = e.data;
var _h = '';

for (var i = 0; i < data.length; i++) {
_h += '<tr>';

var last_update_time = data[i].last_update_time;
last_update_time = last_update_time.substring(0, 19);
last_update_time = last_update_time.replace(/-/g, '/');
var timestamp = new Date(last_update_time).getTime();
var db_time = timestamp.toString().substring(0, 10);
var curr_time = Math.round(new Date() / 1000);

if ((curr_time - parseInt(db_time)) < 60) {
_h += ' <td class="td agent_name"><span class="openx"></span>' + data[i].agent_name + '</td>';
_h += ' <td class="td"><span>' + data[i].agent_ip + '</span></td>';

if (data[i].web_status == "1") {
_h += ' <td class="td" style="text-align: center;"><span class="openx"></span></td>';
} else {
_h += ' <td class="td" style="text-align: center;"><span class="closex"></span></td>';
}

if (data[i].dart_status == "1") {
_h += ' <td class="td" style="text-align: center;"><span class="openx"></span></td>';
} else {
_h += ' <td class="td" style="text-align: center;"><span class="closex"></span></td>';
}

if (data[i].ssh_status == "1") {
_h += ' <td class="td" style="text-align: center;"><span class="openx"></span></td>';
} else {
_h += ' <td class="td" style="text-align: center;"><span class="closex"></span></td>';
}

if (data[i].redis_status == "1") {
_h += ' <td class="td" style="text-align: center;"><span class="openx"></span></td>';
} else {
_h += ' <td class="td" style="text-align: center;"><span class="closex"></span></td>';
}

if (data[i].mysql_status == "1") {
_h += ' <td class="td" style="text-align: center;"><span class="openx"></span></td>';
} else {
_h += ' <td class="td" style="text-align: center;"><span class="closex"></span></td>';
}

if (data[i].telnet_status == "1") {
_h += ' <td class="td" style="text-align: center;"><span class="openx"></span></td>';
} else {
_h += ' <td class="td" style="text-align: center;"><span class="closex"></span></td>';
}

if (data[i].http_status == "1") {
_h += ' <td class="td" style="text-align: center;"><span class="openx"></span></td>';
} else {
_h += ' <td class="td" style="text-align: center;"><span class="closex"></span></td>';
}
} else {
_h += ' <td class="td agent_name"><span class="closex"></span>' + data[i].agent_name + '</td>';
_h += ' <td class="td"><span>' + data[i].agent_ip + '</span></td>';
_h += ' <td class="td" style="text-align: center;"><span class="closex"></span></td>';
_h += ' <td class="td" style="text-align: center;"><span class="closex"></span></td>';
_h += ' <td class="td" style="text-align: center;"><span class="closex"></span></td>';
_h += ' <td class="td" style="text-align: center;"><span class="closex"></span></td>';
_h += ' <td class="td" style="text-align: center;"><span class="closex"></span></td>';
_h += ' <td class="td" style="text-align: center;"><span class="closex"></span></td>';
_h += ' <td class="td" style="text-align: center;"><span class="closex"></span></td>';
}


_h += '</tr>';
}

if (_h == "") {
_h = '<tr style="text-align: center;"><td style="line-height: 200px;font-size: 20px;color: #a9a9a9;" colspan="9">暂无数据</td></tr>'
}

$("#tableList").html(_h);
},
error: function (e) {
}
});
</script>
10 changes: 10 additions & 0 deletions admin/fish.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@
margin-bottom: 10px;
height: 100px;
}

.agent_name{
border: 1px solid #167bcc;
padding: 2px 5px;
border-radius: 5px;
color: #167bcc;
font-size: 12px;
}
</style>
<div class="row">
<div class="col-sm-12">
Expand Down Expand Up @@ -119,6 +127,7 @@ <h4 class="page-title">上钩列表</h4>
<thead>
<tr>
<th width="10%">项目</th>
<th width="10%">集群名称</th>
<th width="10%">来源 IP</th>
<th width="10%">地理信息</th>
<th width="10%">信息</th>
Expand Down Expand Up @@ -252,6 +261,7 @@ <h6 class="modal-title" id="myModalLabel">上钩信息</h6>

_h += ' <span class="project">' + data[i].project_name + '</span>';
_h += ' </td>';
_h += ' <td class="td"><span class="agent_name">' + data[i].agent + '</span></td>';
_h += ' <td class="td">' + data[i].ip + '</td>';
_h += ' <td class="td">' + data[i].ip_info + '</td>';
_h += ' <td><span class="info" onclick="show(' + data[i].id + ')">点击查看</span></td>';
Expand Down
2 changes: 2 additions & 0 deletions admin/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
<script src="/static/js/bootstrap.min.js"></script>
<script src="/static/libs/bootstrap-sweetalert/sweet-alert.min.js"></script>
<script src="/static/libs/switchery/switchery.min.js"></script>
<script src="/static/libs/waypoints/lib/jquery.waypoints.js"></script>
<script src="/static/libs/counterup/jquery.counterup.min.js"></script>

<!-- App js -->
<script src="/static/js/jquery.core.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion admin/setting.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h4 class="page-title">系统设置</h4>
<tbody id="tableList">
{{range $i, $e := .dataList}}
<tr>
<td>{{$e.setting_name}} </td>
<td style="font-weight: bold;">{{$e.setting_name}} </td>
<td>{{$e.setting_dis}}</td>
<td>{{$e.update_time}}</td>
<td>{{if ne $e.info ""}}
Expand Down
40 changes: 26 additions & 14 deletions config.ini
Original file line number Diff line number Diff line change
@@ -1,40 +1,52 @@
[rpc]
status = 1 # 是否启动 0 关闭 1服务端 2客户端
addr = 127.0.0.1:7879 # RPC 服务端地址
name = Server # 1 服务端 名称 2 客户端 名称

[admin]
addr = 127.0.0.1:9001 # 管理后台启动地址
account = admin # 登录账号
password = admin # 登录密码

[api]
status = 1 # 是否启动 API 1 启动 0 关闭
url = /api/v1/post/report # 管理后台启动地址
web_url = /api/v1/post/report # 管理后台启动地址
deep_url = /api/v1/post/deep_report # 管理后台启动地址
sec_key = 9cbf8a4dcb8e30682b927f352d6559a0 # API 认证秘钥

[web]
status = 1 # 是否启动 WEB 1 启动 0 关闭, 启动 API 后 WEB 方可上报结果
addr = 0.0.0.0:9000 # WEB 启动地址,0.0.0.0 对外开放,127.0.0.1 对内开放 可走 Nginx 反向代理
status = 0 # 是否启动 WEB 1 启动 0 关闭, 启动 API 后 WEB 方可上报结果
addr = 0.0.0.0:9010 # WEB 启动地址,0.0.0.0 对外开放,127.0.0.1 对内开放 可走 Nginx 反向代理
template = wordPress/html # WEB 模板路径
index = index.html # WEB 首页文件
static = wordPress/static # WEB 静态文件路径 注意:必须存在两个目录,html 文件 和静态文件 不能平级
url = / # WEB 访问目录,默认 / 可更改成 index.html index.asp index.php

[dark_net]
[deep]
status = 0 # 是否启动 暗网 1 启动 0 关闭, 启动 API 后 方可上报结果
addr = 0.0.0.0:9002 # 暗网 WEB 启动地址
template = github/html # 暗网 WEB 模板路径
static = github/static # 暗网 WEB 静态文件路径 注意:必须存在两个目录,html 文件 和静态文件 不能平级
addr = 0.0.0.0:9012 # 暗网 WEB 启动地址
template = deep/html # 暗网 WEB 模板路径
index = index.html # 暗网 WEB 首页文件
static = deep/static # 暗网 WEB 静态文件路径 注意:必须存在两个目录,html 文件 和静态文件 不能平级
url = / # 暗网 WEB 访问目录,默认 / 可更改成 index.html index.asp index.php

[ssh]
status = 1 # 是否启动 SSH 1 启动 0 关闭
addr = 0.0.0.0:22 # SSH 服务端地址 注意端口冲突,请先关闭服务器 openssh 服务 或 修改端口
status = 0 # 是否启动 SSH 1 启动 0 关闭
addr = 0.0.0.0:26 # SSH 服务端地址 注意端口冲突,请先关闭服务器 openssh 服务 或 修改端口

[redis]
status = 1 # 是否启动 Redis 1 启动 0 关闭
addr = 0.0.0.0:6379 # Redis 服务端地址 注意端口冲突
status = 0 # 是否启动 Redis 1 启动 0 关闭
addr = 0.0.0.0:6374 # Redis 服务端地址 注意端口冲突

[mysql]
status = 1 # 是否启动 Mysql 1 启动 0 关闭
addr = 0.0.0.0:3306 # Mysql 服务端地址 注意端口冲突
status = 0 # 是否启动 Mysql 1 启动 0 关闭
addr = 0.0.0.0:3304 # Mysql 服务端地址 注意端口冲突
files = /etc/passwd,/etc/group # Mysql 服务端读取客户端任意文件; 多写逗号分隔,会随机取

[http]
status = 0 # 是否启动 HTTP 正向代理 1 启动 0 关闭
addr = 0.0.0.0:7878 # HTTP 服务端地址 注意端口冲突
addr = 0.0.0.0:7871 # HTTP 正向代理 服务端地址 注意端口冲突

[telnet]
status = 0 # 是否启动 Telnet 1 启动 0 关闭
addr = 0.0.0.0:24 # Telnet 服务端地址 注意端口冲突
18 changes: 11 additions & 7 deletions core/dbUtil/dbUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"database/sql"
_ "github.com/mattn/go-sqlite3"
"HFish/error"
"HFish/utils/try"
)

// 连接数据库
Expand Down Expand Up @@ -45,17 +46,20 @@ func Insert(sql string, args ...interface{}) int64 {
db := conn()
stmt, _ := db.Prepare(sql)

res, err := stmt.Exec(args...)
error.Check(err, "插入数据失败")
var id int64
id = 0

defer stmt.Close()
try.Try(func() {
res, _ := stmt.Exec(args...)
//error.Check(err, "插入数据失败")

id, err := res.LastInsertId()
error.Check(err, "获取插入ID失败")
defer stmt.Close()

defer db.Close()
id, _ = res.LastInsertId()

defer db.Close()
}).Catch(func() {})

// 返回 自增长 ID
return id
}

Expand Down
Loading

0 comments on commit 0a6a91c

Please sign in to comment.