Projects STRLCPY goc2 Commits 376ce889
🤬
  • goc2
    Binary file.
  • ■ ■ ■ ■ ■ ■
    internal/app/api/agent.go
    skipped 3 lines
    4 4   "encoding/json"
    5 5   "fmt"
    6 6   "log"
     7 + "strconv"
    7 8   "time"
    8 9   
    9 10   "github.com/globalsign/mgo"
    skipped 20 lines
    30 31  //GetSecrets api data
    31 32  func GetAgents() []byte {
    32 33   //query := bson.M{}
     34 + anHourAgo := time.Now().Add(-time.Minute)
    33 35   
    34 36   session, err := mgo.Dial("127.0.0.1")
    35 37   if err != nil {
    skipped 6 lines
    42 44   
    43 45   // Query All
    44 46   var results []Agent
    45  - err = c.Find(bson.M{}).All(&results)
     47 + err = c.Find(bson.M{"checkIn": bson.M{"$gt": anHourAgo}}).All(&results)
    46 48   
    47 49   if err != nil {
    48 50   panic(err)
    skipped 173 lines
    222 224   
    223 225  //NewCMD command read status
    224 226  func AgentCreate(agent string, wd string) {
     227 + timestamp := strconv.FormatInt(time.Now().UTC().UnixNano(), 10)
    225 228   fmt.Println("creating agent")
    226 229   fmt.Println(agent)
    227  - query := bson.M{"agent": agent, "working": wd, "checkIn": time.Now()}
     230 + query := bson.M{"agent": agent, "working": wd, "checkIn": timestamp}
    228 231   session, err := mgo.Dial("127.0.0.1")
    229 232   if err != nil {
    230 233   panic(err)
    skipped 9 lines
  • ■ ■ ■ ■ ■ ■
    pkg/cli/cli.go
    skipped 59 lines
    60 60   }
    61 61   
    62 62   for _, d := range results {
    63  - fmt.Fprintln(os.Stderr, "Agent: "+d.Agent+"\tDir: "+d.Working+"\tSeen: "+d.checkIn.String()+"\n")
     63 + fmt.Fprintln(os.Stderr, "Active callback: "+d.Agent)
    64 64   }
    65 65  }
    66 66   
    skipped 15 lines
    82 82   if err != nil {
    83 83   fmt.Fprintln(os.Stderr, err)
    84 84   }
    85  - deadline := time.Now().Add(5 * time.Second)
     85 + deadline := time.Now().Add(15 * time.Second)
    86 86   for {
    87 87   data := getJSON(c2+"/api/cmd/output/"+agent, c2)
    88 88   if data == "True" || cmdString == "\n" {
    skipped 102 lines
Please wait...
Page is in error, reload to recover