Auto generate script for all in one configs (#145)

* fixes default template value for password at server.json:237

* Auto config generation script

* Readme fix

* remove ?ed=2048

* remove h2 tcp
This commit is contained in:
bghandchi 2023-04-13 20:04:12 +03:00 committed by GitHub
parent d35c6f5aaa
commit 004c490c7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 175 additions and 2 deletions

View file

@ -76,14 +76,27 @@ VMESS-gRPC Request ------> Xray Vless-TCP-XTLS(443) ----**alpn=h2**----> fallbac
| Combination | Link |
| ----------- | ---- |
| Trojan-TCP | `trojan://desdemona99@example.com:443?security=tls&type=tcp#Trojan-TCP` |
| Trojan-WS | `trojan://desdemona99@example.com:443?security=tls&type=ws&path=/trojanws?ed=2048#Trojna-WS` |
| Trojan-WS | `trojan://desdemona99@example.com:443?security=tls&type=ws&path=/trojanws#Trojna-WS` |
| Trojan-gRPC | `trojan://desdemona99@example.com:443?security=tls&type=grpc&serviceName=trgrpc#Trojan-gRPC` |
| Trojan-H2 | `trojan://desdemona99@example.com:443?sni=trh2o.example.com&security=tls&type=http&path=/trh2#Trojan-H2` |
| Vless-TCP | `vless://90e4903e-66a4-45f7-abda-fd5d5ed7f797@example.com:443?security=tls&type=tcp#Vless-TCP` |
| Vless-WS | `vless://90e4903e-66a4-45f7-abda-fd5d5ed7f797@example.com:443?security=tls&type=ws?ed=2048&path=/vlws#Vless-WS` |
| Vless-WS | `vless://90e4903e-66a4-45f7-abda-fd5d5ed7f797@example.com:443?security=tls&type=ws&path=/vlws#Vless-WS` |
| Vless-gRPC | `vless://90e4903e-66a4-45f7-abda-fd5d5ed7f797@example.com:443?security=tls&type=grpc&serviceName=vlgrpc#Vless-gRPC` |
| Vless-H2 | `vless://90e4903e-66a4-45f7-abda-fd5d5ed7f797@example.com:443?sni=vlh2o.example.com&security=tls&type=http&path=/vlh2#Vless-H2` |
| VMESS-TCP | `vmess://ewogICAgImFkZCI6ICJleGFtcGxlLmNvbSIsCiAgICAiYWlkIjogIjAiLAogICAgImhvc3QiOiAiIiwKICAgICJpZCI6ICI5MGU0OTAzZS02NmE0LTQ1ZjctYWJkYS1mZDVkNWVkN2Y3OTciLAogICAgIm5ldCI6ICJ0Y3AiLAogICAgInBhdGgiOiAiL3ZtdGMiLAogICAgInBvcnQiOiAiNDQzIiwKICAgICJwcyI6ICJWTUVTUy1UQ1AiLAogICAgInNjeSI6ICJub25lIiwKICAgICJzbmkiOiAiIiwKICAgICJ0bHMiOiAidGxzIiwKICAgICJ0eXBlIjogImh0dHAiLAogICAgInYiOiAiMiIKfQo=` |
| VMESS-WS | `vmess://ewogICAgImFkZCI6ICJleGFtcGxlLmNvbSIsCiAgICAiYWlkIjogIjAiLAogICAgImhvc3QiOiAiIiwKICAgICJpZCI6ICI5MGU0OTAzZS02NmE0LTQ1ZjctYWJkYS1mZDVkNWVkN2Y3OTciLAogICAgIm5ldCI6ICJ3cyIsCiAgICAicGF0aCI6ICIvdm13cyIsCiAgICAicG9ydCI6ICI0NDMiLAogICAgInBzIjogIlZNRVNTLVdTIiwKICAgICJzY3kiOiAibm9uZSIsCiAgICAic25pIjogIiIsCiAgICAidGxzIjogInRscyIsCiAgICAidHlwZSI6ICIiLAogICAgInYiOiAiMiIKfQo=` |
| VMESS-gRPC | `vmess://ewogICAgImFkZCI6ICJleGFtcGxlLmNvbSIsCiAgICAiYWlkIjogIjAiLAogICAgImhvc3QiOiAiIiwKICAgICJpZCI6ICI5MGU0OTAzZS02NmE0LTQ1ZjctYWJkYS1mZDVkNWVkN2Y3OTciLAogICAgIm5ldCI6ICJncnBjIiwKICAgICJwYXRoIjogInZtZ3JwYyIsCiAgICAicG9ydCI6ICI0NDMiLAogICAgInBzIjogIlZNRVNTLWdSUEMiLAogICAgInNjeSI6ICJub25lIiwKICAgICJzbmkiOiAiIiwKICAgICJ0bHMiOiAidGxzIiwKICAgICJ0eXBlIjogImh0dHAiLAogICAgInYiOiAiMiIKfQo=` |
| VMESS-H2 | `vmess://ewogICAgImFkZCI6ICJleGFtcGxlLmNvbSIsCiAgICAiYWlkIjogIjAiLAogICAgImhvc3QiOiAiIiwKICAgICJpZCI6ICI5MGU0OTAzZS02NmE0LTQ1ZjctYWJkYS1mZDVkNWVkN2Y3OTciLAogICAgIm5ldCI6ICJodHRwIiwKICAgICJwYXRoIjogIi92bWgyIiwKICAgICJwb3J0IjogIjQ0MyIsCiAgICAicHMiOiAiVk1FU1MtSDIiLAogICAgInNjeSI6ICJub25lIiwKICAgICJzbmkiOiAidm1oMm8uZXhhbXBsZS5jb20iLAogICAgInRscyI6ICJ0bHMiLAogICAgInR5cGUiOiAiaHR0cCIsCiAgICAidiI6ICIyIgp9Cg==` |
## Config generation script
To make all the necessary changes to all the files in this folder a simple script is provided.
### Steps
* Open `generate.sh` and change the top lines to your correct values.
* Run `bash generate.sh -m` inside this folder.
* All the files are changed and your config links are stored in `result.txt`
* Run `bash generate.sh -b` to get one base64 string for all of your configs.
* Run `bash generate.sh -q` to get separate qr codes for all your configs.
* Run `bash generate.sh -r` to revert all the changes. This is necessary for generating configs with new values.
### Important note
Run `-b` and `-q` only after running `-m`. The script should run inside this folder.

View file

@ -0,0 +1,160 @@
#!/bin/bash
#################################
# main domain #
#################################
export main_domain="your.domain.com" # Change this to the correct value
export main_domain_crt="\/path\/to\/main\/domain\/fullchain.pem" # Change this to the correct value
export main_domain_key="\/path\/to\/main\/domain\/privkey.pem" # Change this to the correct value
#################################
# behind cdn domain #
#################################
export cdn_domain="" # Change this to the correct value
export cdn_domain_crt="\/path\/to\/cdn\/domain\/fullchain.pem" # Change this to the correct value
export cdn_domain_key="\/path\/to\/cdn\/domain\/privkey.pem" # Change this to the correct value
#################################
# uuid/pass #
#################################
export myid=`xray uuid` # (optional) Let xray pick a random uuid or change it
export mypass=`date | md5sum | cut -c -15` # (optional) Set a password or let script pick one at random
#######################################################################################
#######################################################################################
###### Do not change anything below this line unless you know what you're doing. ######
#######################################################################################
#######################################################################################
#################################
# fake data #
#################################
export fake_domain="example.com"
export fake_cdn_domain="behindcdn.com"
export fakepass="desdemona99"
export fakeid="90e4903e-66a4-45f7-abda-fd5d5ed7f797"
export fake_domain_crt_path="\/etc\/ssl\/example.com\/domain.pem"
export fake_domain_key_path="\/etc\/ssl\/example.com\/domain-key.pem"
export fake_cdn_domain_crt_path="\/etc\/ssl\/behindcdn.com\/domain.pem"
export fake_cdn_domain_key_path="\/etc\/ssl\/behindcdn.com\/domain-key.pem"
Help()
{
echo "*************************************************************************"
echo "*************************************************************************"
echo "Please read the contents of this file and change all the required fields."
echo "*************************************************************************"
echo "*************************************************************************"
echo
echo
echo "Commands"
echo
echo "m Make and store the configs in result.txt."
echo "r Revert all the changes."
echo "q Print the qr codes of configs in terminal. Run this after running with -m."
echo "b Print one base64 link for all configs in terminal. Run this after running with -m."
echo
echo
echo "Usage: "
echo
echo " bash setup.sh <-command> "
echo
}
Revert()
{
git restore client.configs/* server.json nginx.conf
}
Make()
{
#################################
# main domain #
#################################
sed -i "s/$fake_domain_crt_path/$main_domain_crt/g" server.json client.configs/* nginx.conf
sed -i "s/$fake_domain_key_path/$main_domain_key/g" server.json client.configs/* nginx.conf
sed -i "s/$fake_domain/$main_domain/g" server.json client.configs/* nginx.conf
#################################
# behind cdn domain #
#################################
if [ "$cdn_domain" == "" ]; then
echo "No domain behind cdn set. Removing related fields."
sed -i "146 s/.$//" server.json
sed -i "147,152d" server.json
fi
sed -i "s/$fake_cdn_domain_crt_path/$cdn_domain_crt/g" server.json client.configs/* nginx.conf
sed -i "s/$fake_cdn_domain_key_path/$cdn_domain_key/g" server.json client.configs/* nginx.conf
sed -i "s/$fake_cdn_domain/$cdn_domain/g" server.json client.configs/* nginx.conf
#################################
# uuid/pass #
#################################
sed -i "s/$fakeid/$myid/g" server.json client.configs/* nginx.conf
sed -i "s/$fakepass/$mypass/g" server.json client.configs/* nginx.conf
#################################
# configs #
#################################
rm result.txt
touch result.txt
#grep "| Trojan-TCP |" README.md | cut -f2 -d"\`" | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakepass/$mypass/g" >> result.txt
grep "| Trojan-WS |" README.md | cut -f2 -d"\`" | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakepass/$mypass/g" >> result.txt
grep "| Trojan-gRPC |" README.md | cut -f2 -d"\`" | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakepass/$mypass/g" >> result.txt
#grep "| Trojan-H2 |" README.md | cut -f2 -d"\`" | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakepass/$mypass/g" >> result.txt
#grep "| Vless-TCP |" README.md | cut -f2 -d"\`" | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakeid/$myid/g" >> result.txt
grep "| Vless-WS |" README.md | cut -f2 -d"\`" | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakeid/$myid/g" >> result.txt
grep "| Vless-gRPC |" README.md | cut -f2 -d"\`" | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakeid/$myid/g" >> result.txt
#grep "| Vless-H2 |" README.md | cut -f2 -d"\`" | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakeid/$myid/g" >> result.txt
#grep "| VMESS-TCP |" README.md | cut -f2 -d"\`" | cut -c 9- | base64 -d | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakeid/$myid/g" | base64 -w 0 | sed "s/^/vmess:\/\//" >> result.txt
grep "| VMESS-WS |" README.md | cut -f2 -d"\`" | cut -c 9- | base64 -d | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakeid/$myid/g" | base64 -w 0 | sed "s/^/\nvmess:\/\//" >> result.txt
grep "| VMESS-gRPC |" README.md | cut -f2 -d"\`" | cut -c 9- | base64 -d | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakeid/$myid/g" | base64 -w 0 | sed "s/^/\nvmess:\/\//" >> result.txt
#grep "| VMESS-H2 |" README.md | cut -f2 -d"\`" | cut -c 9- | base64 -d | sed "s/$fake_domain/$main_domain/g" | sed "s/$fakeid/$myid/g" | base64 -w 0 | sed "s/^/\nvmess:\/\//" >> result.txt
echo >> result.txt
}
Print64()
{
cat result.txt | base64 -w 0
echo
}
Printqr()
{
while read line; do
export t=`echo $line | cut -c -2`
if [ "$t" == "vm" ]; then
echo $line | cut -c 9- | base64 -d | grep "\"ps\":" | sed -n -e 's/"ps": "//p' | sed -n -e 's/",//p' | sed -n -e 's/ *//p'
curl qrcode.show -d $line
else
echo $line | sed -n -e 's/^.*#//p'
curl qrcode.show -d $line
fi
done < result
}
while getopts "mrqb" option; do
case $option in
r)
Revert
exit;;
m)
Make
exit;;
b)
Print64
exit;;
q)
Printqr
exit;;
\?)
Help
exit;;
esac
done
Help