Skip to content

Commit

Permalink
Wireguard - kernel Tun
Browse files Browse the repository at this point in the history
  • Loading branch information
MHSanaei committed Oct 16, 2024
1 parent dff2496 commit ac7901a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 3 deletions.
6 changes: 5 additions & 1 deletion web/assets/js/model/outbound.js
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,8 @@ Outbound.WireguardSettings = class extends CommonClass {
domainStrategy = '',
reserved = '',
peers = [new Outbound.WireguardSettings.Peer()],
kernelMode = false
kernelMode = false,
kernelTun = false
) {
super();
this.mtu = mtu;
Expand All @@ -1190,6 +1191,7 @@ Outbound.WireguardSettings = class extends CommonClass {
this.reserved = Array.isArray(reserved) ? reserved.join(',') : reserved;
this.peers = peers;
this.kernelMode = kernelMode;
this.kernelTun = kernelTun;
}

addPeer() {
Expand All @@ -1210,6 +1212,7 @@ Outbound.WireguardSettings = class extends CommonClass {
json.reserved,
json.peers.map(peer => Outbound.WireguardSettings.Peer.fromJson(peer)),
json.kernelMode,
json.kernelTun,
);
}

Expand All @@ -1223,6 +1226,7 @@ Outbound.WireguardSettings = class extends CommonClass {
reserved: this.reserved ? this.reserved.split(",").map(Number) : undefined,
peers: Outbound.WireguardSettings.Peer.toJsonArray(this.peers),
kernelMode: this.kernelMode,
kernelTun: this.kernelTun,
};
}
};
Expand Down
12 changes: 11 additions & 1 deletion web/assets/js/model/xray.js
Original file line number Diff line number Diff line change
Expand Up @@ -2644,13 +2644,21 @@ Inbound.HttpSettings.HttpAccount = class extends XrayCommonClass {
};

Inbound.WireguardSettings = class extends XrayCommonClass {
constructor(protocol, mtu = 1420, secretKey = Wireguard.generateKeypair().privateKey, peers = [new Inbound.WireguardSettings.Peer()], kernelMode = false) {
constructor(
protocol,
mtu = 1420,
secretKey = Wireguard.generateKeypair().privateKey,
peers = [new Inbound.WireguardSettings.Peer()],
kernelMode = false,
kernelTun = false,
) {
super(protocol);
this.mtu = mtu;
this.secretKey = secretKey;
this.pubKey = secretKey.length > 0 ? Wireguard.generateKeypair(secretKey).publicKey : '';
this.peers = peers;
this.kernelMode = kernelMode;
this.kernelTun = kernelTun;
}

addPeer() {
Expand All @@ -2668,6 +2676,7 @@ Inbound.WireguardSettings = class extends XrayCommonClass {
json.secretKey,
json.peers.map(peer => Inbound.WireguardSettings.Peer.fromJson(peer)),
json.kernelMode,
json.kernelTun,
);
}

Expand All @@ -2677,6 +2686,7 @@ Inbound.WireguardSettings = class extends XrayCommonClass {
secretKey: this.secretKey,
peers: Inbound.WireguardSettings.Peer.toJsonArray(this.peers),
kernelMode: this.kernelMode,
kernelTun: this.kernelTun,
};
}
};
Expand Down
3 changes: 3 additions & 0 deletions web/html/xui/form/outbound.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
<a-form-item label='Kernel Mode'>
<a-switch v-model="outbound.settings.kernelMode"></a-switch>
</a-form-item>
<a-form-item label='Kernel Tun'>
<a-switch v-model="outbound.settings.kernelTun"></a-switch>
</a-form-item>
<a-form-item>
<template slot="label">
<a-tooltip>
Expand Down
3 changes: 3 additions & 0 deletions web/html/xui/form/protocol/wireguard.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<a-form-item label='Kernel Mode'>
<a-switch v-model="inbound.settings.kernelMode"></a-switch>
</a-form-item>
<a-form-item label='Kernel Tun'>
<a-switch v-model="inbound.settings.kernelTun"></a-switch>
</a-form-item>
<a-form-item label="Peers">
<a-button icon="plus" type="primary" size="small" @click="inbound.settings.addPeer()"></a-button>
</a-form-item>
Expand Down
4 changes: 4 additions & 0 deletions web/html/xui/inbound_info_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@
<td>Kernel Mode</td>
<td>[[ inbound.settings.kernelMode ]]</td>
</tr>
<tr>
<td>Kernel Tun</td>
<td>[[ inbound.settings.kernelTun ]]</td>
</tr>
<template v-for="(peer, index) in inbound.settings.peers">
<tr>
<td colspan="2">
Expand Down
3 changes: 2 additions & 1 deletion web/html/xui/warp_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@
publicKey: peer.public_key,
endpoint: peer.endpoint.host,
}],
kernelMode: false
kernelMode: false,
kernelTun: false,
}
});
}
Expand Down

0 comments on commit ac7901a

Please sign in to comment.