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
81a6f6a7
Commit
81a6f6a7
authored
Apr 05, 2022
by
陶腾飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2022/04/05 v2.2.4
parent
f07c0656
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
142 additions
and
94 deletions
+142
-94
README.MD
+1
-0
adct/adct.go
+15
-53
daemon/automatic.go
+4
-2
daemon/daemon.go
+6
-1
public/cmdb.go
+4
-3
public/cmdbjson.go
+4
-0
public/dept.go
+49
-0
public/env.go
+4
-1
public/error.go
+2
-2
public/log.go
+4
-4
public/msg_deal.go
+21
-5
public/msg_init.go
+9
-18
public/send.go
+3
-0
public/user.go
+14
-1
public/wol.go
+2
-4
No files found.
README.MD
View file @
81a6f6a7
...
@@ -85,6 +85,7 @@
...
@@ -85,6 +85,7 @@
-
2022/04/04 v2.2.1 修复远程管理主机失败的问题,增加对操作系统的判断、为Cmdb Automatic Update Tool的自动更新工具(专用于非情报部门的主机的cmdb同步工具)做铺垫。
-
2022/04/04 v2.2.1 修复远程管理主机失败的问题,增加对操作系统的判断、为Cmdb Automatic Update Tool的自动更新工具(专用于非情报部门的主机的cmdb同步工具)做铺垫。
-
2022/04/04 v2.2.2 使用go mod
-
2022/04/04 v2.2.2 使用go mod
-
2022/04/05 v2.2.3 语法优化
-
2022/04/05 v2.2.3 语法优化
-
2022/04/05 v2.2.4 将支持通过adct全局唤醒
## 五、其他说明
## 五、其他说明
...
...
adct/adct.go
View file @
81a6f6a7
...
@@ -14,6 +14,7 @@ const INFO = pub.INFO
...
@@ -14,6 +14,7 @@ const INFO = pub.INFO
const
ERROR
=
pub
.
ERROR
const
ERROR
=
pub
.
ERROR
const
NULL
=
pub
.
NULL
const
NULL
=
pub
.
NULL
var
LOG
=
pub
.
LOG
var
f
struct
{
var
f
struct
{
Force
bool
Force
bool
Quick
bool
Quick
bool
...
@@ -56,9 +57,7 @@ func main() {
...
@@ -56,9 +57,7 @@ func main() {
}
else
if
*
wolAllText
{
}
else
if
*
wolAllText
{
pub
.
DomainCotroller
()
pub
.
DomainCotroller
()
wolALL
()
wolALL
()
}
}
return
}
}
func
loglevelSet
(
l
string
)
{
func
loglevelSet
(
l
string
)
{
switch
l
{
switch
l
{
...
@@ -91,7 +90,7 @@ func flag_report(s string) {
...
@@ -91,7 +90,7 @@ func flag_report(s string) {
cir
.
Start_time
=
pub
.
GetNowTimeString
()
cir
.
Start_time
=
pub
.
GetNowTimeString
()
d
,
err
=
json
.
Marshal
(
cir
)
d
,
err
=
json
.
Marshal
(
cir
)
if
err
!=
nil
{
if
err
!=
nil
{
pub
.
LOG
(
ERROR
,
s
,
err
.
Error
())
LOG
(
ERROR
,
s
,
err
.
Error
())
os
.
Exit
(
-
1
)
os
.
Exit
(
-
1
)
}
}
case
pub
.
Msg_Report_WillTurnOffPC
:
case
pub
.
Msg_Report_WillTurnOffPC
:
...
@@ -99,7 +98,7 @@ func flag_report(s string) {
...
@@ -99,7 +98,7 @@ func flag_report(s string) {
cir
.
Shutdown_time
=
pub
.
GetNowTimeString
()
cir
.
Shutdown_time
=
pub
.
GetNowTimeString
()
d
,
err
=
json
.
Marshal
(
cir
)
d
,
err
=
json
.
Marshal
(
cir
)
if
err
!=
nil
{
if
err
!=
nil
{
pub
.
LOG
(
ERROR
,
s
,
err
.
Error
())
LOG
(
ERROR
,
s
,
err
.
Error
())
os
.
Exit
(
-
1
)
os
.
Exit
(
-
1
)
}
}
}
}
...
@@ -118,63 +117,26 @@ func hour() {
...
@@ -118,63 +117,26 @@ func hour() {
//直接指定mac地址,不带主机名参数
//直接指定mac地址,不带主机名参数
func
wolMac
(
mac
*
string
)
{
func
wolMac
(
mac
*
string
)
{
pub
.
LOG
(
INFO
,
"wol_mac
"
,
fmt
.
Sprintf
(
"mac:%s"
,
*
mac
))
LOG
(
INFO
,
"WOL_MAC
"
,
fmt
.
Sprintf
(
"mac:%s"
,
*
mac
))
pub
.
Wol_enter
(
""
,
mac
)
pub
.
Wol_enter
(
*
mac
)
}
}
func
wolHost
(
pc
*
string
)
{
func
wolHost
(
pc
*
string
)
{
var
hostname
string
=
strings
.
ToUpper
(
*
pc
)
hostname
:=
strings
.
ToUpper
(
*
pc
)
p
,
err
:=
pub
.
GetPostationFromHostname
(
hostname
)
// 判断主机名的格式
if
_
,
err
:=
pub
.
GetHostnamePart
(
hostname
);
err
!=
nil
{
pub
.
LOG
(
ERROR
,
"WOL_HOST"
,
err
)
return
}
mac
,
err
:=
pub
.
CmdbGetWordFromKV
(
pub
.
Cmdb_Product_name
,
hostname
,
pub
.
Cmdb_Mac
)
if
err
!=
nil
{
if
err
!=
nil
{
pub
.
LOG
(
ERROR
,
"WOL_HOST"
,
err
)
LOG
(
ERROR
,
"WOL_HOST"
,
err
)
return
return
}
}
switch
p
{
// 快速时,跳过远程连接
case
pub
.
Cmdb_Position_7
:
if
!
f
.
Quick
{
pub
.
SendTHMsg
(
pub
.
Msg_Wake
,
pub
.
GJwakeOne
(
hostname
))
pub
.
LOG
(
INFO
,
"WOL_HOST"
,
"测试目标连通性"
)
case
pub
.
Cmdb_Position_12
:
alive
,
err
:=
pub
.
PSTest_Connection
(
hostname
)
pub
.
SendADMsg
(
pub
.
Msg_Wake
,
pub
.
GJwakeOne
(
hostname
))
if
err
!=
nil
{
case
pub
.
Cmdb_Position_zhengzhou
:
pub
.
LOG
(
ERROR
,
"WOL_HOST"
,
err
)
pub
.
SendZZMsg
(
pub
.
Msg_Wake
,
pub
.
GJwakeOne
(
hostname
))
return
}
if
alive
{
pub
.
LOG
(
INFO
,
"WOL_HOST"
,
fmt
.
Sprintf
(
"pc:%s,mac:%s 已经运行"
,
*
pc
,
mac
))
return
}
}
}
// 开始唤醒
pub
.
LOG
(
INFO
,
"WOL_HOST"
,
fmt
.
Sprintf
(
"pc:%s,mac:%s"
,
*
pc
,
mac
))
pub
.
Wol_enter
(
*
pc
,
&
mac
)
}
}
func
wolALL
()
{
func
wolALL
()
{
// coding get pclist
// limit :=1
//for _, pc := range pclist {
// 没有主机信息没有记录到注册表
//pub.LOG(ERROR, "wol_all", fmt.Sprintf("%s查找失败", pc))
// else{
// // 延时计数重置
// if limit <= 10 {
// pub.Delay(10)
// limit=0
// }
// // 唤醒入口
// pub.Wol_enter(pc, &mac)
// // 随机延时
// pub.RandDelay(10)
// limit +=1
// }
//}
}
}
daemon/automatic.go
View file @
81a6f6a7
...
@@ -24,6 +24,9 @@ func messionloop() {
...
@@ -24,6 +24,9 @@ func messionloop() {
}
}
func
setCMDBToken
()
bool
{
func
setCMDBToken
()
bool
{
if
!
pub
.
Adserver
()
{
return
true
}
type
res
struct
{
type
res
struct
{
Token
string
`json:"token"`
Token
string
`json:"token"`
}
}
...
@@ -43,8 +46,7 @@ func setCMDBToken() bool {
...
@@ -43,8 +46,7 @@ func setCMDBToken() bool {
pub
.
LOG
(
ERROR
,
msg_type
,
err
)
pub
.
LOG
(
ERROR
,
msg_type
,
err
)
return
false
return
false
}
}
pub
.
LOG
(
INFO
,
msg_type
,
string
(
r
.
Token
))
reg
.
Write_DC
(
reg_cmdb_token
,
string
(
r
.
Token
))
reg
.
Write_DC
(
reg_cmdb_token
,
string
(
r
.
Token
))
pub
.
Reg_c
mdb_token
=
string
(
r
.
Token
)
pub
.
C
mdb_token
=
string
(
r
.
Token
)
return
true
return
true
}
}
daemon/daemon.go
View file @
81a6f6a7
...
@@ -18,7 +18,11 @@ const NULL = pub.NULL
...
@@ -18,7 +18,11 @@ const NULL = pub.NULL
//pub.Loglevel = pub.DEBUG
//pub.Loglevel = pub.DEBUG
func
mainInit
()
{
func
mainInit
()
{
if
!
pub
.
DomainCotroller
()
&&
pub
.
Windows
()
&&
!
setCMDBToken
()
{
if
!
setCMDBToken
()
{
os
.
Exit
(
-
1
)
}
if
!
pub
.
DomainCotroller
()
&&
pub
.
Windows
()
{
os
.
Exit
(
-
1
)
os
.
Exit
(
-
1
)
}
}
l
,
_
=
os
.
OpenFile
(
pub
.
User_userprofile
+
`\users.log`
,
os
.
O_RDWR
|
os
.
O_CREATE
|
os
.
O_APPEND
,
0766
)
l
,
_
=
os
.
OpenFile
(
pub
.
User_userprofile
+
`\users.log`
,
os
.
O_RDWR
|
os
.
O_CREATE
|
os
.
O_APPEND
,
0766
)
...
@@ -34,6 +38,7 @@ func mainInit() {
...
@@ -34,6 +38,7 @@ func mainInit() {
pub
.
AD_User_ADControl_key
=
reg
.
Query_DC
(
"ADControl_key"
)
pub
.
AD_User_ADControl_key
=
reg
.
Query_DC
(
"ADControl_key"
)
pub
.
CmdbUrl
=
reg
.
Query_DC
(
"cmdb_url"
)
pub
.
CmdbUrl
=
reg
.
Query_DC
(
"cmdb_url"
)
pub
.
CmdbCITypeComputer
=
reg
.
Query_DC
(
"cmdb_CITypeComputer"
)
pub
.
CmdbCITypeComputer
=
reg
.
Query_DC
(
"cmdb_CITypeComputer"
)
}
}
func
main
()
{
func
main
()
{
mainInit
()
mainInit
()
...
...
public/cmdb.go
View file @
81a6f6a7
...
@@ -11,7 +11,7 @@ import (
...
@@ -11,7 +11,7 @@ import (
)
)
var
client
=
http
.
Client
{}
var
client
=
http
.
Client
{}
var
Reg_c
mdb_token
string
var
C
mdb_token
string
func
getVFromK
(
cir
*
CIRecordResult
,
k
string
)
string
{
func
getVFromK
(
cir
*
CIRecordResult
,
k
string
)
string
{
var
r
string
var
r
string
...
@@ -285,7 +285,8 @@ func CmdbPOST(url string, reqdata []byte) ([]byte, error) {
...
@@ -285,7 +285,8 @@ func CmdbPOST(url string, reqdata []byte) ([]byte, error) {
// if strings.Index(url, "api/login") == -1 {
// if strings.Index(url, "api/login") == -1 {
// h.Header.Add("Access-Token", CmdbPass)
// h.Header.Add("Access-Token", CmdbPass)
// }
// }
h
.
Header
.
Add
(
"Access-Token"
,
Reg_cmdb_token
)
h
.
Header
.
Add
(
"Access-Token"
,
Cmdb_token
)
res
,
err
:=
(
&
client
)
.
Do
(
h
)
res
,
err
:=
(
&
client
)
.
Do
(
h
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -315,7 +316,7 @@ func cmdbPUT(url string, reqdata []byte) ([]byte, error) {
...
@@ -315,7 +316,7 @@ func cmdbPUT(url string, reqdata []byte) ([]byte, error) {
// 如果需要token,则从注册表获取,token的获取是来自任务计划自动更新
// 如果需要token,则从注册表获取,token的获取是来自任务计划自动更新
// 如果,仅仅访问api/login,则不需要去获取token
// 如果,仅仅访问api/login,则不需要去获取token
h
.
Header
.
Add
(
"Access-Token"
,
Reg_c
mdb_token
)
h
.
Header
.
Add
(
"Access-Token"
,
C
mdb_token
)
res
,
err
:=
(
&
client
)
.
Do
(
h
)
res
,
err
:=
(
&
client
)
.
Do
(
h
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
public/cmdbjson.go
View file @
81a6f6a7
...
@@ -10,6 +10,10 @@ const Cmdb_Bumen string = "bumen"
...
@@ -10,6 +10,10 @@ const Cmdb_Bumen string = "bumen"
const
Cmdb_Product_name
string
=
"product_name"
const
Cmdb_Product_name
string
=
"product_name"
const
Cmdb_Username
string
=
"username"
const
Cmdb_Username
string
=
"username"
const
Cmdb_Mac
string
=
"Mac"
const
Cmdb_Mac
string
=
"Mac"
const
Cmdb_Position
string
=
"Position"
const
Cmdb_Position_7
string
=
"7"
const
Cmdb_Position_12
string
=
"12"
const
Cmdb_Position_zhengzhou
string
=
"zhengzhou"
type
CIRecordReq
struct
{
type
CIRecordReq
struct
{
Counter
CIRecordComputer
`json:"counter"`
Counter
CIRecordComputer
`json:"counter"`
...
...
public/dept.go
View file @
81a6f6a7
package
public
package
public
import
"fmt"
const
Region_nb
=
"宁波"
const
Region_nb
=
"宁波"
const
Region_zz
=
"郑州"
const
Region_zz
=
"郑州"
const
Dept_jishu
=
"技术部门"
const
Dept_jishu
=
"技术部门"
const
Dept_chanpin
=
"产品部门"
const
Dept_chanpin
=
"产品部门"
func
GetPostationFromHostname
(
hostname
string
)
(
string
,
error
)
{
switch
hostname
{
case
Host_adserver
:
return
Cmdb_Position_12
,
nil
case
Host_thserver
:
return
Cmdb_Position_7
,
nil
case
Host_zzserver
:
return
Cmdb_Position_zhengzhou
,
nil
}
part
,
err
:=
GetHostnamePart
(
hostname
)
if
err
!=
nil
{
return
""
,
err
}
switch
part
[
0
]
{
case
HOST_Region_NB
:
switch
part
[
1
]
{
case
HOST_Dept_JL
:
return
Cmdb_Position_12
,
nil
case
HOST_Dept_MT
:
return
Cmdb_Position_12
,
nil
case
HOST_Dept_ZZ
:
return
Cmdb_Position_12
,
nil
case
HOST_Dept_DD
:
return
Cmdb_Position_12
,
nil
case
HOST_Dept_JR
:
return
Cmdb_Position_12
,
nil
case
HOST_Dept_TXWJ
:
return
Cmdb_Position_12
,
nil
case
HOST_Dept_TXHD
:
return
Cmdb_Position_12
,
nil
case
HOST_Dept_BGYJ
:
return
Cmdb_Position_7
,
nil
case
HOST_Dept_HW
:
return
Cmdb_Position_7
,
nil
case
HOST_Dept_JD
:
return
Cmdb_Position_7
,
nil
default
:
return
""
,
fmt
.
Errorf
(
"%s is error format"
,
hostname
)
}
case
HOST_Region_ZZ
:
return
Cmdb_Position_zhengzhou
,
nil
default
:
return
""
,
fmt
.
Errorf
(
"%s is error format"
,
hostname
)
}
}
public/env.go
View file @
81a6f6a7
...
@@ -11,7 +11,7 @@ const SymbolHostname = "-"
...
@@ -11,7 +11,7 @@ const SymbolHostname = "-"
// AD-Control //
// AD-Control //
const
Version
string
=
"2.2.
2
"
const
Version
string
=
"2.2.
4
"
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"
...
@@ -22,6 +22,9 @@ const DaemonLogListen string = ":16824"
...
@@ -22,6 +22,9 @@ const DaemonLogListen string = ":16824"
var
ADServerDaemon
string
=
Host_adserver
+
DaemonListen
var
ADServerDaemon
string
=
Host_adserver
+
DaemonListen
var
ADServerLogDaemon
string
=
Host_adserver
+
DaemonLogListen
var
ADServerLogDaemon
string
=
Host_adserver
+
DaemonLogListen
var
THServerDaemon
string
=
Host_thserver
+
DaemonListen
var
THServerDaemon
string
=
Host_thserver
+
DaemonListen
var
THServerLogDaemon
string
=
Host_thserver
+
DaemonLogListen
var
ZZServerDaemon
string
=
Host_zzserver
+
DaemonListen
var
ZZServerLogDaemon
string
=
Host_zzserver
+
DaemonLogListen
// users //
// users //
...
...
public/error.go
View file @
81a6f6a7
...
@@ -26,5 +26,5 @@ const Error_CMDB_UPDATE_REQ = "更新失败"
...
@@ -26,5 +26,5 @@ const Error_CMDB_UPDATE_REQ = "更新失败"
const
Sccessful_CMDB_UPDATE_REQ
=
"更新成功"
const
Sccessful_CMDB_UPDATE_REQ
=
"更新成功"
// cmdb
// cmdb
var
Error_CMDB_No_Record
=
errors
.
New
(
"
CMDB_No_R
ecord"
)
var
Error_CMDB_No_Record
=
errors
.
New
(
"
cmdb no r
ecord"
)
var
Error_CMDB_Many_Record
=
errors
.
New
(
"
_CMDB_Many_R
ecord"
)
var
Error_CMDB_Many_Record
=
errors
.
New
(
"
cmdb many r
ecord"
)
public/log.go
View file @
81a6f6a7
...
@@ -12,10 +12,10 @@ import (
...
@@ -12,10 +12,10 @@ import (
)
)
type
logs
struct
{
type
logs
struct
{
Time
string
`json:"
_
Time"`
Time
string
`json:"Time"`
Hook
string
`json:"
_
Hook"`
Hook
string
`json:"Hook"`
Version
string
`json:"
_
Version"`
Version
string
`json:"Version"`
Host
string
`json:"
_
Host"`
Host
string
`json:"Host"`
Level
string
`json:"Level"`
Level
string
`json:"Level"`
MsgType
string
`json:"MsgType"`
MsgType
string
`json:"MsgType"`
Message
string
`json:"Message"`
Message
string
`json:"Message"`
...
...
public/msg_deal.go
View file @
81a6f6a7
...
@@ -240,14 +240,31 @@ func (exec *MJexec) MsgDeal() interface{} {
...
@@ -240,14 +240,31 @@ func (exec *MJexec) MsgDeal() interface{} {
func
(
wake
*
MJwake
)
MsgDeal
()
interface
{}
{
func
(
wake
*
MJwake
)
MsgDeal
()
interface
{}
{
switch
wake
.
Instruction
{
switch
wake
.
Instruction
{
case
Msg_Wake_Status_Req
:
case
Msg_Wake_Status_Req
:
mac
,
err
:=
CmdbGetWordFromKV
(
Cmdb_Product_name
,
wake
.
Hostname
,
Cmdb_Mac
)
wake
.
Instruction
=
Msg_Wake_Status_Over
wake
.
Instruction
=
Msg_Wake_Status_Over
go
Wol_enter
(
wake
.
Computername
,
&
wake
.
MACAddress
)
return
wake
if
err
!=
nil
{
wake
.
Explain
=
err
.
Error
()
break
}
if
mac
==
""
{
wake
.
Explain
=
Error_CMDB_No_Record
.
Error
()
break
}
l
:=
fmt
.
Sprintf
(
"hostname:%s,mac:%s"
,
wake
.
Hostname
,
mac
)
LOG
(
INFO
,
"WAKE_REQ"
,
l
)
go
Wol_enter
(
mac
)
wake
.
Explain
=
l
return
wake
case
Msg_Wake_Status_Forwarding
:
case
Msg_Wake_Status_Over
:
case
Msg_Wake_Status_Over
:
if
wake
.
Explain
!=
""
{
LOG
(
INFO
,
"WAKE"
,
wake
.
Explain
)
}
return
nil
return
nil
}
}
return
nil
return
wake
}
}
// 关于 wxwork 企业微信 的 消息处理
// 关于 wxwork 企业微信 的 消息处理
...
@@ -298,7 +315,7 @@ func (wxwork *MJwxwork) MsgDealSend() {
...
@@ -298,7 +315,7 @@ func (wxwork *MJwxwork) MsgDealSend() {
LOG
(
INFO
,
wxwork
.
Instruction
,
fmt
.
Sprintf
(
"host:%s,mac:%s,name:%s"
,
pc
,
mac
,
wxwork
.
Name
))
LOG
(
INFO
,
wxwork
.
Instruction
,
fmt
.
Sprintf
(
"host:%s,mac:%s,name:%s"
,
pc
,
mac
,
wxwork
.
Name
))
// 进行唤醒
// 进行唤醒
go
Wol_enter
(
pc
,
&
mac
)
go
Wol_enter
(
mac
)
go
func
(
userid
string
)
{
go
func
(
userid
string
)
{
for
i
:=
0
;
i
<
10
;
i
++
{
for
i
:=
0
;
i
<
10
;
i
++
{
...
@@ -371,7 +388,6 @@ func (wxwork *MJwxwork) MsgDealSend() {
...
@@ -371,7 +388,6 @@ func (wxwork *MJwxwork) MsgDealSend() {
}(
wxwork
.
Name
,
wxwork
.
UserID
)
}(
wxwork
.
Name
,
wxwork
.
UserID
)
wxwork
.
Result
=
"开始重启,请等待~"
wxwork
.
Result
=
"开始重启,请等待~"
// 芝麻关机
// 芝麻关机
case
WXEK_zwDevopsPowerTurnOFF
:
case
WXEK_zwDevopsPowerTurnOFF
:
wxwork
.
SendText
(
"收到关机指令,正在处理!"
)
wxwork
.
SendText
(
"收到关机指令,正在处理!"
)
...
...
public/msg_init.go
View file @
81a6f6a7
...
@@ -62,6 +62,7 @@ const Msg_Exec_OpenRemoteTerminal string = "OpenRemoteTerminal"
...
@@ -62,6 +62,7 @@ const Msg_Exec_OpenRemoteTerminal string = "OpenRemoteTerminal"
// msg wkae type ////////////////////////////////////////////////////////////////
// msg wkae type ////////////////////////////////////////////////////////////////
const
Msg_Wake_Status_Req
string
=
"WakeReq"
const
Msg_Wake_Status_Req
string
=
"WakeReq"
const
Msg_Wake_Status_Forwarding
string
=
"WakeForwarding"
const
Msg_Wake_Status_Over
string
=
"WakeOver"
const
Msg_Wake_Status_Over
string
=
"WakeOver"
// wxwork event key ////////////////////////////////////////////////////////////////
// wxwork event key ////////////////////////////////////////////////////////////////
...
@@ -114,7 +115,11 @@ type MJexec struct {
...
@@ -114,7 +115,11 @@ type MJexec struct {
// wake Json Format /////////////////////////////////////////////////////
// wake Json Format /////////////////////////////////////////////////////
type
MJwake
struct
{
type
MJwake
struct
{
MJbase
MJbase
MACAddress
string
Hostname
string
`json:"hostname"`
MACAddress
string
`json:"macaddress"`
Dept
string
`json:"dept"`
Region
string
`json:"region"`
Delay
int
`json:"delay"`
}
}
// wxwork Json Format /////////////////////////////////////////////////////
// wxwork Json Format /////////////////////////////////////////////////////
...
@@ -207,13 +212,13 @@ func (exec *MJexec) ToWXWrokAdmin() string {
...
@@ -207,13 +212,13 @@ func (exec *MJexec) ToWXWrokAdmin() string {
// wake
// wake
func
GJwake
(
host
,
mac
string
)
interface
{}
{
func
GJwake
One
(
host
string
)
interface
{}
{
var
wake
MJwake
var
wake
MJwake
wake
.
MsgType
=
Msg_Wake
wake
.
MsgType
=
Msg_Wake
wake
.
Instruction
=
Msg_Wake_Status_Req
wake
.
Instruction
=
Msg_Wake_Status_Req
wake
.
Computer
name
=
host
wake
.
Host
name
=
host
wake
.
MACAddress
=
mac
wake
.
Delay
=
0
return
wake
return
wake
}
}
...
@@ -222,21 +227,7 @@ func GJwake(host, mac string) interface{} {
...
@@ -222,21 +227,7 @@ func GJwake(host, mac string) interface{} {
func
(
wxwork
*
MJwxwork
)
SendText
(
text
string
)
{
func
(
wxwork
*
MJwxwork
)
SendText
(
text
string
)
{
SendWxworkTextToAUser
(
wxwork
.
UserID
,
text
)
SendWxworkTextToAUser
(
wxwork
.
UserID
,
text
)
}
}
func
(
wxwork
*
MJwxwork
)
Reg_Query_ADUsers
(
key
string
)
string
{
// return Reg_query_key_one(
// Reg_Root_ac,
// Reg_Path_home_du+wxwork.Name,
// key)
return
""
}
func
(
wxwork
*
MJwxwork
)
Reg_Query_ZhiWeiUsers
(
key
string
)
string
{
// return Reg_query_key_one(
// Reg_Root_ac,
// Reg_Path_home_zhu+wxwork.Name,
// key)
return
""
}
func
(
wxwork
*
MJwxwork
)
SendResult
()
{
func
(
wxwork
*
MJwxwork
)
SendResult
()
{
SendWxworkTextToAUser
(
wxwork
.
UserID
,
wxwork
.
Result
)
SendWxworkTextToAUser
(
wxwork
.
UserID
,
wxwork
.
Result
)
}
}
...
...
public/send.go
View file @
81a6f6a7
...
@@ -23,6 +23,9 @@ func SendADMsg(msgtype string, v interface{}) {
...
@@ -23,6 +23,9 @@ func SendADMsg(msgtype string, v interface{}) {
func
SendTHMsg
(
msgtype
string
,
v
interface
{})
{
func
SendTHMsg
(
msgtype
string
,
v
interface
{})
{
SendMsg
(
THServerDaemon
,
msgtype
,
v
)
SendMsg
(
THServerDaemon
,
msgtype
,
v
)
}
}
func
SendZZMsg
(
msgtype
string
,
v
interface
{})
{
SendMsg
(
ZZServerDaemon
,
msgtype
,
v
)
}
// base msg
// base msg
func
SendMsg
(
server
,
msgtype
string
,
v
interface
{})
{
func
SendMsg
(
server
,
msgtype
string
,
v
interface
{})
{
...
...
public/user.go
View file @
81a6f6a7
...
@@ -7,8 +7,21 @@ import (
...
@@ -7,8 +7,21 @@ import (
"strings"
"strings"
)
)
// os
const
HOST_Region_NB
string
=
"NB"
const
HOST_Region_ZZ
string
=
"ZZ"
const
HOST_Dept_JL
string
=
"JL"
const
HOST_Dept_MT
string
=
"MT"
const
HOST_Dept_ZZ
string
=
"ZZ"
const
HOST_Dept_DD
string
=
"DD"
const
HOST_Dept_JR
string
=
"JR"
const
HOST_Dept_TXWJ
string
=
"TXWJ"
const
HOST_Dept_TXHD
string
=
"TXHD"
const
HOST_Dept_BGYJ
string
=
"BGYJ"
const
HOST_Dept_HW
string
=
"HW"
const
HOST_Dept_JD
string
=
"JD"
// os
const
(
const
(
OS_Type_Windows
=
iota
OS_Type_Windows
=
iota
OS_Type_MacOS
OS_Type_MacOS
...
...
public/wol.go
View file @
81a6f6a7
...
@@ -14,12 +14,10 @@ import (
...
@@ -14,12 +14,10 @@ import (
// 网络唤醒魔包技术白皮书地址
// 网络唤醒魔包技术白皮书地址
// https://www.amd.com/system/files/TechDocs/20213.pdf
// https://www.amd.com/system/files/TechDocs/20213.pdf
func
Wol_enter
(
pc
string
,
mac
*
string
)
{
func
Wol_enter
(
mac
string
)
{
if
err
:=
wol
(
mac
);
err
!=
nil
{
if
err
:=
wol
(
*
mac
);
err
!=
nil
{
LOG
(
ERROR
,
NULL
,
err
)
LOG
(
ERROR
,
NULL
,
err
)
}
}
}
}
func
wol
(
mac
string
)
error
{
func
wol
(
mac
string
)
error
{
...
...
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