I am trying to modify a CLI based golang program to a one working on Heroku (GUI). I want to read a file from AWS S3 and use it in the process() and getdomains() function. Need help with the S3 bucket connection and reading of file to put in place of "domains.txt"
Some functions from the Go program Snippet:
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("%s", strings.Repeat(" ", 100))
fmt.Printf("Task completed.
")
}
Thanks!