forked from mirrors/amnezia-wg-easy
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
1 changed files with 2 additions and 1 deletions
|
@ -99,7 +99,8 @@ module.exports = class Server {
|
|||
const { clientId } = req.params;
|
||||
const client = await WireGuard.getClient({ 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.send(config);
|
||||
}))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue