-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
daycat
committed
Oct 18, 2022
1 parent
82a9324
commit 2ea0777
Showing
6 changed files
with
7,579 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# workflow name | ||
name: Build | ||
|
||
# on events | ||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
|
||
# workflow tasks | ||
jobs: | ||
generate: | ||
name: Generate cross-platform builds | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v2 | ||
- name: Build files | ||
uses: tobyxdd/go-cross-build@d00fc41eb205f57dd90f6e5af4613e21c7ebe73f | ||
with: | ||
platforms: 'darwin/amd64,darwin/arm64,linux/amd64,linux/arm,linux/arm64,linux/mips,linux/mips64,linux/mips64le,linux/mipsle,linux/ppc64,linux/ppc64le,linux/riscv64,linux/s390x,windows/386,windows/amd64,windows/arm' | ||
name: 'flarestorm' | ||
compress: 'false' | ||
dest: 'dist' | ||
- name: Archive | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: dist | ||
path: dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# workflow name | ||
name: Release | ||
|
||
# on events | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
# workflow tasks | ||
jobs: | ||
generate: | ||
name: Generate cross-platform builds | ||
runs-on: ubuntu-latest | ||
env: | ||
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | ||
|
||
steps: | ||
- name: Check out | ||
uses: actions/checkout@v3 | ||
- name: Get tag | ||
uses: olegtarasov/get-tag@v2 | ||
id: tagName | ||
- name: Get time | ||
uses: gerred/actions/current-time@master | ||
id: current-time | ||
- name: Checkout the repository | ||
uses: actions/checkout@v2 | ||
- name: Build files | ||
uses: tobyxdd/go-cross-build@d00fc41eb205f57dd90f6e5af4613e21c7ebe73f | ||
with: | ||
platforms: 'darwin/amd64,darwin/arm64,linux/386,linux/amd64,linux/arm,linux/arm64,linux/mips,linux/mips64,linux/mips64le,linux/mipsle,linux/ppc64,linux/ppc64le,linux/riscv64,linux/s390x,windows/386,windows/amd64,windows/arm' | ||
name: 'flarestorm' | ||
compress: 'false' | ||
dest: 'dist' | ||
- name: Generate hashes | ||
run: | | ||
cd dist | ||
for f in $(find . -type f); do | ||
sha256sum $f | sudo tee -a hashes.txt | ||
done | ||
- name: Upload | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: | | ||
./dist/flarestorm-darwin-amd64 | ||
./dist/flarestorm-darwin-arm64 | ||
./dist/flarestorm-windows-amd64.exe | ||
./dist/flarestorm-windows-386.exe | ||
./dist/flarestorm-windows-arm.exe | ||
./dist/flarestorm-linux-amd64 | ||
./dist/flarestorm-linux-386 | ||
./dist/flarestorm-linux-arm | ||
./dist/flarestorm-linux-arm64 | ||
./dist/flarestorm-linux-s390x | ||
./dist/flarestorm-linux-mipsle | ||
./dist/flarestorm-linux-mips64 | ||
./dist/flarestorm-linux-mips | ||
./dist/flarestorm-linux-ppc64 | ||
./dist/hashes.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/daycat/flarestorm | ||
|
||
go 1.19 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package main | ||
|
||
import ( | ||
_ "embed" | ||
"fmt" | ||
"io/ioutil" | ||
"log" | ||
"math/rand" | ||
"net/http" | ||
"net/netip" | ||
"strings" | ||
"sync" | ||
"time" | ||
) | ||
|
||
//go:embed range.txt | ||
var rangefile string | ||
var ( | ||
mu sync.Mutex | ||
colos = make(map[string][]string) | ||
) | ||
|
||
func Hosts(cidr string) string { | ||
prefix, err := netip.ParsePrefix(cidr) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
var ips = []string{} | ||
count := 1 | ||
for addr := prefix.Addr(); prefix.Contains(addr); addr = addr.Next() { | ||
ips = append(ips, addr.String()) | ||
count += 1 | ||
} | ||
|
||
return ips[rand.Intn(253-1)+1] | ||
//return ips[17] | ||
} | ||
|
||
func GetURL(ip string, wg *sync.WaitGroup, colos map[string][]string) string { | ||
client := http.Client{ | ||
Timeout: 3 * time.Second, | ||
} | ||
url := "http://" + ip + "/cdn-cgi/trace" | ||
resp, err := client.Get(url) | ||
if err != nil { | ||
wg.Done() | ||
return "0" | ||
} | ||
body, err := ioutil.ReadAll(resp.Body) | ||
if err != nil { | ||
wg.Done() | ||
return "0" | ||
} | ||
sb := string(body) | ||
splitted := strings.Fields(sb) | ||
var colosx string | ||
if len(splitted) >= 6 && strings.Contains(splitted[6], "colo=") { | ||
colosx = strings.Split(splitted[6], "colo=")[1] | ||
} else { | ||
wg.Done() | ||
return sb | ||
} | ||
mu.Lock() | ||
colos[colosx] = append(colos[colosx], ip) | ||
mu.Unlock() | ||
wg.Done() | ||
return sb | ||
} | ||
|
||
func init() { | ||
log.SetFlags(log.Ldate | log.Ltime) | ||
} | ||
|
||
func main() { | ||
var ( | ||
wg sync.WaitGroup | ||
ipranges []string | ||
testip []string | ||
timeNow = time.Now() | ||
) | ||
log.Println("----------flarestorm v0.1----------") | ||
ipranges = strings.Fields(rangefile) | ||
for i := 0; i < len(ipranges); i++ { | ||
testip = append(testip, Hosts(ipranges[i])) | ||
} | ||
log.Println("Parsing done in", time.Since(timeNow)) | ||
log.Println("Now testing IP") | ||
for i := 0; i < len(testip); i++ { | ||
wg.Add(1) | ||
go GetURL(testip[i], &wg, colos) | ||
} | ||
wg.Wait() | ||
log.Println("Test finished in ", time.Since(timeNow)) | ||
for key, value := range colos { | ||
fmt.Print("----------", key, " has ", len(value), " subnets", "----------\n") | ||
fmt.Print(value, "\n") | ||
} | ||
} |
Oops, something went wrong.