Skip to content

Commit 84bb412

Browse files
authored
Merge pull request #435 from MortezaBashsiz/golang-v1.6-Xray-core
Golang v1.6 xray core
2 parents a03ac8b + 88ed541 commit 84bb412

File tree

16 files changed

+775
-132
lines changed

16 files changed

+775
-132
lines changed

golang/README.md

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,39 @@
33
![go]
44
![version]
55

6-
### CFScanner is a tool written in Golang that scans Cloudflare's edge IPs and locates ones that are viable for use with V2Ray/Xray. It aims to identify edge IPs that are accessible and not blocked.
6+
CFScanner is a powerful tool written in Golang specifically designed to scan Cloudflare's edge IPs and identify viable options for use with V2Ray/Xray.
77

8-
### This program is similar to the bash version, utilizing v2ray+vmess+websocket+tls by default when the VPN flag is enabled. If you wish to use it behind your Cloudflare proxy, you will need to set up a vmess account. Otherwise, the program will use the default configuration.
8+
Its main objective is to locate edge IPs that are accessible and not blocked. With its built-in xray-core, CFScanner leverages xray+vmess+websocket+tls by default when the VPN flag is enabled.
99

10+
If you prefer to use it behind your Cloudflare proxy, you will need to set up a vmess account. However, if no specific configuration is provided, the program will automatically use the default settings.
1011
# Requirements
1112

12-
- Golang v1.18 or higher
13+
- Golang v1.20
1314

1415
# Installation
1516

16-
To install CFScanner, clone the repository and build the binary using the following commands:
17+
### Getting the latest version from release page
18+
Latest release version of golang CFScanner are available in [releases](https://github.com/MortezaBashsiz/CFScanner/releases)
19+
section
1720

21+
22+
### Build instructions
23+
24+
If you prefer to build CFScanner from source, you can follow these instructions:
25+
26+
Clone the repository by running the following command in your terminal:
1827
```bash
1928
git clone https://github.com/MortezaBashsiz/CFScanner.git
29+
```
30+
Navigate to the "golang" directory within the cloned repository:
31+
32+
```bash
2033
cd CFScanner/golang
21-
go build
34+
```
35+
36+
Build the binary using the "go build" command with additional flags for trimming the path and setting linker flags for smaller binary size:
37+
```bash
38+
go build -o CFScanner -trimpath -ldflags "-s -w -buildid=" .
2239
```
2340

2441
## Get Configuration file
@@ -57,7 +74,8 @@ CFScanner takes several arguments:
5774
|------------------------|--------------------------------------------------------------------------------------------------|
5875
| --threads -t | Number of threads to use for parallel scanning. Default is 1. |
5976
| --config -c | The path to the config file. (Required) |
60-
| --vpn | If passed, test with creating VPN connections. |
77+
| --vpn | If passed, test with creating xray-core connections. |
78+
| --loglevel -l | The log level for xray-core (default "none") |
6179
| --subnets -s | The file or subnet. Each line should be in the form of ip.ip.ip.ip/subnet_mask or ip.ip.ip.ip. |
6280
| --shuffle | Shuffling given subnet file or input |
6381
| --upload | If passed, upload test will be conducted. |
@@ -70,17 +88,36 @@ CFScanner takes several arguments:
7088
| --fronting-timeout | Maximum time to wait for fronting response. Default is 1.0. |
7189
| --download-latency | Maximum allowed latency for download. Default is 2.0. |
7290
| --upload-latency | Maximum allowed latency for upload. Default is 2.0. |
73-
| --startprocess-timeout | Process timeout for v2ray. Default is 12. |
74-
| --vpn-path | Custom V2Ray binary path for using v2ray binary in another directory. |
75-
| --writer | Custom output writer for writing interim results. available writers : `csv`/`json` |
76-
# KeyEvent Listeners
91+
| --writer | Custom output writer for writing interim results. available writers : `csv`/`json` |
92+
93+
# Features
94+
95+
### KeyEvent Listeners
7796
CFScanner supports pause and resume progress
7897

7998
- For Pausing current progress press `p`
8099

81100
- For Resuming current progress press `r`
101+
102+
### XRay Core
103+
This Program has built-in Xray-core for testing connection with vpn
104+
105+
xray-core has 5 log levels
106+
107+
**Available log levels**
108+
- debug
109+
- info
110+
- warning
111+
- error
112+
- none
113+
114+
default loglevel is none.
115+
116+
---
117+
82118
# Examples
83119

120+
84121
### Load configuration file and load subnet file for scanning
85122

86123
```bash
@@ -105,21 +142,27 @@ CFScanner supports pause and resume progress
105142
./CFScanner --config config.real --subnets 172.20.0.0/24 --threads 4 --tries 3
106143
```
107144

108-
### Load configurations file with subnet file and using vpn mode with another v2ray binary
145+
### Load configurations file with subnet file and using vpn mode
109146

110147
```bash
111-
./CFScanner --config config.real --subnets 172.20.0.0/24 --vpn --vpn-path ~/v2ray-macos-arm64-v8a/v2ray
148+
./CFScanner --config config.real --subnets 172.20.0.0/24 --vpn
112149
```
113150

151+
---
152+
114153
## Output
115154

116155
Two files are stored for each (complete) run of the program
117156

157+
#### Writer Results
118158
- Interim results file (e.g., `2023-03-10_20:49:30_result.csv` or `2023-03-10_20:49:30_result.json`)
119-
- Includes the unsorted intermediate results in writer format. Useful in case the scanning process is not complete.
159+
- Includes the unsorted intermediate results in specified writer format. Useful in case the scanning process is not complete.
160+
#### Sorted Results
120161
- Final results file (e.g., `2023-03-10_20:49:30_final.txt`)
121162
- Includes the final sorted results. The results are sorted ascending ly based on the download latency time.
122163

164+
all results are stored in `result` folder
165+
123166
# License
124167

125168
CFScanner is released under the [GPL-3](../LICENSE) license.
@@ -129,4 +172,4 @@ CFScanner is released under the [GPL-3](../LICENSE) license.
129172
Contributions are welcome! Please read [CONTRIBUTING.md](../CONTRIBUTING.md) for more information.
130173

131174
[go]: https://img.shields.io/badge/Go-cyan?logo=go
132-
[version]: https://img.shields.io/badge/Version-1.4-blue
175+
[version]: https://img.shields.io/badge/Version-1.6-blue

golang/cmd.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ var nTries int
77

88
var configPath string
99
var subnets string
10-
var vpnPath string
1110

1211
var Vpn bool
12+
var Loglevel string
1313
var doUploadTest bool
1414
var fronting bool
1515
var shuffle bool
@@ -19,7 +19,6 @@ var minULSpeed float64
1919
var maxDLTime float64
2020
var maxULTime float64
2121

22-
var startProcessTimeout float64
2322
var frontingTimeout float64
2423
var maxDLLatency float64
2524
var maxULLatency float64
@@ -31,7 +30,8 @@ var writerType string
3130
func RegisterCommands(rootCmd *cobra.Command) {
3231
rootCmd.PersistentFlags().IntVarP(&threads, "threads", "t", 1, "Number of threads to use for parallel scanning")
3332
rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "", "The path to the config file")
34-
rootCmd.PersistentFlags().BoolVar(&Vpn, "vpn", false, "If passed, test with creating vpn connections")
33+
rootCmd.PersistentFlags().BoolVar(&Vpn, "vpn", false, "If passed, test with creating xray-core connections")
34+
rootCmd.PersistentFlags().StringVarP(&Loglevel, "loglevel", "l", "none", "The log level for xray-core")
3535
rootCmd.PersistentFlags().StringVarP(&subnets, "subnets", "s", "", "The file or subnet. each line should be in the form of ip.ip.ip.ip/subnet_mask or ip.ip.ip.ip.")
3636
rootCmd.PersistentFlags().BoolVar(&shuffle, "shuffle", false, "Shuffling given subnet file or input")
3737
rootCmd.PersistentFlags().BoolVar(&doUploadTest, "upload", false, "If passed, upload test will be conducted")
@@ -44,8 +44,6 @@ func RegisterCommands(rootCmd *cobra.Command) {
4444
rootCmd.PersistentFlags().Float64Var(&frontingTimeout, "fronting-timeout", 1.0, "Maximum time to wait for fronting response")
4545
rootCmd.PersistentFlags().Float64Var(&maxDLLatency, "download-latency", 3.0, "Maximum allowed latency for download")
4646
rootCmd.PersistentFlags().Float64Var(&maxULLatency, "upload-latency", 3.0, "Maximum allowed latency for upload")
47-
rootCmd.PersistentFlags().Float64Var(&startProcessTimeout, "startprocess-timeout", 12, "Process timeout for v2ray")
48-
rootCmd.PersistentFlags().StringVar(&vpnPath, "vpn-path", "", "Custom V2Ray binary path for using v2ray binary in another directory")
4947
rootCmd.PersistentFlags().StringVar(&writerType, "writer", "csv", "Custom output writer for writing interim results. [csv/json]")
5048

5149
}

golang/configuration/config.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414

1515
var (
1616
PROGRAMDIR = filepath.Dir(os.Args[0])
17-
BIN = filepath.Join(PROGRAMDIR, "..", "bin", "v2ray")
1817
DIR = filepath.Join(PROGRAMDIR, "config")
1918
RESULTDIR = filepath.Join(PROGRAMDIR, "result")
2019
StartDtStr = time.Now().Format("2006-01-02_15:04:05")
@@ -31,7 +30,6 @@ WS Header Host: %v%v%v
3130
WS Header Path : %v%v%v
3231
Address Port : %v%v%v
3332
SNI : %v%v%v
34-
Start Proccess Timeout : %v%v%v
3533
Upload Test : %v%v%v
3634
Fronting Request Test : %v%v%v
3735
Minimum Download Speed : %v%v%v
@@ -42,7 +40,8 @@ Fronting Timeout : %v%v%v
4240
Maximum Download Latency : %v%v%v
4341
Maximum Upload Latency : %v%v%v
4442
Number of Tries : %v%v%v
45-
VPN Mode : %v%v%v
43+
Xray-core : %v%v%v
44+
Xray-loglevel : %v%v%v
4645
Shuffling : %v%v%v
4746
Writer : %v%v%v
4847
Total Threads : %v%v%v
@@ -53,7 +52,6 @@ Total Threads : %v%v%v
5352
utils.Colors.OKBLUE, C.Config.WsHeaderPath, utils.Colors.ENDC,
5453
utils.Colors.OKBLUE, C.Config.AddressPort, utils.Colors.ENDC,
5554
utils.Colors.OKBLUE, C.Config.Sni, utils.Colors.ENDC,
56-
utils.Colors.OKBLUE, C.Worker.StartProcessTimeout, utils.Colors.ENDC,
5755
utils.Colors.OKBLUE, C.Config.DoUploadTest, utils.Colors.ENDC,
5856
utils.Colors.OKBLUE, C.Config.DoFrontingTest, utils.Colors.ENDC,
5957
utils.Colors.OKBLUE, C.Worker.Download.MinDlSpeed, utils.Colors.ENDC,
@@ -65,6 +63,7 @@ Total Threads : %v%v%v
6563
utils.Colors.OKBLUE, C.Worker.Upload.MaxUlLatency, utils.Colors.ENDC,
6664
utils.Colors.OKBLUE, C.Config.NTries, utils.Colors.ENDC,
6765
utils.Colors.OKBLUE, C.Worker.Vpn, utils.Colors.ENDC,
66+
utils.Colors.OKBLUE, C.LogLevel, utils.Colors.ENDC,
6867
utils.Colors.OKBLUE, C.Shuffling, utils.Colors.ENDC,
6968
utils.Colors.OKBLUE, C.Config.Writer, utils.Colors.ENDC,
7069
utils.Colors.OKBLUE, C.Worker.Threads, utils.Colors.ENDC,

golang/configuration/types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ type Configuration struct {
44
Config ConfigStruct
55
Worker Worker
66
Shuffling bool
7+
LogLevel string
78
}
89

910
type Worker struct {
10-
Download Download
11-
Upload Upload
12-
StartProcessTimeout float64 // seconds
13-
Threads int
14-
Vpn bool
11+
Download Download
12+
Upload Upload
13+
Threads int
14+
Vpn bool
1515
}
1616

1717
type ConfigStruct struct {

golang/go.mod

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,57 @@
11
module CFScanner
22

3-
go 1.18
3+
go 1.20
44

55
require (
66
github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203
77
github.com/spf13/cobra v1.6.1
8+
github.com/xtls/xray-core v1.8.0
89
)
910

1011
require (
12+
github.com/andybalholm/brotli v1.0.5 // indirect
13+
github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect
14+
github.com/francoispqt/gojay v1.2.13 // indirect
15+
github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 // indirect
16+
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
17+
github.com/golang/mock v1.6.0 // indirect
18+
github.com/golang/protobuf v1.5.3 // indirect
19+
github.com/google/btree v1.1.2 // indirect
20+
github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 // indirect
21+
github.com/gorilla/websocket v1.5.0 // indirect
1122
github.com/inconshreveable/mousetrap v1.0.1 // indirect
23+
github.com/klauspost/compress v1.16.0 // indirect
24+
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
25+
github.com/miekg/dns v1.1.51 // indirect
26+
github.com/onsi/ginkgo/v2 v2.9.0 // indirect
27+
github.com/pelletier/go-toml v1.9.5 // indirect
28+
github.com/pires/go-proxyproto v0.6.2 // indirect
29+
github.com/quic-go/qtls-go1-19 v0.2.1 // indirect
30+
github.com/quic-go/qtls-go1-20 v0.1.1 // indirect
31+
github.com/quic-go/quic-go v0.33.0 // indirect
32+
github.com/refraction-networking/utls v1.2.3-0.20230308205431-4f1df6c200db // indirect
33+
github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect
34+
github.com/sagernet/sing v0.1.7 // indirect
35+
github.com/sagernet/sing-shadowsocks v0.1.1 // indirect
36+
github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c // indirect
37+
github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb // indirect
1238
github.com/spf13/pflag v1.0.5 // indirect
13-
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
39+
github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e // indirect
40+
github.com/xtls/reality v0.0.0-20230309125256-0d0713b108c8 // indirect
41+
go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 // indirect
42+
go.uber.org/atomic v1.10.0 // indirect
43+
golang.org/x/crypto v0.7.0 // indirect
44+
golang.org/x/exp v0.0.0-20230307190834-24139beb5833 // indirect
45+
golang.org/x/mod v0.9.0 // indirect
46+
golang.org/x/net v0.8.0 // indirect
47+
golang.org/x/sys v0.6.0 // indirect
48+
golang.org/x/text v0.8.0 // indirect
49+
golang.org/x/time v0.3.0 // indirect
50+
golang.org/x/tools v0.7.0 // indirect
51+
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
52+
google.golang.org/grpc v1.53.0 // indirect
53+
google.golang.org/protobuf v1.29.0 // indirect
54+
gopkg.in/yaml.v2 v2.4.0 // indirect
55+
gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c // indirect
56+
lukechampine.com/blake3 v1.1.7 // indirect
1457
)

0 commit comments

Comments
 (0)