Skip to content

Commit

Permalink
feat(client): dns.rules: Add options
Browse files Browse the repository at this point in the history
Options:
  query_type
  ip_version
  rewrite_ttl
  • Loading branch information
muink committed Dec 1, 2023
1 parent 827167a commit 45eedc3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
15 changes: 15 additions & 0 deletions htdocs/luci-static/resources/view/homeproxy/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,16 @@ return view.extend({
so.rmempty = false;
so.readonly = true;

so = ss.option(form.ListValue, 'ip_version', _('IP Version'));
so.value('4', _('IPv4'));
so.value('6', _('IPv6'));
so.value('', _('Both'));
so.modalonly = true;

so = ss.option(form.DynamicList, 'query_type', _('Query type'),
_('Match query type.'));
so.modalonly = true;

so = ss.option(form.ListValue, 'network', _('Network'));
so.value('tcp', _('TCP'));
so.value('udp', _('UDP'));
Expand Down Expand Up @@ -835,6 +845,11 @@ return view.extend({
_('Disable cache and save cache in this query.'));
so.default = so.disabled;
so.modalonly = true;

so = ss.option(form.Value, 'rewrite_ttl', _('Rewrite TTL'),
_('Rewrite TTL in DNS responses.'));
so.datatype = 'uinteger';
so.modalonly = true;
/* DNS rules end */
/* Custom routing settings end */

Expand Down
18 changes: 17 additions & 1 deletion root/etc/homeproxy/scripts/generate_client.uc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'use strict';

import { readfile, writefile } from 'fs';
import { isnan } from 'math';
import { cursor } from 'uci';

import {
Expand Down Expand Up @@ -116,6 +117,18 @@ function parse_port(strport) {

}

function parse_dnsquery(strquery) {
if (type(strquery) !== 'array' || isEmpty(strquery))
return null;

let querys = [];
for (let i in strquery)
isnan(int(i)) ? push(querys, i) : push(querys, int(i));

return querys;

}

function generate_outbound(node) {
if (type(node) !== 'object' || isEmpty(node))
return null;
Expand Down Expand Up @@ -377,6 +390,8 @@ if (!isEmpty(main_node)) {
return;

push(config.dns.rules, {
ip_version: strToInt(cfg.ip_version),
query_type: parse_dnsquery(cfg.query_type),
network: cfg.network,
protocol: cfg.protocol,
domain: cfg.domain,
Expand All @@ -396,7 +411,8 @@ if (!isEmpty(main_node)) {
invert: (cfg.invert === '1'),
outbound: get_outbound(cfg.outbound),
server: get_resolver(cfg.server),
disable_cache: (cfg.dns_disable_cache === '1')
disable_cache: (cfg.dns_disable_cache === '1'),
rewrite_ttl: strToInt(cfg.rewrite_ttl)
});
});

Expand Down

0 comments on commit 45eedc3

Please sign in to comment.