Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
daycat committed Oct 18, 2022
1 parent 82a9324 commit 2ea0777
Show file tree
Hide file tree
Showing 6 changed files with 7,579 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
30 changes: 30 additions & 0 deletions .github/workflows/build.yaml
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
60 changes: 60 additions & 0 deletions .github/workflows/release.yaml
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
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/daycat/flarestorm

go 1.19
99 changes: 99 additions & 0 deletions main.go
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")
}
}
Loading

0 comments on commit 2ea0777

Please sign in to comment.