Esempio n. 1
0
// SendUnsyncedFiles sends unsynchronized files to the server (ie, files modified after last_accessed)
func SendUnsyncedFiles(tlsConn *tls.Conn, last_accessed int64, private_key []byte) {
	files, err := GBClientWatch.CheckForFilesToSendToServerOnInit(last_accessed)
	checkErr(err, tlsConn)

	for _, fileData := range files {
		log.Println(fileData)
		GBClientNetworkTools.SendDataEncrypted(tlsConn, fileData, GBClientNetworkTools.FILE_ADDED_CONST, private_key)
	}
}
Esempio n. 2
0
// GracefullyExit is the default exit method for the binary.
func GracefullyExit(tlsConn *tls.Conn, key []byte) {

	// Kill command to server
	err := GBClientNetworkTools.SendDataEncrypted(tlsConn, GBClientWatch.OutputData{"kill", true, 1, 1}, GBClientNetworkTools.DISCONNECT_CONST, key)
	if err != nil {
		fmt.Printf("Error: %s\n", err.Error())
	}

	// Allow time to send request
	time.Sleep(200 * time.Millisecond)

	tlsConn.Close()
	os.Exit(1)
}