mirror of
https://github.com/wg-easy/wg-easy.git
synced 2025-10-07 00:24:04 +08:00
add ui port to template
This commit is contained in:
@@ -88,7 +88,7 @@ In the Admin Panel of your WireGuard server, go to the `Hooks` tab and add the f
|
|||||||
1. PostUp
|
1. PostUp
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
apk add nftables; nft add table inet wg_table; nft add chain inet wg_table postrouting { type nat hook postrouting priority 100 \; }; nft add rule inet wg_table postrouting ip saddr {{ipv4Cidr}} oifname {{device}} masquerade; nft add rule inet wg_table postrouting ip6 saddr {{ipv6Cidr}} oifname {{device}} masquerade; nft add chain inet wg_table input { type filter hook input priority 0 \; policy drop \; }; nft add rule inet wg_table input udp dport {{port}} accept; nft add chain inet wg_table forward { type filter hook forward priority 0 \; policy drop \; }; nft add rule inet wg_table forward iifname "wg0" accept; nft add rule inet wg_table forward oifname "wg0" accept;
|
apk add nftables; nft add table inet wg_table; nft add chain inet wg_table postrouting { type nat hook postrouting priority 100 \; }; nft add rule inet wg_table postrouting ip saddr {{ipv4Cidr}} oifname {{device}} masquerade; nft add rule inet wg_table postrouting ip6 saddr {{ipv6Cidr}} oifname {{device}} masquerade; nft add chain inet wg_table input { type filter hook input priority 0 \; policy drop \; }; nft add rule inet wg_table input udp dport {{port}} accept; nft add rule inet wg_table input tcp dport {{uiPort}} accept; nft add chain inet wg_table forward { type filter hook forward priority 0 \; policy drop \; }; nft add rule inet wg_table forward iifname "wg0" accept; nft add rule inet wg_table forward oifname "wg0" accept;
|
||||||
```
|
```
|
||||||
|
|
||||||
2. PostDown
|
2. PostDown
|
||||||
|
@@ -15,4 +15,16 @@ export const OLD_ENV = {
|
|||||||
export const WG_ENV = {
|
export const WG_ENV = {
|
||||||
/** UI is hosted on HTTP instead of HTTPS */
|
/** UI is hosted on HTTP instead of HTTPS */
|
||||||
INSECURE: process.env.INSECURE === 'true',
|
INSECURE: process.env.INSECURE === 'true',
|
||||||
|
/** Port the UI is listening on */
|
||||||
|
PORT: assertEnv('PORT'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function assertEnv<T extends string>(env: T) {
|
||||||
|
const val = process.env[env];
|
||||||
|
|
||||||
|
if (!val) {
|
||||||
|
throw new Error(`Missing environment variable: ${env}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
@@ -15,6 +15,7 @@ export function template(templ: string, values: Record<string, string>) {
|
|||||||
* - ipv6Cidr: IPv6 CIDR
|
* - ipv6Cidr: IPv6 CIDR
|
||||||
* - device: Network device
|
* - device: Network device
|
||||||
* - port: Port number
|
* - port: Port number
|
||||||
|
* - uiPort: UI port number
|
||||||
*/
|
*/
|
||||||
export function iptablesTemplate(templ: string, wgInterface: InterfaceType) {
|
export function iptablesTemplate(templ: string, wgInterface: InterfaceType) {
|
||||||
return template(templ, {
|
return template(templ, {
|
||||||
@@ -22,5 +23,6 @@ export function iptablesTemplate(templ: string, wgInterface: InterfaceType) {
|
|||||||
ipv6Cidr: wgInterface.ipv6Cidr,
|
ipv6Cidr: wgInterface.ipv6Cidr,
|
||||||
device: wgInterface.device,
|
device: wgInterface.device,
|
||||||
port: wgInterface.port.toString(),
|
port: wgInterface.port.toString(),
|
||||||
|
uiPort: WG_ENV.PORT,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user