Skip to content

Commit e28432e

Browse files
committed
feat: enhance address and host handling in FormatHostsService
- Added functionality to replace '*' in addresses and hosts with a generated ID using nanoid. - Ensured that both address and host can now dynamically incorporate unique identifiers when needed.
1 parent 02e04d9 commit e28432e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/modules/subscription-template/generators/format-hosts.service.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ export class FormatHostsService {
131131
if (address.includes(',')) {
132132
const addressList = address.split(',');
133133
address = addressList[Math.floor(Math.random() * addressList.length)].trim();
134+
} else if (address.includes('*')) {
135+
address = address.replace('*', this.nanoid()).trim();
134136
}
135137

136138
const port = inputHost.port;
@@ -296,7 +298,11 @@ export class FormatHostsService {
296298
const protocol = inbound.protocol;
297299
const path = inputHost.path || pathFromConfig || '';
298300

299-
const host = inputHost.host || hostFromConfig || '';
301+
let host = inputHost.host || hostFromConfig || '';
302+
303+
if (host.includes('*')) {
304+
host = host.replace('*', this.nanoid()).trim();
305+
}
300306

301307
const tls = tlsFromConfig;
302308

0 commit comments

Comments
 (0)