🥅 Check for a protocol & print panic errors

This commit is contained in:
perp 2023-11-12 00:46:51 +00:00
parent 0b885ba356
commit b38e4278f2
1 changed files with 9 additions and 2 deletions

View File

@ -1,6 +1,8 @@
package commands
import (
"errors"
"github.com/panjf2000/ants/v2"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
@ -21,10 +23,15 @@ var checkCmd = &cobra.Command{
Use: "check",
Short: "Check proxies from a file",
Run: func(_ *cobra.Command, _ []string) {
// Missing protocol
if socks5 == false && socks4 == false && socks4a == false {
log.Fatal().Err(errors.New("A protocol is required")).Msg("")
}
// Get file lines
lines, err := utils.Read(file)
if err != nil {
log.Panic().Err(err)
log.Panic().Err(err).Msg("")
}
// Get job count & make channel
@ -34,7 +41,7 @@ var checkCmd = &cobra.Command{
// Create new pool
pool, err := ants.NewPool(threads)
if err != nil {
log.Panic().Err(err)
log.Panic().Err(err).Msg("")
}
defer pool.Release()