boypt / vmess2json

Scripts parse vmess:// links into v2ray config json and vice versa.
MIT License
462 stars 125 forks source link

a solution to dictionary key missed problem due to the vmess provider. #17

Open liuliping0315 opened 7 months ago

liuliping0315 commented 7 months ago

"message node" are provided by some airports. like add: "127.0.0.1" with some alias like "Remaining Traffic", "Avai Date".

vmess2json will complain due to the dict "_vinfo" lacking one of the keys in {"ps", "add", "port", "net"}

Temp Solution: I change the code at line 651 in vmess2json.py from

    if _vinfo is not None:
         vmesses.append({ "ps": "[{ps}] {add}:{port}/{net}".format(**_vinfo), "vm": _v })

to

        if _vinfo is not None:
            #if _vinfo["add"] == "127.0.0.1":
            #    continue
            needed_keys = {"ps", "add", "port", "net"}
            if needed_keys.issubset(_vinfo.keys()):
                vmesses.append({ "ps": "[{ps}] {add}:{port}/{net}".format(**_vinfo), "vm": _v })

However, I'm not sure other keys should be considered, and I'm too busy to understand vmess and this convert code. I cannot provide a PR.