mirror of
https://github.com/WeeJeWel/wg-easy.git
synced 2024-12-23 01:29:24 +08:00
normalize config file name for download to make it work on Windows
Windows client name is derived from config file name when importing to WireGuard and it only accepts names satisfying /^[a-zA-Z0-9_=+.-]{1,32}$/.
For more information look at af60ab2299/conf/name.go (L24)
.
This commit is contained in:
parent
67b820d985
commit
722bd18999
@ -99,7 +99,8 @@ module.exports = class Server {
|
|||||||
const { clientId } = req.params;
|
const { clientId } = req.params;
|
||||||
const client = await WireGuard.getClient({ clientId });
|
const client = await WireGuard.getClient({ clientId });
|
||||||
const config = await WireGuard.getClientConfiguration({ clientId });
|
const config = await WireGuard.getClientConfiguration({ clientId });
|
||||||
res.header('Content-Disposition', `attachment; filename="${client.name}.conf"`);
|
const configName = client.name.replace(/[^a-zA-Z0-9_=+.-]/g, '-').replace(/(-{2,}|-$)/g, '-').replace(/-$/, '').substring(0, 32);
|
||||||
|
res.header('Content-Disposition', `attachment; filename="${configName}.conf"`);
|
||||||
res.header('Content-Type', 'text/plain');
|
res.header('Content-Type', 'text/plain');
|
||||||
res.send(config);
|
res.send(config);
|
||||||
}))
|
}))
|
||||||
|
Loading…
Reference in New Issue
Block a user