Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for custom port specifications #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net"
"net/http"
"os"
"log"
"strings"
"sync"
"time"
Expand All @@ -36,6 +37,10 @@ func main() {
var probes probeArgs
flag.Var(&probes, "p", "add additional probe (proto:port)")

// custom probe location flag
var customPath string
flag.StringVar(&customPath, "l", "" ,"Path to the custom port list file")

// skip default probes flag
var skipDefault bool
flag.BoolVar(&skipDefault, "s", false, "skip the default probes (http:80 and https:443)")
Expand Down Expand Up @@ -177,6 +182,29 @@ func main() {
for _, port := range large {
httpsURLs <- fmt.Sprintf("%s:%s", domain, port)
}
case "custom":
if customPath != "" {
if _, err := os.Stat(customPath); err == nil {
file, err := os.Open(customPath)
if err != nil {
log.Printf("Error opening file: %s , did you provide a file path on the -l flag?", err)
break
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
port := scanner.Text()
httpsURLs <- fmt.Sprintf("%s:%s", domain, port)
}
if err := scanner.Err(); err != nil {
log.Printf("Error reading file: %s", err)
}
} else {
log.Printf("Custom file %s not found.", customPath)
}
} else {
log.Println("Custom file path is not provided.")
}
default:
pair := strings.SplitN(p, ":", 2)
if len(pair) != 2 {
Expand Down