-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.php
140 lines (124 loc) · 4.42 KB
/
generate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
require 'vendor/autoload.php'; // Make sure to require the autoload file from the library
include 'settings.php';
include 'inc/func.php';
$valid_users = array_keys($valid_passwords);
$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];
$validated = (in_array($user, $valid_users)) && ($pass == $valid_passwords[$user]);
if (!$validated) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
die ("Not authorized");
}
function generateVMessConfig($uuids) {
$clients = [];
foreach ($uuids as $uuid) {
$clients[] = [
"id" => $uuid,
"security" => null,
"email"=> @$_GET['email']
];
}
$config = [
"log" => [
"access" => "/var/log/v2ray/access.log",
"error" => "/var/log/v2ray/error.log",
"loglevel" => "warning"
],
"inbound" => [
"port" => 9999,
"listen" => "0.0.0.0",
"protocol" => "vmess",
"settings" => [
"auth" => null,
"udp" => false,
"ip" => null,
"clients" => $clients
],
"streamSettings" => [
"network" => "tcp",
"security" => "",
"tcpSettings" => [
"connectionReuse" => true,
"header" => [
"type" => "http",
"request" => [
"version" => "1.1",
"method" => "GET",
"path" => ["/"],
"headers" => [
"Host" => ["$host"],
"User-Agent" => [
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36",
"Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/53.0.2785.109 Mobile/14A456 Safari/601.1.46"
],
"Accept-Encoding" => ["gzip, deflate"],
"Connection" => ["keep-alive"],
"Pragma" => "no-cache"
]
],
"response" => [
"version" => "1.1",
"status" => "200",
"reason" => "OK",
"headers" => [
"Content-Type" => ["application/octet-stream", "video/mpeg"],
"Transfer-Encoding" => ["chunked"],
"Connection" => ["keep-alive"],
"Pragma" => "no-cache"
]
]
]
],
"kcpSettings" => null,
"wsSettings" => null
]
],
"outbound" => [
"tag" => null,
"protocol" => "freedom",
"settings" => null,
"streamSettings" => null,
"mux" => null
],
"inboundDetour" => null,
"outboundDetour" => [
[
"protocol" => "blackhole",
"settings" => null,
"tag" => "blocked"
]
],
"dns" => null,
"routing" => [
"strategy" => "rules",
"settings" => [
"rules" => [
[
"type" => "field",
"domain" => ["regexp:.*\\.ir$"],
"outboundTag" => "direct"
],
[
"type" => "field",
"ip" => ["geoip:private", "geoip:ir"],
"outboundTag" => "direct"
]
]
]
]
];
return json_encode(($config), JSON_PRETTY_PRINT);
}
$uuids = [];
// Add new UUIDs here
$uuids[] = generateUUID();
$config = generateVMessConfig($uuids);
$dir = "/usr/local/etc/v2ray";
//$dir = "/Users/afshinakhgar/Projects/afshin";
$filename = $dir."/config.json";
//$filename = "config.json";
file_put_contents($filename, $config);
echo "Generated multi-user VMess configuration.\nSaved to: $filename\n";
?>