Skip to content

Commit 0ec6f12

Browse files
authored
Merge pull request #554 from MortezaBashsiz/golang-bugfix
golang-bugfix
2 parents 330024e + 4cca4e7 commit 0ec6f12

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

golang/configuration/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import (
1313
)
1414

1515
var (
16-
PROGRAMDIR = filepath.Dir(os.Args[0])
16+
PROGRAMDIR, _ = filepath.Abs(filepath.Dir(os.Args[0]))
1717
DIR = filepath.Join(PROGRAMDIR, "config")
1818
RESULTDIR = filepath.Join(PROGRAMDIR, "result")
19-
StartDtStr = time.Now().Format("2006-01-02_15:04:05")
19+
StartDtStr = time.Now().Format("2006-01-02_15-04-05")
2020
CSVInterimResultsPath = filepath.Join(RESULTDIR, StartDtStr+"_result.csv")
2121
JSONInterimResultsPath = filepath.Join(RESULTDIR, StartDtStr+"_result.json")
2222
FinalResultsPathSorted = filepath.Join(RESULTDIR, StartDtStr+"_final.txt")

golang/scanner/scan.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ var (
4646
)
4747

4848
// const WorkerCount = 48
49+
4950
func scanner(ip string, Config config.Configuration, Worker config.Worker) *ScanResult {
5051

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

327+
// Save results & sort based on download latency
328+
err := saveResults(results, config.FinalResultsPathSorted, true)
329+
if err != nil {
330+
fmt.Println(err)
331+
return
332+
}
333+
326334
}
327335
func Start(C config.Configuration, Worker config.Worker, ipList []string, threadsCount int) {
328336
var (
@@ -398,12 +406,6 @@ func Start(C config.Configuration, Worker config.Worker, ipList []string, thread
398406
_ = keyboard.Close()
399407
}()
400408

401-
// Save results
402-
err = saveResults(results, config.FinalResultsPathSorted, true)
403-
if err != nil {
404-
fmt.Println(err)
405-
return
406-
}
407409
}
408410

409411
// controller is a event listener for pausing or running workers

golang/utils/utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"net"
99
"net/url"
1010
"os"
11+
"path/filepath"
1112
"strconv"
1213
"strings"
1314
"time"
@@ -32,6 +33,7 @@ func Round(val float64, roundOn float64, places int) (newVal float64) {
3233
}
3334

3435
func CreateDir(dirPath string) {
36+
dirPath = filepath.FromSlash(dirPath)
3537
if _, err := os.Stat(dirPath); os.IsNotExist(err) {
3638
err := os.MkdirAll(dirPath, 0755)
3739
if err != nil {

0 commit comments

Comments
 (0)