Skip to content

Commit

Permalink
added: grpc & json url
Browse files Browse the repository at this point in the history
  • Loading branch information
ircfspace committed Feb 12, 2024
1 parent 7273a69 commit d7fffd4
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 42 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
### مناسب برای :
* VLESS [Websocket]
* VMESS [Websocket]
* VLESS [GRPC]
* VMESS [GRPC]
---

### لینکهای کاربردی در رابطه با فرگمنت :
Expand Down
4 changes: 2 additions & 2 deletions assets/css/lang.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ html[lang="en"] footer {
}

html[lang="en"] .fetchIps button:first-child {
border-radius: 5px 0 0 5px;
border-radius: 0 5px 5px 0;
}
html[lang="en"] .fetchIps button:last-child {
border-radius: 0 5px 5px 0;
border-radius: 5px 0 0 5px;
border-right: 1px solid #adadad;
border-left: inherit;
}
41 changes: 35 additions & 6 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ img[alt="loader"] {
width: 60% !important;
}
.fetchIps .input-group-btn {
float: right;
width: 40% !important;
float: left;
width: 33px !important;
}
.fetchIps .input-group-btn button {
float: right;
Expand All @@ -258,14 +258,18 @@ img[alt="loader"] {
width: 50%;
}
.fetchIps button:first-child {
width: calc(100% - 130px);
width: calc(100% - 34px);
border-radius: 0 5px 5px 0;
}
.fetchIps button:last-child {
width: 130px;
border-radius: 5px 0 0 5px;
border-right: transparent;
}
.fetchIps .open>.dropdown-menu {
left: 0;
right: inherit;
}

.minWidth {
float: right;
Expand Down Expand Up @@ -309,15 +313,19 @@ img[alt="loader"] {
}
.xsWidth.withSmallCenter select:first-child,
.xsWidth.withSmallCenter input:first-child {
width: 150px;
width: 95px;
}
.xsWidth.withSmallCenter select:nth-child(2),
.xsWidth.withSmallCenter input:nth-child(2) {
width: calc(100% - 250px);
width: 85px;
}
.xsWidth.withSmallCenter select:nth-child(3),
.xsWidth.withSmallCenter input:nth-child(3) {
width: calc(100% - 260px);
}
.xsWidth.withSmallCenter select:last-child,
.xsWidth.withSmallCenter input:last-child {
width: 100px;
width: 80px;
}

p {
Expand Down Expand Up @@ -447,4 +455,25 @@ footer p {
margin-top: 10px;
height: 70px;
}
}

@media(max-width:370px) {
.xsWidth.withSmallCenter select:first-child,
.xsWidth.withSmallCenter input:first-child {
width: 50%;
}
.xsWidth.withSmallCenter select:nth-child(2),
.xsWidth.withSmallCenter input:nth-child(2) {
width: 50%;
}
.xsWidth.withSmallCenter select:nth-child(3),
.xsWidth.withSmallCenter input:nth-child(3) {
width: 50%;
margin-top: -5px;
}
.xsWidth.withSmallCenter select:last-child,
.xsWidth.withSmallCenter input:last-child {
width: 50%;
margin-top: -5px;
}
}
2 changes: 1 addition & 1 deletion assets/js/lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function setLanguagePreference(lang) {
}

async function fetchLanguageData(lang) {
const response = await fetch("assets/lang/"+lang+".json?v1.3");
const response = await fetch("assets/lang/"+lang+".json?v1.3.1");
return response.json();
}

Expand Down
101 changes: 86 additions & 15 deletions assets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,21 @@ $(document).on('keyup', '#defConfig', function(e) {
return false;
}
$('#protocol option').removeAttr('selected');
$('#protocol option[value="'+protocol+'"]').attr('selected', 'selected');
$('#protocol option[value="'+protocol+'"]').attr('selected', 'selected').prop('selected', true);
let defConfig = parser(protocol, config);
if ( protocol === 'vmess' && ["grpc", "reality", "tcp", "quic"].includes(defConfig.tls) ) {
alert('نوع کانفیگ باید وب‌سوکت باشد!');
//console.log(defConfig)
if ( protocol === 'vmess' && ["reality", "tcp"].includes(defConfig.tls) ) {
alert('نوع کانفیگ باید WS/GRPC باشد!');
resetForm();
return false;
}
if ( protocol === 'vless' && ["grpc", "reality", "tcp", "quic"].includes(defConfig.security) ) {
alert('نوع کانفیگ باید وب‌سوکت باشد!');
if ( protocol === 'vless' && ["reality", "tcp"].includes(defConfig.security) ) {
alert('نوع کانفیگ باید WS/GRPC باشد!');
resetForm();
return false;
}
$('#stream option').removeAttr('selected');
$('#stream option[value="'+ (defConfig.type === 'ws' ? 'ws' : 'grpc') +'"]').attr('selected', 'selected').prop('selected', true).trigger('change');
let port = String(getAddress(config)[1]).replace('/', '');
$('#port').val(port);
$('#sni').val(defConfig.host);
Expand All @@ -163,9 +166,16 @@ $(document).on('keyup', '#defConfig', function(e) {
}
if ( protocol === 'vmess' ) {
$('#cleanIp').val(defConfig.add);
$('#grpcMode option').removeAttr('selected');
$('#grpcMode option[value="'+ (defConfig.type
=== 'multi' ? 'multi' : 'gun') +'"]').attr('selected', 'selected').prop('selected', true);
$('#serviceName').val(defConfig.path);
}
else {
$('#cleanIp').val(defConfig.address);
$('#grpcMode option').removeAttr('selected');
$('#grpcMode option[value="'+ (defConfig.mode === 'multi' ? 'multi' : 'gun') +'"]').attr('selected', 'selected').prop('selected', true);
$('#serviceName').val(defConfig.serviceName);
}
if ( typeof defConfig.allowInsecure !== "undefined" ) {
if ( protocol === 'vmess' ) {
Expand Down Expand Up @@ -203,9 +213,13 @@ $(document).on('keyup', '#defConfig', function(e) {
}
}
}
let path = setPath(defConfig.path);
let stream = $('#stream').val();
if ( stream !== 'ws' ) {
$('#early').prop('checked', false);
}
let path = setPath(defConfig.type === 'ws' ? defConfig.path : "");
let early = $('#early').is(':checked');
if ( early ) {
if ( early && stream === 'ws' ) {
path = path+'?ed=2048';
}
$('#uuid').val(getHashId(defConfig.id));
Expand All @@ -229,10 +243,25 @@ function setPath(string) {
return string;
}

$(document).on('change', '#stream', function(e) {
let stream = $('#stream').val();
if ( stream !== 'ws' ) {
$('#grpcOnly').removeClass('none');
$('#path').prop('disabled', true).val('');
$('#early').prop('disabled', true);
}
else {
$('#grpcOnly').addClass('none');
$('#path').prop('disabled', false).val('');;
$('#early').prop('disabled', false);
}
});

$(document).on('click', '#early', function(e) {
let early = $('#early').is(':checked');
let path = setPath($('#path').val());
if ( early ) {
let stream = $('#stream').val();
if ( early && stream === 'ws' ) {
path = path+'?ed=2048';
}
$('#path').val(path);
Expand Down Expand Up @@ -285,6 +314,7 @@ function cleanUrl(url) {
function generateJson() {
return new Promise((resolve, reject) => {
let protocol = $('#protocol').val();
let stream = $('#stream').val();
//let network = $('#network').val();
let uuid = $('#uuid').val();
let sni = cleanUrl($('#sni').val());
Expand All @@ -298,6 +328,8 @@ function generateJson() {
let length = $('#length').val();
let interval = $('#interval').val();
//let early = $('#early').is(':checked');
let grpcMode = $('#grpcMode').val();
let serviceName = $('#serviceName').val();
let cleanIp = $('#cleanIp').val();
if ( cleanIp === '' ) {
cleanIp = 'zula.ir';
Expand All @@ -307,23 +339,31 @@ function generateJson() {
alert('فرم را تکمیل نمایید.');
return false;
}
fetch('fragment.json?v1.5')
fetch('fragment.json?v1.6')
.then(response => response.json())
.then(data => {
data.outbounds[0].protocol = protocol;
if ( mux ) {
data.outbounds[0].mux.enabled = true;
data.outbounds[0].mux.concurrency = Number(concurrency);
data.outbounds[0].mux.xudpConcurrency = Number(concurrency);
}
else {
delete data.outbounds[0].mux;
}
data.outbounds[0].streamSettings.network = stream;
if ( stream === "grpc" ) {
delete data.outbounds[0].streamSettings.wsSettings;
data.outbounds[0].streamSettings.grpcSettings.multiMode = (grpcMode === 'multi' ? true : false);
data.outbounds[0].streamSettings.grpcSettings.serviceName = serviceName;
}
else {
data.outbounds[0].mux.enabled = false;
data.outbounds[0].mux.concurrency = Number(-1);
delete data.outbounds[0].streamSettings.grpcSettings;
data.outbounds[0].streamSettings.wsSettings.headers.Host = sni;
data.outbounds[0].streamSettings.wsSettings.path = path;
}
data.outbounds[0].streamSettings.network = "ws";
data.outbounds[0].streamSettings.tlsSettings.allowInsecure = (insecure ? true : false);
data.outbounds[0].streamSettings.tlsSettings.serverName = sni;
data.outbounds[0].streamSettings.wsSettings.headers.Host = sni;
data.outbounds[0].streamSettings.wsSettings.path = path;
data.outbounds[0].settings.vnext[0].port = Number(port);
data.outbounds[0].settings.vnext[0].users[0].id = uuid;
data.outbounds[0].settings.vnext[0].address = cleanIp;
Expand Down Expand Up @@ -368,7 +408,7 @@ $(document).on('click', '#getFile', function(e) {
})
.catch(error => {
// Handle errors here
console.error(error);
console.log(error)
});
});

Expand All @@ -389,6 +429,37 @@ $(document).on('click', '#copyCode', function (e) {
});
});

let vercelUrl = 'https://convertor-ircf.vercel.app/json/sub/';

$(document).on('click', '#jsonUrl', function (e) {
e.preventDefault();
generateJson()
.then(data => {
data = JSON.stringify(data, null, 2);
window.open(vercelUrl+btoa(data));
})
.catch(error => {
console.error(error);
});
});

$(document).on('click', '#copyUrl', function (e) {
e.preventDefault();
generateJson()
.then(data => {
data = JSON.stringify(data, null, 2);
document.getElementById("jsonOutput").value = vercelUrl+btoa(data);
const input = document.getElementById('jsonOutput');
input.select();
input.setSelectionRange(0, 99999);
document.execCommand('copy');
alert('آدرس در کلیپ‌بورد کپی شد.');
})
.catch(error => {
console.error(error);
});
});

window.addEventListener('load', function() {
$('[data-toggle="tooltip"]').tooltip({
placement: "top",
Expand Down
7 changes: 5 additions & 2 deletions assets/lang/cn.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"welcome_message": "使用片段工具,您可以恢复您的失效域名!",
"config_input": "提供带有WS类型的VLESS/VMESS配置",
"config_input": "提供一个使用WS/GRPC类型的VLESS/VMESS配置:",
"config_input_label": "您的配置",
"config_input_submit": "检查",
"config_form_ortext": "",
Expand All @@ -12,8 +12,11 @@
"config_form_cleanip_tooltip": "输入一个IPv4/IPv6地址或托管在CDN Cloudflare上的其中一个网站的地址",
"config_form_sni": "SNI",
"config_form_path": "路径",
"config_form_submit": "创建JSON文件",
"config_form_serviceName": "服务名称",
"config_form_submit": "下载 JSON",
"config_form_copy": "复制代码",
"config_form_copyurl": "复制网址",
"config_form_jsonurl": "查看 JSON 代码",
"config_switch_tls": "TLS",
"config_switch_tls_tooltip": "切换TLS片段和TCP段之间的能力",
"config_switch_insecure": "不安全",
Expand Down
7 changes: 5 additions & 2 deletions assets/lang/en.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"welcome_message": "Using the Fragment tool, you can revive your dead domains!",
"config_input": "Provide a VLESS/VMESS configuration with WS type:",
"config_input": "Provide a VLESS/VMESS configuration with WS/GRPC type:",
"config_input_label": "Your Config",
"config_input_submit": "Check",
"config_form_ortext": "OR",
Expand All @@ -12,8 +12,11 @@
"config_form_cleanip_tooltip": "Enter an IPv4/IPv6 or the address of one of the websites hosted on CDN Cloudflare",
"config_form_sni": "SNI",
"config_form_path": "PATH",
"config_form_submit": "Create a JSON file",
"config_form_serviceName": "ServiceName",
"config_form_submit": "Download JSON",
"config_form_copy": "Copy Code",
"config_form_copyurl": "Copy URL",
"config_form_jsonurl": "View JSON code",
"config_switch_tls": "TLS",
"config_switch_tls_tooltip": "the ability to switch between TLS Fragment and TCP Segment",
"config_switch_insecure": "Insecure",
Expand Down
7 changes: 5 additions & 2 deletions assets/lang/fa.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"welcome_message": "توسط ابزار فرگمنت می‌تونین دامنه‌های مرده‌تون رو مجدد زنده کنید!",
"config_input": "یک کانفیگ VLESS/VMESS از نوع webSocket وارد کنین:",
"config_input": "یک کانفیگ VLESS/VMESS از نوع WS/GRPC وارد کنین:",
"config_input_label": "Your Config",
"config_input_submit": "بررسی",
"config_form_ortext": "یا",
Expand All @@ -12,8 +12,11 @@
"config_form_cleanip_tooltip": "یک IPv4/IPv6 وارد کرده یا آدرس یکی\u200Cاز سایت\u200Cهای پشت کلودفلر را وارد کنید (مقدار پیشفرض zula.ir است)",
"config_form_sni": "SNI",
"config_form_path": "PATH",
"config_form_submit": "ایجاد فایل JSON",
"config_form_serviceName": "ServiceName",
"config_form_submit": "دانلود JSON",
"config_form_copy": "کپی کد",
"config_form_copyurl": "کپی آدرس",
"config_form_jsonurl": "مشاهده کد JSON",
"config_switch_tls": "TLS",
"config_switch_tls_tooltip": "امکان سوییچ بین حالت TLS Fragment و TCP Segment",
"config_switch_insecure": "Insecure",
Expand Down
7 changes: 5 additions & 2 deletions assets/lang/ru.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"welcome_message": "С помощью инструмента Fragment вы можете оживить свои мертвые домены!",
"config_input": "Укажите конфигурацию VLESS/VMESS с типом WS:",
"config_input": "Укажите конфигурацию VLESS/VMESS с типом WS/GRPC:",
"config_input_label": "Ваша конфигурация",
"config_input_submit": "Проверить",
"config_form_ortext": "ИЛИ",
Expand All @@ -12,8 +12,11 @@
"config_form_cleanip_tooltip": "Введите IPv4/IPv6 или адрес одного из веб-сайтов, размещенных на CDN Cloudflare",
"config_form_sni": "SNI",
"config_form_path": "ПУТЬ",
"config_form_submit": "Создать файл JSON",
"config_form_serviceName": "ИмяСлужбы",
"config_form_submit": "Скачать JSON",
"config_form_copy": "Копировать код",
"config_form_copyurl": "Скопируйте URL",
"config_form_jsonurl": "Просмотреть JSON код",
"config_switch_tls": "TLS",
"config_switch_tls_tooltip": "Возможность переключения между фрагментацией TLS и сегментацией TCP",
"config_switch_insecure": "Небезопасный",
Expand Down
Loading

0 comments on commit d7fffd4

Please sign in to comment.