GithubHelp home page GithubHelp logo

boypt / vmess2json Goto Github PK

View Code? Open in Web Editor NEW
458.0 458.0 124.0 96 KB

Scripts parse vmess:// links into v2ray config json and vice versa.

License: MIT License

Python 100.00%
v2ray v2rayn v2rayng vmess

vmess2json's Introduction

VmessUtils

VmessUtils consist of a bundle of python scripts that works with vmess:// format and the subscription.

Formerly named vmess2json, is one of the scripts in the project.

  • vmess2json - parses vmess:// to client side json config.
  • json2vmess - parses server side json to vmess://
  • vmesseditor - editor for a vmess:// or a subscription
  • vmesssed - editor for vmess:// subscription, like sed command works for batch job
  • vmessviewer - viewer for vmess:// or subscription

vmess2json's People

Contributors

boypt avatar jm0477 avatar lhy0403 avatar zaoqi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vmess2json's Issues

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

"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.

Reading from subscribe, shows binascii.Error: Incorrect padding

Reading from subscribe ...
Traceback (most recent call last):
File "vmess2json.py", line 723, in
select_multiple(read_subscribe(option.subscribe))
File "vmess2json.py", line 630, in read_subscribe
return base64.b64decode(_subs).decode().splitlines()
File "/usr/lib/python3.7/base64.py", line 87, in b64decode
return binascii.a2b_base64(s)
binascii.Error: Incorrect padding

Could you help on this? is that my subscribe content issue or ?
the subscribe url works well on v2ray gui subscription.

Parse subscription txt file failed with following command

$ cat v2ray.txt | sudo ./vmess2json.py --inbounds http:1081,socks:1080 --output /etc/v2ray/config.json
Traceback (most recent call last):
File "./vmess2json.py", line 725, in
if int(vc["v"]) != 2:
TypeError: 'NoneType' object is not subscriptable

The v2ray.txt was the file provided by ssr provider. and not modified, just name changed

Do you have any idea why this happed?
I tried on Debian9 and Ubuntu 18.04 none of them works. all the same error.

请求批量转换的功能

这个脚本太棒了,省去很多麻烦,感谢作者,希望持续维护。
另外能否提供批量转换vmess的功能,现在每次只能选择其中之一来转换。

转化出错-AttributeError: 'Namespace' object has no attribute 'select'

(test) type result | python vmess2json.py
Found 10 items.

1
2
3
4
5
6
>..(以上均正常显示)
Traceback (most recent call last):
  File "vmess2json.py", line 730, in <module>
    select_multiple(stdin_data)
  File "vmess2json.py", line 658, in select_multiple
    elif int(option.select) > -1:
AttributeError: 'Namespace' object has no attribute 'select'

result文件为

vmess://
x10

How to convert a json to vmess?

I use json2vmess.py without any result. what actually should I do?

Here's the v2ray client config file:

{
	"log": {
		"loglevel": "warning"
	},
	"inbounds": [{
			"port": 1080,
			"protocol": "socks",
			"settings": {
				"udp": true
			}
		},
		{
			"port": 8880,
			"protocol": "http",
			"allowTransparent": false,
			"userLevel": 0
		}
	],
	"outbounds": [{
			"protocol": "vmess",
			"settings": {
				"vnext": [{
					"address": "xxxx",
					"port": 18345,
					"users": [{
						"id": "xxxx",
						"alterId": 0,
						"security": "aes-128-gcm"

					}]
				}]
			},
			"streamSettings": {
				"network": "ws",
				"wsSettings": {
					"path": "/vmess"

				}
			}
		},
		{
			"protocol": "freedom",
			"tag": "direct"
		}
	],
	"routing": {
		"domainStrategy": "IPOnDemand",
		"rules": [

			{

				"domain": ["ext:iran.dat:ir"],
				"outboundTag": "direct",
				"type": "field"
			},
			{

				"domain": ["regexp:.*\\.ir$"],
				"outboundTag": "direct",
				"type": "field"
			},
			{
				"domain": ["regexp:.*\\.cab$"],
				"outboundTag": "direct",
				"type": "field"
			},
			{

				"domain": ["ext:iran.dat:other"],
				"outboundTag": "direct",
				"type": "field"
			},
			{
				"domain": ["ext:iran.dat:other"],
				"outboundTag": "direct",
				"type": "field"
			}
		]
	}
}

always require tty while thiere sys.stdin.isatty() is False

Execute vmess2json.py in non-tty environment with a single vmess URL.

There is an error from select_multiple function:

No such device or address: '/dev/tty'

In line 741:

if len(option.subscribe) > 0:

The value of option.subscribe is '-'.

In line 684-687:

    if sys.stdin.isatty():
        return None
    stdindata = sys.stdin.read()
    option.subscribe = "-"

When isatty returns False. It will continue run option.subscribe = "-".

I don't know about Python. Is this a bug? Hope these information may help you.

Could you please let the ``--outbound --inbounds socks:port'' works?

Hi,

The vmess2json.py 's --outbound option will only out outbound config. I want to combine the following two part in the out of config:

--outbound --inbounds

Say, I want to run the following:

vmess2json.py --outbound --inbounds socks:8888

Could you please let this work?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.