Skip to content

Commit

Permalink
Add reverse to clash build-config
Browse files Browse the repository at this point in the history
  • Loading branch information
Hongbo He committed Apr 15, 2020
1 parent fac6d66 commit 6aa2404
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hbkit/clash.py
Expand Up @@ -27,9 +27,11 @@ def cli():
type=click.Choice([
'ss', 'vmess', 'http', 'snell', 'socks5', 'trojan']),
help='Filter by proxy type')
@click.option('--reverse', is_flag=True,
help='Reverse proxy order')
@click.argument('origin', type=click.File('r', encoding='utf-8'),
default=sys.stdin)
def cli_build_config(template, origin, proxy_type):
def cli_build_config(template, origin, proxy_type, reverse):
"""Build new config from origin according to template"""
if not template:
template = pkg_resources \
Expand All @@ -43,6 +45,8 @@ def cli_build_config(template, origin, proxy_type):
proxies = origin.get('proxies') or origin.get('Proxy')
if proxy_type:
proxies = list(filter(lambda p: p['type'] == proxy_type, proxies))
if reverse:
proxies = list(reversed(proxies))
template['proxies'] = proxies
for group in template['proxy-groups']:
if group['name'] in ['FAST', 'FALLBACK', 'SPECIFY']:
Expand Down

0 comments on commit 6aa2404

Please sign in to comment.