Skip to content
This repository was archived by the owner on Nov 24, 2024. It is now read-only.

Commit 1b051e4

Browse files
authored
Merge pull request #45 from SonyaCore/update-1.1.5
Update 1.1.5
2 parents 5b117b3 + c9814d5 commit 1b051e4

File tree

2 files changed

+120
-32
lines changed

2 files changed

+120
-32
lines changed

README.md

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,36 @@
88

99
</h1>
1010

11-
<h3>
12-
<strong>V2RayGen / XRayGen</strong> is a fully automated script that helps you to set up your own Xray server in the fastest time.
13-
</h3>
11+
<h3><strong>V2RayGen/XRayGen</strong>: A Fast and Automated Script for XRay/V2Ray Server Setup</h3>
1412

1513
[**Usage**](#usage)
1614

1715
[**Quick Setup**](#quicksetup)
1816

1917
[**Examples**](#examples)
2018

21-
[**Options ⚙️**](#options)
19+
[**Options**](#options)
2220

23-
[**License 🪪**](#license)
21+
[**License**](#license)
2422

25-
[**Donate Me**](#donateme)
23+
[**Donate Me**](#donateme)
2624

2725
## **Prerequisites & Dependencies**
2826

29-
For running this script, you must have **docker**, **docker-compose** and **python3** on your server **but** this script installs `docker` & `docker-compose` if your server doesn't have docker and runs xray-core automatically
27+
- `Python3`
28+
- `Docker`
29+
- `Docker Compose`
30+
<p>If your server lacks Docker and Docker-Compose, the script will install them and launch XRay-Core automatically.</p>
3031

3132
use **sudo** if your current user is not in the docker group or you don't have docker installed
3233

33-
## **How XRayGen Works ?**
34+
## **How Does XRayGen Work?**
3435

35-
`XRayGen` uses docker to pull XRay image from the docker registry and after that, it generates a configuration file to start XRay container.
36+
<p>XRayGen uses Docker to retrieve the xray-core image from the Docker registry. It then generates a configuration file to launch the XRay container.
3637

37-
it also creates a client side configuration file so you can use that with xray-core or v2ray-core.
38+
A client-side configuration file is also created for use with XRay-core or V2Ray-core.
3839

39-
There is also `XRayAgent` for User Management on XRay Configuration which can be used for CRUD operations.
40+
The XRayAgent provides user management for XRay configuration, offering CRUD operations.</p>
4041

4142
## **Usage**
4243

@@ -50,11 +51,12 @@ There is also `XRayAgent` for User Management on XRay Configuration which can be
5051

5152
You can use one of the following protocols for installation and change its settings according to your needs.
5253

53-
| Protoctol | Argument |
54-
| ----------- | ------------- |
55-
| VMESS | --vmess , -wm |
56-
| VMESS + TLS | --vmess --tls |
57-
| VLESS + TLS | --vless , -vl |
54+
| Protoctol | Argument |
55+
| ------------ | -------------- |
56+
| VMESS | --vmess , -wm |
57+
| VMESS + TLS | --vmess --tls |
58+
| VLESS + TLS | --vless , -vl |
59+
| VLESS + XTLS | --vless --xtls |
5860

5961
### **Quick `Xray` Setup with Default Setting** :
6062

@@ -127,6 +129,12 @@ VLESS + Using Google DNS :
127129
curl https://raw.githubusercontent.com/SonyaCore/V2RayGen/main/V2RayGen.py | sudo python3 - --vless --dns google
128130
```
129131

132+
VLESS + XTLS :
133+
134+
```bash
135+
curl https://raw.githubusercontent.com/SonyaCore/V2RayGen/main/V2RayGen.py | sudo python3 - --vless --xtls
136+
```
137+
130138
ShadowSocks + adding shadowsocks port to server :
131139

132140
```bash
@@ -153,10 +161,14 @@ curl https://raw.githubusercontent.com/SonyaCore/V2RayGen/main/V2RayGen.py | pyt
153161

154162
XRayAgent is a Simple User Management for XRay Configuration
155163

156-
> XRayAgent takes user input so you have to download that to your server and then running it
157-
158164
### Download Script & Run With Python3:
159165

166+
```bash
167+
curl https://raw.githubusercontent.com/SonyaCore/V2RayGen/main/V2RayGen.py --output /tmp/v.py && python3 /tmp/v.py --agent
168+
```
169+
170+
OR
171+
160172
```bash
161173
curl https://raw.githubusercontent.com/SonyaCore/V2RayGen/main/XRayAgent.py --output XRayAgent.py
162174
python3 XRayAgent.py
@@ -303,6 +315,12 @@ none : Nothing will be printed.
303315
>
304316
> `it's important to enable allow insecure tls on your client`
305317
318+
`xtls` Using XTLS in specified protocol
319+
320+
> XTLS only supports (TCP, mKCP) so by default when you use --xtls argument tcp mode is being used for vless
321+
>
322+
> also xtls doesn't support vmess protocol
323+
306324
`port` for changing configuration port.
307325

308326
> if you want your v2ray to be listening on a different port use this option

V2RayGen.py

Lines changed: 84 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import string
1919
import csv
2020
import re
21+
import platform
2122
import ipaddress
2223
from urllib.parse import unquote
2324
from urllib.request import urlopen, Request
@@ -31,7 +32,7 @@
3132
NAME = "XRayGen"
3233

3334
# Version
34-
VERSION = "1.1.4"
35+
VERSION = "1.1.5"
3536

3637
# UUID Generation
3738
UUID = uuid.uuid4()
@@ -58,6 +59,10 @@
5859
SOCKSPORT = 10808
5960
HTTPPORT = 10809
6061

62+
## AGENT
63+
AGENT_URL = "https://raw.githubusercontent.com/SonyaCore/V2RayGen/main/XRayAgent.py"
64+
AGENT_PATH = "/tmp/agent.py"
65+
6166
# -------------------------------- Colors --------------------------------- #
6267

6368
# Color Format
@@ -86,6 +91,8 @@ def str2bool(v):
8691

8792

8893
parser.add_argument("--config", "-c", action="store_true", help="Creating only the Configuration file")
94+
parser.add_argument("--agent", "-a", action="store_true", help="Launch XRayAgent")
95+
8996

9097
quick = parser.add_argument_group(f"{green}Protocols{reset}")
9198

@@ -125,6 +132,10 @@ def str2bool(v):
125132
inboundsparser.add_argument(
126133
"--tls", "-t", action="store_true", help="Using TLS in specified protocol"
127134
)
135+
inboundsparser.add_argument(
136+
"--xtls", "-xt", action="store_true", help="Using XTLS in specified protocol"
137+
)
138+
128139

129140
inboundsparser.add_argument(
130141
"--port",
@@ -562,6 +573,14 @@ def create_key():
562573
print(reset)
563574

564575

576+
def clearcmd() -> None:
577+
version = platform.system()
578+
if version in ("Linux", "Darwin"):
579+
subprocess.run("clear")
580+
elif version == "Windows":
581+
subprocess.run("cls")
582+
583+
565584
# def websocket_domaincheck(url = args.domain,t = 10) :
566585
# """
567586
# when using the domain for WebSocket the status code should be 400
@@ -655,7 +674,9 @@ def xray_make():
655674

656675
print(blue + f"! {name} Config Generated." + reset)
657676
if args.vless:
658-
print(yellow + f"! By default TLS is being used for this Protocol" + reset)
677+
print(
678+
"{}! By default TLS is being used for this Protocol{}".format(yellow, reset)
679+
)
659680

660681

661682
def xray_config(outband, protocol) -> str:
@@ -664,17 +685,22 @@ def xray_config(outband, protocol) -> str:
664685
"""
665686
global NETSTREAM
666687

688+
if args.xtls:
689+
print(
690+
"{}! XTLS only supports (TCP,mKCP). Using TCP mode{}".format(yellow, reset)
691+
)
692+
667693
if args.http:
668694
networkstream = http()
669695
NETSTREAM = "HTTP"
670-
elif args.tcp or args.shadowsocks:
696+
elif args.tcp or args.shadowsocks or args.xtls:
671697
networkstream = tcp()
672698
NETSTREAM = "TCP"
673699
else:
674700
networkstream = websocket_config(args.wspath)
675701
NETSTREAM = "WebSocket"
676702

677-
if args.tcp or args.shadowsocks:
703+
if args.tcp or args.shadowsocks or args.xtls:
678704
# TCP stream settings
679705
streamsettings = """
680706
"streamSettings": {
@@ -989,9 +1015,16 @@ def tlssettings() -> str:
9891015
"""
9901016
tls security settings for protocols with tls
9911017
"""
1018+
if args.xtls:
1019+
server_security = "xtls"
1020+
tls_server_type = "xtlsSettings"
1021+
else:
1022+
server_security = "tls"
1023+
tls_server_type = "tlsSettings"
1024+
9921025
tls = """
993-
"security": "tls",
994-
"tlsSettings": {
1026+
"security": "%s",
1027+
"%s": {
9951028
"alpn": ["http/1.1"],
9961029
"certificates": [
9971030
{
@@ -1000,6 +1033,8 @@ def tlssettings() -> str:
10001033
}
10011034
]
10021035
}""" % (
1036+
server_security,
1037+
tls_server_type,
10031038
crtkey,
10041039
hostkey,
10051040
)
@@ -1377,20 +1412,30 @@ def client_side_configuration(protocol):
13771412
HTTPPORT,
13781413
)
13791414

1415+
if args.xtls:
1416+
tls_client_type = "xtlsSettings"
1417+
security = "xtls"
1418+
else:
1419+
tls_client_type = "tlsSettings"
1420+
security = "tls"
1421+
13801422
tls_client = """
1381-
"security": "tls",
1382-
"tlsSettings": {
1423+
"security": "%s",
1424+
"%s": {
13831425
"allowInsecure": true,
13841426
"alpn": [
13851427
"http/1.1"
13861428
],
13871429
"fingerprint": ""
13881430
}
1389-
"""
1431+
""" % (
1432+
security,
1433+
tls_client_type,
1434+
)
13901435

13911436
if args.http:
13921437
network = "http"
1393-
elif args.tcp or args.shadowsocks:
1438+
elif args.tcp or args.shadowsocks or args.xtls:
13941439
network = "tcp"
13951440
else:
13961441
network = "websocket"
@@ -2143,17 +2188,17 @@ def shadowsocks_check():
21432188

21442189
if args.ssmethod not in methodlist:
21452190
print("Select one method :")
2146-
print("{}XRay Ciphers :{}".format(yellow,reset))
2191+
print("{}XRay Ciphers :{}".format(yellow, reset))
21472192

21482193
for xmethods in range(len(xraymethod)):
21492194
print(green + xraymethod[xmethods] + reset)
21502195

2151-
print("{}V2ray Ciphers : {}".format(yellow,reset))
2196+
print("{}V2ray Ciphers : {}".format(yellow, reset))
21522197
for vmethods in range(len(v2raymethod)):
21532198
print(green + v2raymethod[vmethods] + reset)
21542199
sys.exit(2)
21552200

2156-
elif args.ssmethod in (methodlist[0:2] , methodlist[-1]):
2201+
elif args.ssmethod in (methodlist[0:2], methodlist[-1]):
21572202
print(
21582203
"{}{} are only useable in xray-core{}".format(yellow, args.ssmethod, reset)
21592204
)
@@ -2197,6 +2242,14 @@ def base_error(err):
21972242

21982243
user_permission()
21992244

2245+
if args.agent:
2246+
clearcmd()
2247+
subprocess_command = "curl -s {url} --output {path} && python3 {path}".format(
2248+
url=AGENT_URL, path=AGENT_PATH
2249+
)
2250+
subprocess.run(subprocess_command, check=True, shell=True)
2251+
os.remove(AGENT_PATH)
2252+
22002253
# install bbr
22012254
if args.bbr:
22022255
install_bbr()
@@ -2298,7 +2351,13 @@ def base_error(err):
22982351
args.outbound = "both"
22992352

23002353
# link security method
2301-
if args.tls or args.vless:
2354+
if args.tls:
2355+
TLSTYPE = "tls"
2356+
2357+
elif args.xtls:
2358+
TLSTYPE = "xtls"
2359+
2360+
elif args.vless:
23022361
TLSTYPE = "tls"
23032362

23042363
if args.http:
@@ -2311,6 +2370,11 @@ def base_error(err):
23112370
path = "/"
23122371
header = "http"
23132372

2373+
elif args.vless and args.xtls:
2374+
net = "tcp"
2375+
path = "/"
2376+
header = "http"
2377+
23142378
else:
23152379
net = "ws"
23162380
path = args.wspath
@@ -2324,6 +2388,12 @@ def base_error(err):
23242388
if args.linkname == None:
23252389
args.linkname = linkname
23262390

2391+
if args.vmess and args.xtls:
2392+
sys.exit("{}! XTLS doesn't supports VMess for now.{}".format(error, reset))
2393+
2394+
if args.http and args.xtls:
2395+
sys.exit("{}! XTLS doesn't supports HTTP mode{}".format(error, reset))
2396+
23272397
# Quick VMess Setup
23282398
if all((args.vmess, args.tls)):
23292399
xray_create("VMESSTLS")

0 commit comments

Comments
 (0)