Skip to content

Commit dd0de91

Browse files
authored
Merge pull request #466 from MortezaBashsiz/golang-fix
fixed undefined type
2 parents 425f52c + 7095be0 commit dd0de91

File tree

4 files changed

+20
-24
lines changed

4 files changed

+20
-24
lines changed

golang/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.20
44

55
require (
66
github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203
7-
github.com/spf13/cobra v1.6.1
7+
github.com/spf13/cobra v1.7.0
88
github.com/xtls/xray-core v1.8.0
99
)
1010

@@ -19,7 +19,7 @@ require (
1919
github.com/google/btree v1.1.2 // indirect
2020
github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 // indirect
2121
github.com/gorilla/websocket v1.5.0 // indirect
22-
github.com/inconshreveable/mousetrap v1.0.1 // indirect
22+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
2323
github.com/klauspost/compress v1.16.0 // indirect
2424
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
2525
github.com/miekg/dns v1.1.51 // indirect
@@ -44,7 +44,7 @@ require (
4444
golang.org/x/exp v0.0.0-20230307190834-24139beb5833 // indirect
4545
golang.org/x/mod v0.9.0 // indirect
4646
golang.org/x/net v0.8.0 // indirect
47-
golang.org/x/sys v0.7.0 // indirect
47+
golang.org/x/sys v0.6.0 // indirect
4848
golang.org/x/text v0.8.0 // indirect
4949
golang.org/x/time v0.3.0 // indirect
5050
golang.org/x/tools v0.7.0 // indirect

golang/go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWm
8787
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
8888
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
8989
github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw=
90-
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
91-
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
90+
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
91+
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
9292
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU=
9393
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
9494
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
@@ -175,8 +175,8 @@ github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYED
175175
github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
176176
github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE=
177177
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
178-
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
179-
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
178+
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
179+
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
180180
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
181181
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
182182
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -267,8 +267,8 @@ golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBc
267267
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
268268
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
269269
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
270-
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
271-
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
270+
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
271+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
272272
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
273273
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
274274
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
package scanner
22

3-
import "C"
43
import (
54
config "CFScanner/configuration"
65
"CFScanner/logger"
76
"CFScanner/speedtest"
87
"CFScanner/utils"
98
"CFScanner/vpn"
109
"fmt"
11-
"github.com/eiannone/keyboard"
1210
"math"
1311
"os"
1412
"runtime"
1513
"strconv"
1614
"strings"
1715
"sync"
1816
"time"
17+
18+
"github.com/eiannone/keyboard"
1919
)
2020

2121
var results [][]string
@@ -27,7 +27,7 @@ var (
2727
uploadLatency float64
2828
)
2929

30-
type Result struct {
30+
type ScanResult struct {
3131
IP string
3232
Download struct {
3333
Speed []float64
@@ -46,9 +46,9 @@ var (
4646
)
4747

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

51-
result := &Result{
51+
result := &ScanResult{
5252
IP: ip,
5353
}
5454

@@ -67,11 +67,7 @@ func scanner(ip string, Config config.Configuration, Worker config.Worker) *Resu
6767
proxies = vpn.ProxyBind(listen, port)
6868

6969
// wait for port
70-
waitPort := utils.WaitForPort(listen, port, time.Duration(5))
71-
72-
if waitPort != nil {
73-
fmt.Errorf(waitPort.Error())
74-
}
70+
utils.WaitForPort(listen, port, time.Duration(5))
7571

7672
var err error
7773
process = vpn.XRayInstance(xrayConfigPath)
@@ -142,7 +138,7 @@ func scanner(ip string, Config config.Configuration, Worker config.Worker) *Resu
142138
return result
143139
}
144140

145-
func uploader(ip string, Upload *config.Upload, proxies map[string]string, result *Result) (*Result, bool) {
141+
func uploader(ip string, Upload *config.Upload, proxies map[string]string, result *ScanResult) (*ScanResult, bool) {
146142
var err error
147143
nBytes := Upload.MinUlSpeed * 1000 * Upload.MaxUlTime
148144
uploadSpeed, uploadLatency, err = speedtest.UploadSpeedTest(int(nBytes), proxies,
@@ -188,7 +184,7 @@ func uploader(ip string, Upload *config.Upload, proxies map[string]string, resul
188184
return nil, false
189185
}
190186

191-
func downloader(ip string, Download *config.Download, proxies map[string]string, result *Result) (*Result, bool) {
187+
func downloader(ip string, Download *config.Download, proxies map[string]string, result *ScanResult) (*ScanResult, bool) {
192188
nBytes := Download.MinDlSpeed * 1000 * Download.MaxDlTime
193189
var err error
194190

@@ -312,7 +308,7 @@ func scan(Config *config.Configuration, worker *config.Worker, ip string) {
312308
MeanUploadLatency: meanUploadLatency,
313309
}
314310
default:
315-
cause := fmt.Errorf("Invalid writer type: %s\n", Config.Config.Writer)
311+
cause := fmt.Errorf("invalid writer type: %s", Config.Config.Writer)
316312
ld := logger.ScannerManage{
317313
IP: "",
318314
Status: logger.ErrorStatus,

golang/scanner/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type Writer interface {
66
}
77

88
type CSV struct {
9-
res *Result
9+
res *ScanResult
1010
IP string
1111
DownloadMeanJitter float64
1212
UploadMeanJitter float64
@@ -17,7 +17,7 @@ type CSV struct {
1717
}
1818

1919
type JSON struct {
20-
res *Result
20+
res *ScanResult
2121
IP string `json:"ip"`
2222
DownloadMeanJitter float64 `json:"downloadMeanJitter"`
2323
UploadMeanJitter float64 `json:"uploadMeanJitter"`

0 commit comments

Comments
 (0)