Compare commits

...

4 Commits

Author SHA1 Message Date
ultimateplayer1999 06eb50358a
Added time to output with a time difference calculation.
Signed-off-by: ultimateplayer1999 <ultimateplayer1999@gmail.com>
2023-01-10 13:16:06 +01:00
ultimateplayer1999 75edc9fb79
Added time to output with a time difference calculation.
Signed-off-by: ultimateplayer1999 <ultimateplayer1999@gmail.com>
2023-01-10 13:13:40 +01:00
ultimateplayer1999 e3bb9ddccb
Added time to output with a time difference calculation. - Ultimateplayer1999 2023-01-10 13:05:56 +01:00
ultimateplayer1999 639ff3ceb7
Changed source to include time - ultimateplayer1999 2023-01-10 11:23:10 +01:00
4 changed files with 36 additions and 4 deletions

View File

@ -672,3 +672,4 @@ may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -14,3 +14,5 @@ The following code is needed in a .env. This is for the DB connection.
> DB_PASS=
This is based on the phish table. Table can also be changed if needed.
Execution time is *1h24m16.934194673s*. This was for **18811 records**.

View File

@ -8,6 +8,7 @@ import (
"net/http"
"io/ioutil"
"encoding/json"
"time"
"github.com/joho/godotenv"
@ -33,6 +34,13 @@ func main() {
log.Fatal(err)
}
// Get the start time
StartTime := time.Now()
// Format the start time
formattedStartTime := StartTime.Format("02-01-2006 15:04:05")
fmt.Println("Script started at " + formattedStartTime)
// Perform a cleanup on DB
deleter, err := db.Exec("DELETE FROM phish;")
if err != nil {
@ -43,7 +51,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
fmt.Printf("Number of rows affected: %d\n", rowsAffected)
fmt.Printf("Deletion: Number of rows affected: %d\n", rowsAffected)
// Perform a cleanup on DB
aiupdate, err := db.Exec("ALTER TABLE phish AUTO_INCREMENT = 0;")
@ -55,7 +63,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
fmt.Printf("Number of rows affected: %d\n", rowsAffected)
fmt.Printf("Altering: Number of rows affected: %d\n", rowsAffected)
// Add local records first
insert1, err := db.Exec("INSERT INTO phish (Domain, Reporter, Evidence) VALUES ('iriseperiplo.info', 'Henk', 'https://www.virustotal.com/gui/url/318ac29af0001f6678efdd94c16d3225d78369123ebbbe5f50387b208e0ac523?nocache=1');")
@ -71,13 +79,13 @@ func main() {
if err != nil {
log.Fatal(err)
}
fmt.Printf("Number of rows affected: %d\n", rowsAffected)
fmt.Printf("Insert: Number of rows affected: %d\n", rowsAffected)
// Get the number of affected rows
rowsAffected, err = insert2.RowsAffected()
if err != nil {
log.Fatal(err)
}
fmt.Printf("Number of rows affected: %d\n", rowsAffected)
fmt.Printf("Insert: Number of rows affected: %d\n", rowsAffected)
// Define name for use later
// name := os.Getenv("USER_OR_BOTNAME")
@ -95,6 +103,10 @@ func main() {
}
defer resp.Body.Close()
currentTime := time.Now()
formattedTime := currentTime.Format("02-01-2006 15:04:05")
fmt.Println(formattedTime + ": Initial database table setup done")
fmt.Println("Status code: ", resp.StatusCode)
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
@ -125,6 +137,23 @@ func main() {
totalRowsAffected += rowsAffected
}
fmt.Printf("Total number of rows affected: %d\n", totalRowsAffected)
// Get the end time
EndTime := time.Now()
// Format the end time
formattedEndTime := EndTime.Format("02-01-2006 15:04:05")
fmt.Println("Recent changes recieved and has been added to the database. Removed domains deleted from database. Reorded domains.")
fmt.Println("Script ended at " + formattedEndTime)
// Calculate the time difference
diff := EndTime.Sub(StartTime)
// Print the time difference
fmt.Println("Time until completion: ", diff)
// dummy
// fmt.Println("Data: ", string(body))
}

Binary file not shown.