Skip to content

Commit

Permalink
feat(generator/client): support parse array in get_outbound
Browse files Browse the repository at this point in the history
  • Loading branch information
1715173329 authored Nov 15, 2023
1 parent 533c68e commit e2adb72
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions root/etc/homeproxy/scripts/generate_client.uc
Original file line number Diff line number Diff line change
Expand Up @@ -243,28 +243,24 @@ function get_outbound(cfg) {
if (isEmpty(cfg))
return null;

if (cfg in ['direct-out', 'block-out'])
return cfg;
else {
const node = uci.get(uciconfig, cfg, 'node');
if (isEmpty(node))
die(sprintf("%s's node is missing, please check your configuration.", cfg));
else
return 'cfg-' + node + '-out';
if (type(cfg) === 'array') {
let outbounds = [];
for (let i in cfg)
push(outbounds, get_outbound(i))
return outbounds;
} else {
if (cfg in ['direct-out', 'block-out']) {
return cfg;
} else {
const node = uci.get(uciconfig, cfg, 'node');
if (isEmpty(node))
die(sprintf("%s's node is missing, please check your configuration.", cfg));
else
return 'cfg-' + node + '-out';
}
}
}

function parse_outbound(rawobs) {
if (type(rawobs) !== 'array' || isEmpty(rawobs))
return null;

let obs = [];
for (let i in rawobs)
push(obs, get_outbound(i));

return obs;
}

function get_resolver(cfg) {
if (isEmpty(cfg))
return null;
Expand Down Expand Up @@ -388,7 +384,7 @@ if (!isEmpty(main_node)) {
process_path: cfg.process_path,
user: cfg.user,
invert: (cfg.invert === '1'),
outbound: parse_outbound(cfg.outbound),
outbound: get_outbound(cfg.outbound),
server: get_resolver(cfg.server),
disable_cache: (cfg.dns_disable_cache === '1')
});
Expand Down

0 comments on commit e2adb72

Please sign in to comment.