Add wireguard to xray outbound (#763)

* Add wireguard to xray outbound

* [Fix little mistake] Add wireguard to xray outbound

* [Requested changes] Add wireguard to xray outbound

* Remove DNS field and add keepAlive field
This commit is contained in:
Sudo Space
2024-01-08 19:42:05 +03:30
committed by GitHub
parent 8b64976eef
commit 3a174144c4
7 changed files with 87 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ const Protocols = {
Shadowsocks: "shadowsocks",
Socks: "socks",
HTTP: "http",
Wireguard: "wireguard"
};
const SSMethods = {
@@ -625,6 +626,7 @@ Outbound.Settings = class extends CommonClass {
case Protocols.Shadowsocks: return new Outbound.ShadowsocksSettings();
case Protocols.Socks: return new Outbound.SocksSettings();
case Protocols.HTTP: return new Outbound.HttpSettings();
case Protocols.Wireguard: return new Outbound.WireguardSettings();
default: return null;
}
}
@@ -640,6 +642,7 @@ Outbound.Settings = class extends CommonClass {
case Protocols.Shadowsocks: return Outbound.ShadowsocksSettings.fromJson(json);
case Protocols.Socks: return Outbound.SocksSettings.fromJson(json);
case Protocols.HTTP: return Outbound.HttpSettings.fromJson(json);
case Protocols.Wireguard: return Outbound.WireguardSettings.fromJson(json);
default: return null;
}
}
@@ -897,4 +900,43 @@ Outbound.HttpSettings = class extends CommonClass {
}],
};
}
};
Outbound.WireguardSettings = class extends CommonClass{
constructor(mtu=1420, secretKey='', address='', publicKey='', allowedIPs='0.0.0.0/0,::/0', endpoint='', keepAlive=0) {
super();
this.mtu = mtu,
this.secretKey = secretKey,
this.address = address,
this.publicKey = publicKey,
this.allowedIPs = allowedIPs,
this.endpoint = endpoint,
this.keepAlive = keepAlive
}
static fromJson(json={}){
const peers = json.peers
return new Outbound.WireguardSettings(
json.mtu,
json.secretKey,
json.address.toString(),
peers[0].publicKey,
peers[0].allowedIPs.toString(),
peers[0].endpoint,
peers[0].keepAlive
);
}
toJson() {
return {
mtu: this.mtu,
secretKey: this.secretKey,
address: this.address ? this.address.split(",") : [],
peers: [{
publicKey:this.publicKey,
allowedIPs: this.allowedIPs ? this.allowedIPs.split(",") : [],
keepAlive: this.keepAlive,
endpoint: this.endpoint
}]
};
}
};

View File

@@ -66,6 +66,31 @@
</a-form-item>
</template>
<!-- wireguard settings -->
<template v-if="outbound.protocol === Protocols.Wireguard">
<a-form-item label='MTU'>
<a-input-number v-model.number="outbound.settings.mtu"></a-input-number>
</a-form-item>
<a-form-item label='{{ i18n "pages.xray.outbound.address" }}'>
<a-input v-model.trim="outbound.settings.address"></a-input>
</a-form-item>
<a-form-item label='{{ i18n "pages.xray.outbound.secretKey" }}'>
<a-input v-model.trim="outbound.settings.secretKey"></a-input>
</a-form-item>
<a-form-item label='{{ i18n "pages.xray.outbound.publicKey" }}'>
<a-input v-model.trim="outbound.settings.publicKey"></a-input>
</a-form-item>
<a-form-item label='{{ i18n "pages.xray.outbound.allowedIPs" }}'>
<a-input v-model.trim="outbound.settings.allowedIPs"></a-input>
</a-form-item>
<a-form-item label='keepAlive'>
<a-input-number v-model.number="outbound.settings.keepAlive" :min="0"></a-input>
</a-form-item>
<a-form-item label='{{ i18n "pages.xray.outbound.endpoint" }}'>
<a-input v-model.trim="outbound.settings.endpoint"></a-input>
</a-form-item>
</template>
<!-- Address + Port -->
<template v-if="outbound.hasAddressPort()">
<a-form-item label='{{ i18n "pages.inbounds.address" }}'>

View File

@@ -388,6 +388,10 @@
"bridge" = "Bridge"
"portal" = "Portal"
"intercon" = "Interconnection"
"secretKey" = "Secret Key"
"publicKey" = "Public Key"
"allowedIPs" = "Allowed IPs"
"endpoint" = "End Point"
[tgbot]
"noResult" = "❗ No result!"

View File

@@ -387,6 +387,10 @@
"bridge" = "پل"
"portal" = "پرتال"
"intercon" = "اتصال میانی"
"secretKey" = "کلید شخصی"
"publicKey" = "کلید عمومی"
"allowedIPs" = "های مجاز IP"
"endpoint" = "نقطه پایانی"
[tgbot]
"noResult" = "❗ نتیجه‌ای یافت نشد!"

View File

@@ -388,6 +388,10 @@
"bridge" = "Мост"
"portal" = "Портал"
"intercon" = "Соединение"
"secretKey" = "Секретный ключ"
"publicKey" = "Открытый ключ"
"allowedIPs" = "Разрешенные IP-адреса"
"endpoint" = "Конечная точка"
[tgbot]
"noResult" = "❗ Нет результатов!"

View File

@@ -388,6 +388,10 @@
"bridge" = "Liên kết"
"portal" = "Cổng thông tin"
"intercon" = "Kết nối"
"secretKey" = "Chìa khoá bí mật"
"publicKey" = "Khóa công khai"
"allowedIPs" = "IP được phép"
"endpoint" = "Điểm cuối"
[tgbot]
"noResult" = "❗ Không có kết quả!"

View File

@@ -388,6 +388,10 @@
"bridge" = "桥"
"portal" = "门户"
"intercon" = "互连"
"secretKey" = "密钥"
"publicKey" = "公钥"
"allowedIPs" = "允许的 IP"
"endpoint" = "终点"
[tgbot]
"noResult" = "❗ 没有结果!"