Skip to content

Commit

Permalink
Merge pull request #554 from MortezaBashsiz/golang-bugfix
Browse files Browse the repository at this point in the history
golang-bugfix
  • Loading branch information
SonyaCore authored May 11, 2023
2 parents 330024e + 4cca4e7 commit 0ec6f12
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions golang/configuration/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
)

var (
PROGRAMDIR = filepath.Dir(os.Args[0])
PROGRAMDIR, _ = filepath.Abs(filepath.Dir(os.Args[0]))
DIR = filepath.Join(PROGRAMDIR, "config")
RESULTDIR = filepath.Join(PROGRAMDIR, "result")
StartDtStr = time.Now().Format("2006-01-02_15:04:05")
StartDtStr = time.Now().Format("2006-01-02_15-04-05")
CSVInterimResultsPath = filepath.Join(RESULTDIR, StartDtStr+"_result.csv")
JSONInterimResultsPath = filepath.Join(RESULTDIR, StartDtStr+"_result.json")
FinalResultsPathSorted = filepath.Join(RESULTDIR, StartDtStr+"_final.txt")
Expand Down
14 changes: 8 additions & 6 deletions golang/scanner/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var (
)

// const WorkerCount = 48

func scanner(ip string, Config config.Configuration, Worker config.Worker) *ScanResult {

result := &ScanResult{
Expand Down Expand Up @@ -323,6 +324,13 @@ func scan(Config *config.Configuration, worker *config.Worker, ip string) {
Writer.Output()
Writer.Write()

// Save results & sort based on download latency
err := saveResults(results, config.FinalResultsPathSorted, true)
if err != nil {
fmt.Println(err)
return
}

}
func Start(C config.Configuration, Worker config.Worker, ipList []string, threadsCount int) {
var (
Expand Down Expand Up @@ -398,12 +406,6 @@ func Start(C config.Configuration, Worker config.Worker, ipList []string, thread
_ = keyboard.Close()
}()

// Save results
err = saveResults(results, config.FinalResultsPathSorted, true)
if err != nil {
fmt.Println(err)
return
}
}

// controller is a event listener for pausing or running workers
Expand Down
2 changes: 2 additions & 0 deletions golang/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net"
"net/url"
"os"
"path/filepath"
"strconv"
"strings"
"time"
Expand All @@ -32,6 +33,7 @@ func Round(val float64, roundOn float64, places int) (newVal float64) {
}

func CreateDir(dirPath string) {
dirPath = filepath.FromSlash(dirPath)
if _, err := os.Stat(dirPath); os.IsNotExist(err) {
err := os.MkdirAll(dirPath, 0755)
if err != nil {
Expand Down

0 comments on commit 0ec6f12

Please sign in to comment.