Commit b7362f3c by 陶腾飞

V1.1.0 更新在注册表中用户状态记录和修正电源状态的记录

parent 99fb8965
......@@ -6,9 +6,15 @@ import (
func main(){
pub.Loger = pub.NewLoger(pub.Dir_userprofile + `\adct.log`)
var logpath string
if pub.Adserver() {
logpath = `F:\logs\`
} else {
logpath = pub.Dir_userprofile
pub.AutoFillInWeDriveDir()
}
pub.Loger = pub.NewLoger(logpath + `\adct.log`)
pub.AutoFillInWeDriveDir()
var backupText = flag.String( pub.Msg_Backup ,"" ,"backup status to AD")
var reportText = flag.String( pub.Msg_Report ,"" ,"report to AD")
......@@ -89,7 +95,7 @@ func flag_woluser(user,pass * string){
}
func flag_wolall(pass * string){
pcgroup := pub.LDAP_Get_PCGroup(pass)
limit :=0
limit :=1
for i,pc := range pcgroup{
mac := pub.Reg_query_key_one(
pub.Reg_Root_ac,
......@@ -99,11 +105,11 @@ func flag_wolall(pass * string){
pub.PntError(pc,"查找注册表失败")
continue
}else{
if limit == 9 {
pub.Delay(300)
if limit <= 10 {
pub.Delay(60)
limit=0
}
pub.PntInfo(i,pc,mac)
pub.PrintLog(i,pc,mac)
pub.RandDelay(10)
flag_wolmac(&mac)
limit +=1
......
......@@ -9,7 +9,7 @@ const DaemonListen string = ":" + DaemonPort
const ADServerDaemon string = Host_adserver + DaemonListen
var LocalDaemon string = User_computername + DaemonListen
const RandMax int = 60
const Version string = "1.0.2"
const Version string = "1.1.0"
// user //
......@@ -96,14 +96,16 @@ const Reg_Name_WeDriveDir string = "WeDriveDir"
const Reg_Name_MACaddress string = "MACaddress"
const Reg_Name_PrimaryUser string = "PrimaryUser"
const Reg_Name_PowerStatus string = "PowerStatus"
const Reg_Name_LogStatus string = "LogStatus"
const Reg_Name_BackupVersion string = "BackupVersion"
// reg value //
var Reg_Value_WeDriveDir string = Reg_query_key_one(HKCU,Reg_Path_home,Reg_Name_WeDriveDir)
var Reg_Value_PowerStatus_ON string = "ON"
var Reg_Value_PowerStatus_OFF string = "OFF"
var Reg_Value_LogStatus_IN string = "IN"
var Reg_Value_LogStatus_OUT string = "OUT"
// other //
......
......@@ -102,7 +102,7 @@ func (rep *MJreport)Msg_Deal() interface{} {
case Msg_Report_WillTurnOnPC:
rep.Reg_Write_AC(
Reg_Name_TurnOffTime,
Reg_Name_TurnOnTime,
UnixTimeParse(&rep.Timestamp))
rep.Reg_Write_AC(
Reg_Name_PowerStatus,
......@@ -115,11 +115,20 @@ func (rep *MJreport)Msg_Deal() interface{} {
rep.Reg_Write_AC(
Reg_Name_LoginTime,
UnixTimeParse(&rep.Timestamp))
rep.Reg_Write_AC(
Reg_Name_LogStatus,
Reg_Value_LogStatus_IN)
case Msg_Report_WillLogOutUser:
rep.Reg_Write_AC(
Reg_Name_LoginUserName,
rep.Username)
rep.Reg_Write_AC(
Reg_Name_LogOffTime,
UnixTimeParse(&rep.Timestamp))
rep.Reg_Write_AC(
Reg_Name_LogStatus,
Reg_Value_LogStatus_OUT)
case Msg_Report_OverCopyToWeDrive:
go func() {
......@@ -235,7 +244,7 @@ func (bak * MJbackup)Msg_Deal() interface{}{
bak.Instruction = Msg_Backup_Status_Continue
wetype,weid,err := GetWeDriveVersion()
if err !=nil{
return GJerror(err)
SendServerError(err)
}
var filename string
switch wetype{
......
......@@ -170,6 +170,7 @@ func (rep * MJreport)Pskill(cmd string){
Pskill(rep.Computername,cmd)
}
func (rep * MJreport)init(Report string) {
rep.Username = User_name
rep.Computername = User_computername
rep.Timestamp = NowTimestamp()
rep.MsgType = Msg_Report
......
......@@ -134,7 +134,8 @@ func AutoGetWeDriveDir() (string,error) {
return "",Error_Null_Folder_WeDrive
}
func AutoFillInWeDriveDir() {
ADserverPanic()
if HostAsUser(){return }
d := Reg_Query_DC(Reg_Name_WeDriveDir)
if d == "" || NotExist(d){
......@@ -154,6 +155,6 @@ func GetWeDriveVersion() (int,string,error) {
} else if strings.Contains(d, "AppData"){
return 1,d,nil
}else {
return 0,"",Error_Null_Folder_WeDrive
return 1,"233",Error_Null_Folder_WeDrive
}
}
\ No newline at end of file
......@@ -59,7 +59,13 @@ func TheUser(s string)bool{
if s == User_name || AdminUser(&s) { return true}
return false
}
func HostAsUser()bool{
if User_name[len(User_name)-1] == '$' {
return true
} else {
return false
}
}
//
//
// If computer
......@@ -73,8 +79,3 @@ func Adserver() bool{
if Host_adserver == User_computername {return true}
return false
}
func ADserverPanic() {
if Host_adserver == User_computername {
panic("no should run me in this env")
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment