Skip to content

Commit

Permalink
fix(v2ray): check export format
Browse files Browse the repository at this point in the history
  • Loading branch information
JinnLynn committed Jun 13, 2024
1 parent ca7d75e commit da91b00
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/genpac/format/v2ray.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import yaml

from ..util import conv_lower
from .base import formater, FmtBase


Expand Down Expand Up @@ -31,10 +32,16 @@ def prepare(cls, parser):
cls.register_option('direct-tag', default=None,
metavar='TAG',
help='直连标签,未指定则不输出直连规则')
cls.register_option('format', default=_DEF_FORMAT,
cls.register_option('format', conv=conv_lower, default=_DEF_FORMAT,
choices=V2RAY_DUMPER.keys(),
help=f'输出格式,默认: {_DEF_FORMAT}')

def pre_generate(self):
if self.options.v2ray_format not in V2RAY_DUMPER.keys():
self.error(f'输出的格式错误,只能是: {list(V2RAY_DUMPER.keys())}')
return False
return super().pre_generate()

def generate(self, replacements):
rules = []
if self.options.v2ray_proxy_tag:
Expand Down

0 comments on commit da91b00

Please sign in to comment.