Git Product home page Git Product logo

Comments (6)

rikkix avatar rikkix commented on June 3, 2024

If just use v2gen.ini, the v2gen config will be hard to edit.
It will be sovled in next version, by allowing user to use their own v2ray config template.

from v2gen.

rikkix avatar rikkix commented on June 3, 2024

If just use v2gen.ini, the v2gen config will be hard to edit.
It will be sovled in next version, by allowing user to use their own v2ray config template.

In the latest version,
use --tpl v2rayconfig.tpl to do that

from v2gen.

hongyi-zhao avatar hongyi-zhao commented on June 3, 2024

Failed to test this function, see my following steps:

Firstly, I use the v2rayconfig.tpl which has the following content:

$ cat v2rayconfig.tpl 
{
	"inbounds": [
		{
			"port": 8888,
			"protocol": "socks"
		}
	],
	"outbound": {
		"protocol": "vmess",
		"settings": {
			"vnext": [
				{
					"address": "",
					"port": "",
					"users": [
						{
							"id": "",
							"alterId": "",
							"security": "aes-256-gcm"
						}
					]
				}
			]
		},
		"streamSettings": {
			"network": "",
			"security": "",
			"tlsSettings": null,
			"kcpSettings": null,
			"wsSettings": null,
			"httpSettings": null,
			"quicSettings": null
		}
	}
}


Then I do the test as follows:

$ ./v2gen -tpl ./v2rayconfig.tpl -vmess vmess://eyJhZGQiOiI0NS4zMi44NC4xMzQiLCJhaWQiOiIxIiwiaG9zdCI6IiIsImlkIjoiOTM2NzAxYmUtNmJkNS0yMjc5LWRmZTAtZjBjNTUzMDczNzExIiwibmV0IjoidGNwIiwicGF0aCI6IiIsInBvcnQiOjM5MDAzLCJwcyI6IlNTUlRPT0wuQ09NIiwidGxzIjoiIiwidHlwZSI6Im5vbmUiLCJ2IjoiMiJ9 -p "" -silent
{
	"inbounds": [
		{
			"port": 8888,
			"protocol": "socks"
		}
	],
	"outbound": {
		"protocol": "vmess",
		"settings": {
			"vnext": [
				{
					"address": "",
					"port": "",
					"users": [
						{
							"id": "",
							"alterId": "",
							"security": "aes-256-gcm"
						}
					]
				}
			]
		},
		"streamSettings": {
			"network": "",
			"security": "",
			"tlsSettings": null,
			"kcpSettings": null,
			"wsSettings": null,
			"httpSettings": null,
			"quicSettings": null
		}
	}
}

As you can see, the corresponding field value don't feed the tpl file. Any hints?

from v2gen.

rikkix avatar rikkix commented on June 3, 2024

It should be like

{
  "log": {
    "loglevel": "{{loglevel}}"
  },
  "inbounds": [
    {
      "port": {{socksPort}},
      "protocol": "socks",
      "settings": {
		"udp": {{udp}}
      }
    },
    {
      "port": {{httpPort}},
      "protocol": "http",
      "settings": {
		"udp": {{udp}}
      }
    }
  ],
  "outbound": {
    "protocol": "vmess",
    "settings": {
      "vnext": [
        {
          "address": "{{address}}",
          "port": {{serverPort}},
          "users": [
            {
              "id": "{{uuid}}",
              "alterId": {{aid}},
              "security": "{{security}}"
            }
          ]
        }
      ]
    },
    "streamSettings": {
      "network": "{{network}}",
      "security": "{{streamSecurity}}",
      "tlsSettings": {{tls}},
      "kcpSettings": {{kcp}},
      "wsSettings": {{ws}},
      "httpSettings": {{http}},
      "quicSettings": {{quic}}
    },
    "mux": {
      "enabled": {{mux}},
      "concurrency": {{concurrency}}
    }
  },
  "dns": {
    "servers": [
      "{{dns1}}",
      "{{dns2}}",
      "localhost"
    ]
  },
  "outboundDetour": [
    {
      "protocol": "freedom",
      "settings": {},
      "tag": "direct"
    }
  ],
	"routing": {
		"strategy": "rules",
			"settings": {
			"domainStrategy": "IPIfNonMatch",
				"rules": [{{china_sites}}
					{
    			    "type": "field",
    			    "outboundTag": "direct",
     			    "ip": [{{china_ip}}
       				    "geoip:private"
					]
				}
			]
		}
	}
}

It will replace {{foo}} with bar in v2gen config, with the line foo bar in v2gen config.

uuid aid address serverPort depend on the vmess://xxxx uri

from v2gen.

hongyi-zhao avatar hongyi-zhao commented on June 3, 2024

Are these variables' name are defined by you or from the specification of v2ray?

from v2gen.

rikkix avatar rikkix commented on June 3, 2024

Both.
You can use your own variable names too.

from v2gen.

Related Issues (20)

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.