Skip to content

Commit

Permalink
feat(scripts/subscribe): improve the logic of addding nodes
Browse files Browse the repository at this point in the history
Signed-off-by: Tianling Shen <[email protected]>
  • Loading branch information
1715173329 committed Jun 25, 2024
1 parent 15a4932 commit d1f9572
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions root/etc/homeproxy/scripts/update_subscriptions.uc
Original file line number Diff line number Diff line change
Expand Up @@ -457,14 +457,11 @@ function main() {
node_cache[groupHash] = {};

const res = wGET(url);
if (!res) {
if (isEmpty(res)) {
log(sprintf('Failed to fetch resources from %s.', url));
continue;
}

push(node_result, []);
const subindex = length(node_result) - 1;

let nodes;
try {
nodes = json(res).servers || json(res);
Expand Down Expand Up @@ -502,15 +499,19 @@ function main() {
config.packet_encoding = packet_encoding;

config.grouphash = groupHash;
push(node_result[subindex], config);
push(node_result, []);
push(node_result[length(node_result)-1], config);
node_cache[groupHash][confHash] = config;
node_cache[groupHash][nameHash] = config;

count++;
}
}

log(sprintf('Successfully fetched %s nodes of total %s from %s.', count, length(nodes), url));
if (count == 0)
log(sprintf('No valid node found in %s.', url));
else
log(sprintf('Successfully fetched %s nodes of total %s from %s.', count, length(nodes), url));
}

if (isEmpty(node_result)) {
Expand Down

0 comments on commit d1f9572

Please sign in to comment.