Skip to content

Commit

Permalink
feat: add inline providers type
Browse files Browse the repository at this point in the history
  • Loading branch information
muink committed Dec 26, 2024
1 parent 065e4da commit eb3023b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
18 changes: 18 additions & 0 deletions luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,7 @@ return view.extend({
so = ss.taboption('field_general', form.ListValue, 'type', _('Type'));
so.value('file', _('Local'));
so.value('http', _('Remote'));
so.value('inline', _('Inline'));
so.default = 'http';

so = ss.option(form.DummyValue, '_value', _('Value'));
Expand All @@ -848,6 +849,8 @@ return view.extend({
return uci.get(data[0], section_id, '.name');
case 'http':
return uci.get(data[0], section_id, 'url');
case 'inline':
return uci.get(data[0], section_id, '.name');
default:
return null;
}
Expand Down Expand Up @@ -875,6 +878,21 @@ return view.extend({
so.depends('type', 'file');
so.modalonly = true;

so = ss.taboption('field_general', form.TextValue, 'payload', 'payload:',
_('Please type <a target="_blank" href="%s" rel="noreferrer noopener">%s</a>.')
.format('https://wiki.metacubex.one/config/proxy-providers/content/', _('Payload')));
so.renderWidget = function(/* ... */) {
var frameEl = form.TextValue.prototype.renderWidget.apply(this, arguments);

frameEl.querySelector('textarea').style.fontFamily = hm.monospacefonts.join(',');

return frameEl;
}
so.placeholder = '- name: "ss1"\n type: ss\n server: server\n port: 443\n cipher: chacha20-ietf-poly1305\n password: "password"\n# ' + _('Content will not be verified, Please make sure you enter it correctly.');
so.rmempty = false;
so.depends('type', 'inline');
so.modalonly = true;

so = ss.taboption('field_general', form.Value, 'url', _('Provider URL'));
so.validate = L.bind(hm.validateUrl, so);
so.rmempty = false;
Expand Down
6 changes: 5 additions & 1 deletion luci-app-fchomo/root/etc/fchomo/scripts/generate_client.uc
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,11 @@ uci.foreach(uciconf, uciprov, (cfg) => {
/* General fields */
config["proxy-providers"][cfg['.name']] = {
type: cfg.type,
path: HM_DIR + '/provider/' + cfg['.name'],
...(cfg.payload ? {
payload: trim(cfg.payload)
} : {
path: HM_DIR + '/provider/' + cfg['.name']
}),
url: cfg.url,
"size-limit": bytesizeToByte(cfg.size_limit) || null,
interval: (cfg.type === 'http') ? durationToSecond(cfg.interval) || 86400 : null,
Expand Down
4 changes: 3 additions & 1 deletion luci-app-fchomo/root/etc/init.d/fchomo
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ start_service() {
| .sniffer["skip-domain"][] style="double"
| with(.dns["nameserver-policy"] | keys; .. style="double")
| .dns["fallback-filter"].domain[] style="double"
| with(.["rule-providers"][] | select(.payload); .payload style="literal")' | sed -E 's,^(\s*payload:) \|-,\1,' \
| with(.["proxy-providers"][] | select(.payload); .payload style="literal")
| with(.["rule-providers"][] | select(.payload); .payload style="literal")' \
| sed -E 's,^(\s*payload:) \|-,\1,' \
> "$RUN_DIR/mihomo-c.yaml"
yq eval-all -i '. as $item ireduce ({}; . * $item )' "$RUN_DIR/mihomo-c.yaml" "$TEMPS_DIR/"*.yaml

Expand Down

0 comments on commit eb3023b

Please sign in to comment.