mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-22 03:10:42 +08:00
Merge remote-tracking branch 'au/main' into refactoring
This commit is contained in:
+22
-10
@@ -6,6 +6,8 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
var Num int64
|
||||
@@ -32,12 +34,18 @@ func LogSuccess(result string) {
|
||||
|
||||
func SaveLog() {
|
||||
for result := range Results {
|
||||
if Silent == false || strings.Contains(*result, "[+]") || strings.Contains(*result, "[*]") {
|
||||
fmt.Println(*result)
|
||||
if !Silent {
|
||||
if strings.Contains(*result, "[+]") {
|
||||
color.Green(*result)
|
||||
} else if strings.Contains(*result, "[*]") {
|
||||
color.Cyan(*result)
|
||||
}
|
||||
}
|
||||
|
||||
if IsSave {
|
||||
WriteFile(*result, Outputfile)
|
||||
}
|
||||
|
||||
LogWG.Done()
|
||||
}
|
||||
}
|
||||
@@ -49,19 +57,23 @@ func WriteFile(result string, filename string) {
|
||||
fmt.Printf("Open %s error, %v\n", filename, err)
|
||||
return
|
||||
}
|
||||
_, err = fl.Write(text)
|
||||
fl.Close()
|
||||
if err != nil {
|
||||
|
||||
defer func() {
|
||||
_ = fl.Close()
|
||||
}()
|
||||
|
||||
if _, err := fl.Write(text); err != nil {
|
||||
fmt.Printf("Write %s error, %v\n", filename, err)
|
||||
}
|
||||
}
|
||||
|
||||
func LogError(errinfo interface{}) {
|
||||
if WaitTime == 0 {
|
||||
fmt.Printf("completed %v/%v %v \n", End, Num, errinfo)
|
||||
} else if (time.Now().Unix()-LogSucTime) > WaitTime && (time.Now().Unix()-LogErrTime) > WaitTime {
|
||||
fmt.Printf("completed %v/%v %v \n", End, Num, errinfo)
|
||||
LogErrTime = time.Now().Unix()
|
||||
if WaitTime == 0 || (time.Now().Unix()-LogSucTime) > WaitTime && (time.Now().Unix()-LogErrTime) > WaitTime {
|
||||
color.Red(fmt.Sprintf("Completed %v/%v %v \n", End, Num, errinfo))
|
||||
|
||||
if WaitTime != 0 {
|
||||
LogErrTime = time.Now().Unix()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user