FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
proxycheck/cli.go at main · memclutter/proxycheck · GitHub
memclutter
/
proxycheck
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
proxycheck
/
cli.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
78 lines (67 loc) · 1.77 KB
Breadcrumbs
proxycheck
/
cli.go
Copy path
File metadata and controls
78 lines (67 loc) · 1.77 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package
proxycheck
import
(
"fmt"
cli
"github.com/urfave/cli/v2"
"os"
"strings"
"sync"
)
// NewApp builds the proxycheck CLI application. It is shared by the cmd binary
// and the tests so both exercise the same flag wiring.
func
NewApp
()
*
cli.
App
{
return
&
cli.
App
{
Name
:
"proxycheck"
,
Description
:
"Proxy checker tool"
,
Version
:
"0.0.6"
,
Flags
: []cli.
Flag
{
&
cli.
StringFlag
{
Name
:
"judge"
,
Usage
:
"Set judge"
,
Value
:
"proxyjudge.us"
},
&
cli.
IntFlag
{
Name
:
"threads"
,
Usage
:
"Count of threads"
,
Value
:
10
},
},
Action
:
Action
,
}
}
func
Action
(
c
*
cli.
Context
)
error
{
// Resolve the judge from the --judge flag before doing any work; an unknown
// name aborts here, so no proxy is checked.
judge
,
err
:=
ResolveJudge
(
c
.
String
(
"judge"
))
if
err
!=
nil
{
return
err
}
// If pass args, use it or read stdin as input file with proxies
var
feed
Feed
if
c
.
Args
().
Len
()
>
0
{
feed
=
NewSliceFeed
(
c
.
Args
().
Slice
())
}
else
{
feed
=
NewFileFeed
(
os
.
Stdin
)
}
// Worker pool
poolSize
:=
c
.
Int
(
"threads"
)
proxyAddrs
:=
make
(
chan
string
,
poolSize
)
var
wg
sync.
WaitGroup
for
i
:=
0
;
i
<
poolSize
;
i
++
{
wg
.
Add
(
1
)
go
func
(
proxyAddrs
chan
string
) {
defer
wg
.
Done
()
for
proxyAddr
:=
range
proxyAddrs
{
if
res
:=
Check
(
proxyAddr
,
judge
);
res
.
Online
{
fmt
.
Printf
(
"%s
\t
%s
\t
%s
\n
"
,
proxyAddr
,
strings
.
Join
(
res
.
Protocols
,
","
),
res
.
Speed
.
String
())
}
else
{
fmt
.
Fprintf
(
os
.
Stderr
,
"invalid proxy %s: %v
\n
"
,
proxyAddr
,
res
.
Err
)
}
}
}(
proxyAddrs
)
}
// Start one thread proxy check
for
{
proxyAddr
,
err
:=
feed
.
Next
()
if
err
==
FeedEnd
{
break
}
proxyAddrs
<-
proxyAddr
}
// Closing the channel lets the workers' range loops finish so wg.Wait
// returns once the feed is exhausted.
close
(
proxyAddrs
)
wg
.
Wait
()
return
nil
}
Back
|
FazBrowse Home
|
New Git URL