Skip to content

Commit

Permalink
feat(node,server): implement certpath validate
Browse files Browse the repository at this point in the history
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
  • Loading branch information
1715173329 committed Dec 4, 2024
1 parent 1d815e1 commit d7a90a2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions htdocs/luci-static/resources/homeproxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,14 @@ return baseclass.extend({
return true;
},

validateCertificatePath: function(section_id, value) {
if (section_id && value)
if (!value.match(/^(\/etc\/homeproxy\/certs\/|\/etc\/acme\/|\/etc\/ssl\/).+$/))
return _('Expecting: %s').format(_('/etc/homeproxy/certs/..., /etc/acme/..., /etc/ssl/...'));

return true;
},

validateUniqueValue: function(uciconfig, ucisection, ucioption, section_id, value) {
if (section_id) {
if (!value)
Expand Down
1 change: 1 addition & 0 deletions htdocs/luci-static/resources/view/homeproxy/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,7 @@ function renderNodeSettings(section, data, features, main_node, routing_mode) {
_('The path to the server certificate, in PEM format.'));
o.value('/etc/homeproxy/certs/client_ca.pem');
o.depends('tls_self_sign', '1');
o.validate = L.bind(hp.validateCertificatePath, this);
o.rmempty = false;
o.modalonly = true;

Expand Down
2 changes: 2 additions & 0 deletions htdocs/luci-static/resources/view/homeproxy/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ return view.extend({
o.depends({'tls': '1', 'tls_acme': '0', 'tls_reality': '0'});
o.depends({'tls': '1', 'tls_acme': null, 'tls_reality': '0'});
o.depends({'tls': '1', 'tls_acme': null, 'tls_reality': null});
o.validate = L.bind(hp.validateCertificatePath, this);
o.rmempty = false;
o.modalonly = true;

Expand All @@ -763,6 +764,7 @@ return view.extend({
o.depends({'tls': '1', 'tls_acme': '0', 'tls_reality': null});
o.depends({'tls': '1', 'tls_acme': null, 'tls_reality': '0'});
o.depends({'tls': '1', 'tls_acme': null, 'tls_reality': null});
o.validate = L.bind(hp.validateCertificatePath, this);
o.rmempty = false;
o.modalonly = true;

Expand Down

0 comments on commit d7a90a2

Please sign in to comment.