From c81467557c462b76d53dc5da8b0e45e325a3f7af Mon Sep 17 00:00:00 2001 From: b3nguang <1127786222@qq.com> Date: Thu, 18 Jul 2024 00:06:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=86=97=E4=BD=99=E9=83=A8?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/Parse.go | 52 +++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/common/Parse.go b/common/Parse.go index 6255bfe..1d1376a 100644 --- a/common/Parse.go +++ b/common/Parse.go @@ -46,50 +46,46 @@ func ParseUser() { func ParsePass() { var PwdList []string - if Password != "" { - passs := strings.Split(Password, ",") - for _, pass := range passs { - if pass != "" { - PwdList = append(PwdList, pass) + + processPwd := func(list []string, items []string) []string { + for _, item := range items { + if item != "" { + list = append(list, item) } } + return list + } + + processURL := func(urls []string, target *[]string) { + TmpUrls := make(map[string]struct{}) + for _, url := range urls { + if _, ok := TmpUrls[url]; !ok && url != "" { + TmpUrls[url] = struct{}{} + *target = append(*target, url) + } + } + } + + if Password != "" { + passs := strings.Split(Password, ",") + PwdList = processPwd(PwdList, passs) Passwords = PwdList } if Passfile != "" { passs, err := Readfile(Passfile) if err == nil { - for _, pass := range passs { - if pass != "" { - PwdList = append(PwdList, pass) - } - } + PwdList = processPwd(PwdList, passs) Passwords = PwdList } } if URL != "" { urls := strings.Split(URL, ",") - TmpUrls := make(map[string]struct{}) - for _, url := range urls { - if _, ok := TmpUrls[url]; !ok { - TmpUrls[url] = struct{}{} - if url != "" { - Urls = append(Urls, url) - } - } - } + processURL(urls, &Urls) } if UrlFile != "" { urls, err := Readfile(UrlFile) if err == nil { - TmpUrls := make(map[string]struct{}) - for _, url := range urls { - if _, ok := TmpUrls[url]; !ok { - TmpUrls[url] = struct{}{} - if url != "" { - Urls = append(Urls, url) - } - } - } + processURL(urls, &Urls) } } if PortFile != "" {