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

Adding proxychains output format #59

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion proxybroker/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def add_format_arg(group):
nargs='?',
type=str.lower,
help='''Flag indicating in what format the results will be presented.
Available formats: default and json''')
Available formats: default, proxychains and json''')


def add_show_stats_arg(group):
Expand Down Expand Up @@ -297,6 +297,7 @@ def outformat(outfile, format):
async def handle(proxies, outfile, format):
with outformat(outfile, format):
is_json = format == 'json'
is_proxychains = format == 'proxychains'
is_first = True
while True:
proxy = await proxies.get()
Expand All @@ -305,6 +306,8 @@ async def handle(proxies, outfile, format):

if is_json:
line = '%s' % json.dumps(proxy.as_json())
if is_proxychains:
line = '%s\n' % proxy.as_proxychains()
else:
line = '%r\n' % proxy

Expand Down Expand Up @@ -373,3 +376,7 @@ def cli(args=sys.argv[1:]):
finally:
loop.stop()
loop.close()


if __name__ == "__main__":
cli()
4 changes: 4 additions & 0 deletions proxybroker/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def types(self):
"""
return self._types

def as_proxychains(self):
tp = list(self.types.keys())[0] if self.types.keys() else "http"
return "%s %s %s" % (tp.lower(), self.host, self.port)

@property
def is_working(self):
"""True if the proxy is working, False otherwise.
Expand Down