Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
AD-Control-Golang
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陶腾飞
AD-Control-Golang
Commits
b3732fea
Commit
b3732fea
authored
Apr 11, 2022
by
陶腾飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2022-04-11 v2.3.0
parent
f47af0d3
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
50 additions
and
12 deletions
+50
-12
README.MD
+1
-0
adct/adct.go
+11
-4
public/env.go
+5
-1
public/msg_deal.go
+13
-2
public/msg_init.go
+2
-1
public/send.go
+1
-1
public/win.go
+14
-0
users/menu.go
+3
-3
No files found.
README.MD
View file @
b3732fea
...
@@ -91,6 +91,7 @@
...
@@ -91,6 +91,7 @@
-
2022/04/05 v2.2.3 语法优化
-
2022/04/05 v2.2.3 语法优化
-
2022/04/05 v2.2.4 将支持通过adct全局唤醒
-
2022/04/05 v2.2.4 将支持通过adct全局唤醒
-
2022/04/09 v2.2.5 修复IP地址、MAC地址获取失败的问题,添加cmdb信息更新时间字段,优化log日志,开机时将确定主机位置,修复DDR4的判断超过速率字段出现的场景导致无法判断DDR4的问题,小工具菜单名优化,远程唤醒优化
-
2022/04/09 v2.2.5 修复IP地址、MAC地址获取失败的问题,添加cmdb信息更新时间字段,优化log日志,开机时将确定主机位置,修复DDR4的判断超过速率字段出现的场景导致无法判断DDR4的问题,小工具菜单名优化,远程唤醒优化
-
2022/04/11 v2.3.0 添加无用户登录时的工位活动检测
## 四、其他说明
## 四、其他说明
...
...
adct/adct.go
View file @
b3732fea
...
@@ -127,10 +127,17 @@ func flag_report(s string) {
...
@@ -127,10 +127,17 @@ func flag_report(s string) {
// 定点执行
// 定点执行
func
hour
()
{
func
hour
()
{
nh
:=
pub
.
GetHour
()
hour
:=
pub
.
GetHour
()
switch
nh
{
// 晚上18点 到 早上6点
default
:
if
hour
>=
18
||
hour
<=
6
{
break
hourUserActivitydetection
()
}
hourUserActivitydetection
()
}
func
hourUserActivitydetection
()
{
r
:=
pub
.
Execcmd_outputIgnoreError
(
"query user"
)
if
len
(
r
)
==
0
{
pub
.
SendADMsg
(
pub
.
Msg_Exec
,
pub
.
GJexec
(
pub
.
Msg_Exec_UserActivitydetection
,
"0"
))
}
}
}
}
...
...
public/env.go
View file @
b3732fea
...
@@ -11,7 +11,7 @@ const SymbolHostname = "-"
...
@@ -11,7 +11,7 @@ const SymbolHostname = "-"
// AD-Control //
// AD-Control //
const
Version
string
=
"2.
2.5
"
const
Version
string
=
"2.
3.0
"
const
Host_adserver
string
=
"ADSERVER"
const
Host_adserver
string
=
"ADSERVER"
const
Host_adserver_ip
string
=
"192.168.0.20"
const
Host_adserver_ip
string
=
"192.168.0.20"
const
Host_thserver
string
=
"THSERVER"
const
Host_thserver
string
=
"THSERVER"
...
@@ -106,3 +106,7 @@ var CmdbUrl string
...
@@ -106,3 +106,7 @@ var CmdbUrl string
var
CmdbCITypeComputer
string
var
CmdbCITypeComputer
string
var
AD_User_ADControl
string
var
AD_User_ADControl
string
var
AD_User_ADControl_key
string
var
AD_User_ADControl_key
string
// RealTimeEnv //
var
Env_UserActivitydetection
=
"ADControl_UserActivitydetection"
var
Env_sendwx
=
"ADControl_sendwx"
public/msg_deal.go
View file @
b3732fea
...
@@ -224,8 +224,19 @@ func (exec *MJexec) MsgDeal() interface{} {
...
@@ -224,8 +224,19 @@ func (exec *MJexec) MsgDeal() interface{} {
SendWxworkTextToAdmins
(
exec
.
ToWXWrokAdmin
())
SendWxworkTextToAdmins
(
exec
.
ToWXWrokAdmin
())
exec
.
Status
=
Msg_Exec_State_Over
exec
.
Status
=
Msg_Exec_State_Over
default
:
case
Msg_Exec_UserActivitydetection
:
Execcmd_nowait
(
exec
.
Command
)
s
:=
GetEnv
(
Env_UserActivitydetection
)
if
s
==
"1"
{
LOG
(
INFO
,
""
,
fmt
.
Sprintf
(
"%s 允许 %s 关机"
,
s
,
exec
.
Computername
))
exec
.
Command
=
Msg_Exec_TurnOffPC_cmd
exec
.
IfMsg
=
true
exec
.
Explain
=
"没有活跃用户,立即关机"
exec
.
PsExec
()
exec
.
Status
=
Msg_Exec_State_Over
}
else
{
LOG
(
INFO
,
""
,
fmt
.
Sprintf
(
"%s 禁止 %s 关机"
,
s
,
exec
.
Computername
))
}
}
}
return
exec
return
exec
}
}
...
...
public/msg_init.go
View file @
b3732fea
...
@@ -49,8 +49,9 @@ const Msg_Report_UpdatePrimaryHost string = UpdatePrimaryHost
...
@@ -49,8 +49,9 @@ const Msg_Report_UpdatePrimaryHost string = UpdatePrimaryHost
const
Msg_Exec_State_Request
string
=
"request"
const
Msg_Exec_State_Request
string
=
"request"
const
Msg_Exec_State_Ack
string
=
"ack"
const
Msg_Exec_State_Ack
string
=
"ack"
const
Msg_Exec_State_Over
string
=
"over"
const
Msg_Exec_State_Over
string
=
"over"
const
Msg_Exec_UserActivitydetection
string
=
"UserActivitydetection"
const
Msg_Exec_TurnOffPC
string
=
TurnOffPC
const
Msg_Exec_TurnOffPC
string
=
TurnOffPC
const
Msg_Exec_TurnOffPC_cmd
string
=
"shutdown -s -t
30
0"
const
Msg_Exec_TurnOffPC_cmd
string
=
"shutdown -s -t 0"
const
Msg_Exec_LogOffUser
string
=
LogOutUser
const
Msg_Exec_LogOffUser
string
=
LogOutUser
const
Msg_Exec_LogOffUser_cmd
string
=
"shutdown -l"
const
Msg_Exec_LogOffUser_cmd
string
=
"shutdown -l"
const
Msg_Exec_RebootWindows
string
=
"rebootWindows"
const
Msg_Exec_RebootWindows
string
=
"rebootWindows"
...
...
public/send.go
View file @
b3732fea
...
@@ -114,7 +114,7 @@ func SendPostRequestWithData(link *string, data interface{}) ([]byte, error) {
...
@@ -114,7 +114,7 @@ func SendPostRequestWithData(link *string, data interface{}) ([]byte, error) {
func
SendWX
(
Content
string
)
{
func
SendWX
(
Content
string
)
{
if
DomainCotroller
()
{
if
DomainCotroller
()
{
if
GetEnv
(
"sendwx"
)
==
"0"
{
if
GetEnv
(
Env_sendwx
)
==
"0"
{
LOG
(
WARN
,
"ENV"
,
"系统变量检测到取消微信发送"
)
LOG
(
WARN
,
"ENV"
,
"系统变量检测到取消微信发送"
)
return
return
}
}
...
...
public/win.go
View file @
b3732fea
...
@@ -87,6 +87,8 @@ func Execcmd_wait(cmdargs string) {
...
@@ -87,6 +87,8 @@ func Execcmd_wait(cmdargs string) {
LOG
(
ERROR
,
NULL
,
err
)
LOG
(
ERROR
,
NULL
,
err
)
}
}
}
}
// 包含标准错误的结果输出
func
Execcmd_output
(
cmdargs
string
)
[]
byte
{
func
Execcmd_output
(
cmdargs
string
)
[]
byte
{
app
,
appargs
,
err
:=
execcmd_base
(
cmdargs
)
app
,
appargs
,
err
:=
execcmd_base
(
cmdargs
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -101,6 +103,18 @@ func Execcmd_output(cmdargs string) []byte {
...
@@ -101,6 +103,18 @@ func Execcmd_output(cmdargs string) []byte {
}
}
return
nil
return
nil
}
}
func
Execcmd_outputIgnoreError
(
cmdargs
string
)
[]
byte
{
app
,
appargs
,
err
:=
execcmd_base
(
cmdargs
)
if
err
!=
nil
{
return
nil
}
out
,
err2
:=
exec
.
Command
(
app
,
appargs
...
)
.
Output
()
if
err2
!=
nil
{
return
nil
}
else
{
return
out
}
}
func
Execcmd_wait_noargs
(
app
string
)
{
func
Execcmd_wait_noargs
(
app
string
)
{
cmd
:=
exec
.
Command
(
app
)
cmd
:=
exec
.
Command
(
app
)
if
err
:=
cmd
.
Start
();
err
!=
nil
{
if
err
:=
cmd
.
Start
();
err
!=
nil
{
...
...
users/menu.go
View file @
b3732fea
...
@@ -74,14 +74,14 @@ func menuInitPower(ni *walk.NotifyIcon) {
...
@@ -74,14 +74,14 @@ func menuInitPower(ni *walk.NotifyIcon) {
// 电源管理 保持开机
// 电源管理 保持开机
func
pKeepRunning
()
{
func
pKeepRunning
()
{
pub
.
Active
=
false
pub
.
Active
=
false
Msg
(
"将保持开机,至次日18点重新检测主机活动"
)
go
Msg
(
"将保持开机,至次日18点重新检测主机活动"
)
pub
.
Execcmd_output
(
"shutdown -a"
)
pub
.
Execcmd_output
IgnoreError
(
"shutdown -a"
)
pub
.
LOG
(
INFO
,
"USERS_POWER"
,
"执行 电源管理-保持开机"
)
pub
.
LOG
(
INFO
,
"USERS_POWER"
,
"执行 电源管理-保持开机"
)
}
}
// 电源管理 删除关机倒计时
// 电源管理 删除关机倒计时
func
pCancelCloseWindows
()
{
func
pCancelCloseWindows
()
{
pub
.
Execcmd_output
(
"shutdown -a"
)
pub
.
Execcmd_output
IgnoreError
(
"shutdown -a"
)
pub
.
LOG
(
INFO
,
"USERS_POWER"
,
"执行 电源管理-删除关机倒计时"
)
pub
.
LOG
(
INFO
,
"USERS_POWER"
,
"执行 电源管理-删除关机倒计时"
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment