-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added client, removed debug from library
- Loading branch information
Showing
2 changed files
with
52 additions
and
1 deletion.
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
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,52 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"gitlab.nobody.run/tbi/LeakIXClient" | ||
"html/template" | ||
"log" | ||
"os" | ||
) | ||
|
||
func main() { | ||
var scope string | ||
flag.StringVar(&scope, "s", "leak", "Specify scope, default to leak") | ||
var query string | ||
flag.StringVar(&query, "q", "*", "Specify search query, default to *") | ||
var outputTemplate string | ||
flag.StringVar(&outputTemplate, "t", "{{ .Ip }}:{{ .Port }}", "Specify output template, default to \"{{ .Ip }}:{{ .Port }}\"") | ||
var limit int | ||
flag.IntVar(&limit, "l", 100, "Limit results output, default to 100") | ||
|
||
flag.Usage = func() { | ||
fmt.Printf("Usage of leakix: \n") | ||
fmt.Printf(" ./leakix -q '*' -l 200\n\n") | ||
flag.PrintDefaults() | ||
} | ||
|
||
flag.Parse() | ||
|
||
searcher := LeakIXClient.SearchResultsClient{ | ||
Scope: scope, | ||
Query: query, | ||
} | ||
|
||
tmpl, err := template.New("output").Parse(outputTemplate + "\n") | ||
if err != nil { | ||
log.Println("Template error :") | ||
log.Fatal(err) | ||
} | ||
count := 0 | ||
for searcher.Next() { | ||
count++ | ||
err = tmpl.Execute(os.Stdout, searcher.SearchResult()) | ||
if err != nil { | ||
log.Println("Template error :") | ||
log.Fatal(err) | ||
} | ||
if count >= limit { | ||
os.Exit(0) | ||
} | ||
} | ||
} |