我正在尝试将基于CLI的golang程序修改为使用Heroku(GUI)的程序。我想从AWS S3读取文件并在process()和getdomains()函数中使用它。需要有关S3存储桶连接和读取文件的帮助来代替“domains.txt”
Go程序代码段中的一些函数:
package main
import (
"bufio"
"bytes"
"crypto/tls"
"fmt"
"io/ioutil"
"log"
"math/rand"
"net"
"net/http"
"os"
"strings"
"sync"
"time"
)
var Wordlist string = ""
var int Threads, Timeout
var Https, Strict bool = false, false
type Http struct {
Url, Num string
}
func getDomains(path string) (lines []string, Error error) {
file, err := os.Open(path)
if err != nil {
log.Fatalln(err)
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
lines = append(lines, scanner.Text())
}
return lines, scanner.Err()
}
func Process() {
urls := make(chan *Http, Threads*10) // parameters threads taken as input from html form
list, err := getDomains("file name taken from html form")
if err != nil {
log.Fatalln(err)
}
var wg sync.WaitGroup
for i := 0; i < Threads; i++ {
wg.Add(1)
go func() {
for url := range urls {
url.DNS()
}
wg.Done()
}()
}
for i := 0; i < len(list); i++ {
Progress := fmt.Sprintf("%d", len(list))
urls <- &Http{Url: list[i], Num: Progress}
}
close(urls)
wg.Wait()
fmt.Printf("\r%s", strings.Repeat(" ", 100))
fmt.Printf("\rTask completed.\n")
}
谢谢!