Documentation
¶
Overview ¶
Example ¶
package main import ( "bytes" "fmt" "github.com/9uuso/proksi" "os" "path/filepath" "time" ) func main() { dir, err := filepath.Abs(filepath.Dir(os.Args[0])) if err != nil { fmt.Println(err) os.Exit(1) } proxychan := make(chan proksi.Proxy) lines := 0 amountOf := 0 alive := 0 te := time.Now() var timeout = time.Millisecond * 2500 var buffer bytes.Buffer proxies, err := proksi.ReadFile(dir + "/proxies.txt") if err != nil { fmt.Println(err) } for _, proxy := range proxies { lines++ amountOf++ go proksi.ResolveAndWrite(proxychan, proxy, timeout, "http://google.com/") } for proxy := range proxychan { lines-- if proxy.Alive { alive++ buffer.WriteString(proxy.Address + "\n") } if lines == 0 { err := proksi.WriteFile(dir+"/checked-proxies.txt", buffer) if err != nil { fmt.Println(err) } fmt.Println("Checked", amountOf, "proxies in", time.Now().Sub(te), "and of which", alive, "responded.") } } }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadFile ¶
ReadFile returns string array of IP addresses in a file. It uses scanner.Scan() to parse IP's from the given file.
func Resolve ¶
Resolve makes TCP connection to given host with given timeout. The function broadcasts to given channel about the response of the connection. Even if the connection is refused or it times out, the channel will receive new proxy instance with filled fields.
func ResolveAndWrite ¶
Same as Resolve function, but takes in extra parameter which defines what HTTP site the proxy will attempt to connect with HEAD. The timeout in both TCP and HTTP connections are the same. Useful for checking whether a proxy is busy or not.
Types ¶
Click to show internal directories.
Click to hide internal directories.