Skip to content

Commit

Permalink
Merge pull request openwrt#7227 from stangri/master-luci-app-pbr
Browse files Browse the repository at this point in the history
luci-app-pbr: sync with 1.1.6-20 principal package
  • Loading branch information
stangri authored Aug 14, 2024
2 parents 4380591 + fc9f85f commit 521dc76
Show file tree
Hide file tree
Showing 7 changed files with 354 additions and 233 deletions.
9 changes: 5 additions & 4 deletions applications/luci-app-pbr/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# Copyright 2017-2023 MOSSDeF, Stan Grishin ([email protected])
# This is free software, licensed under the GNU General Public License v3.
# Copyright 2017-2024 MOSSDeF, Stan Grishin ([email protected]).
# This is free software, licensed under AGPL-3.0-or-later.

include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-pbr
PKG_LICENSE:=AGPL-3.0-or-later
PKG_MAINTAINER:=Stan Grishin <[email protected]>
PKG_VERSION:=1.1.4
PKG_RELEASE:=16
PKG_VERSION:=1.1.6
PKG_RELEASE:=20

LUCI_TITLE:=Policy Based Routing Service Web UI
LUCI_URL:=https://github.com/stangri/luci-app-pbr/
LUCI_DESCRIPTION:=Provides Web UI for Policy Based Routing Service.
LUCI_DEPENDS:=+luci-base +jsonfilter +pbr

Expand Down
4 changes: 4 additions & 0 deletions applications/luci-app-pbr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# README

Documentation for this project is available at [https://docs.openwrt.melmac.net/luci-app-pbr/](https://docs.openwrt.melmac.net/luci-app-pbr/).

Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,25 @@ var pkg = {
get Name() {
return "pbr";
},
get ReadmeCompat() {
return "1.1.6-16";
},
get URL() {
return "https://docs.openwrt.melmac.net/" + pkg.Name + "/";
return (
"https://docs.openwrt.melmac.net/" +
pkg.Name +
"/" +
(pkg.ReadmeCompat ? pkg.ReadmeCompat + "/" : "")
);
},
get DonateURL() {
return (
"https://docs.openwrt.melmac.net/" +
pkg.Name +
"/" +
(pkg.ReadmeCompat ? pkg.ReadmeCompat + "/" : "") +
"#Donate"
);
},
};

Expand Down Expand Up @@ -184,13 +201,21 @@ var status = baseclass.extend({
{ class: "cbi-value-title" },
_("Service Gateways")
);
text = _(
"The %s indicates default gateway. See the %sREADME%s for details."
).format(
"<strong>✓</strong>",
'<a href="' + pkg.URL + '#AWordAboutDefaultRouting" target="_blank">',
"</a>"
);
text =
_(
"The %s indicates default gateway. See the %sREADME%s for details."
).format(
"<strong>✓</strong>",
'<a href="' +
pkg.URL +
'#AWordAboutDefaultRouting" target="_blank">',
"</a>"
) +
"<br />" +
_("Please %sdonate%s to support development of this project.").format(
"<a href='" + pkg.DonateURL + "' target='_blank'>",
"</a>"
);
var gatewaysDescr = E("div", { class: "cbi-value-description" }, text);
var gatewaysText = E("div", {}, reply.gateways);
var gatewaysField = E("div", { class: "cbi-value-field" }, [
Expand Down Expand Up @@ -228,8 +253,11 @@ var status = baseclass.extend({
warningInvalidOVPNConfig: _(
"Invalid OpenVPN config for %s interface"
),
warningOutdatedWebUIApp: _(
"The WebUI application is outdated (version %s), please update it"
warningOutdatedLuciPackage: _(
"The WebUI application (luci-app-pbr) is outdated, please update it"
),
warningOutdatedPrincipalPackage: _(
"The principal package (pbr) is outdated, please update it"
),
warningBadNftCallsInUserFile: _(
"Incompatible nft calls detected in user include file, disabling fw4 nft file support."
Expand Down Expand Up @@ -310,6 +338,10 @@ var status = baseclass.extend({
"Policy '%s' has no source/destination parameters"
),
errorPolicyNoInterface: _("Policy '%s' has no assigned interface"),
errorPolicyNoDns: _("Policy '%s' has no assigned DNS"),
errorPolicyProcessNoInterfaceDns: _(
"Interface '%s' has no assigned DNS"
),
errorPolicyUnknownInterface: _(
"Policy '%s' has an unknown interface"
),
Expand Down Expand Up @@ -380,9 +412,9 @@ var status = baseclass.extend({
text += _("Unknown error!") + "<br />";
}
});
text += _("Errors encountered, please check the %sREADME%s!").format(
text += _("Errors encountered, please check the %sREADME%s").format(
'<a href="' + pkg.URL + '" target="_blank">',
"</a><br />"
"</a>!<br />"
);
var errorsText = E("div", {}, text);
var errorsField = E("div", { class: "cbi-value-field" }, errorsText);
Expand Down Expand Up @@ -534,13 +566,37 @@ var status = baseclass.extend({
var buttonsDiv = reply.version
? E("div", { class: "cbi-value" }, [buttonsTitle, buttonsField])
: "";

var donateTitle = E(
"label",
{ class: "cbi-value-title" },
_("Donate to the Project")
);
var donateText = E(
"div",
{ class: "cbi-value-field" },
E(
"div",
{ class: "cbi-value-description" },
_("Please %sdonate%s to support development of this project.").format(
"<a href='" + pkg.DonateURL + "' target='_blank'>",
"</a>"
)
)
);

var donateDiv = reply.version
? E("div", { class: "cbi-value" }, [donateTitle, donateText])
: "";

return E("div", {}, [
header,
statusDiv,
gatewaysDiv,
warningsDiv,
errorsDiv,
buttonsDiv,
// donateDiv,
]);
});
},
Expand All @@ -553,6 +609,8 @@ RPC.on("setInitAction", function (reply) {

return L.Class.extend({
status: status,
pkg: pkg,
getInitStatus: getInitStatus,
getInterfaces: getInterfaces,
getPlatformSupport: getPlatformSupport,
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@
"require view";
"require pbr.status as pbr";

var pkg = {
get Name() {
return "pbr";
},

get URL() {
return "https://docs.openwrt.melmac.net/" + pkg.Name + "/";
},
};
var pkg = pbr.pkg;

return view.extend({
load: function () {
Expand Down Expand Up @@ -95,26 +87,6 @@ return view.extend({
o.default = "1";

var text = "";
if (reply.platform.adguardhome_ipset_support === null) {
text +=
_("The %s support is unknown.").format("<i>adguardhome.ipset</i>") +
"<br />";
} else if (!reply.platform.adguardhome_ipset_support) {
text +=
_("The %s is not supported on this system.").format(
"<i>adguardhome.ipset</i>"
) + "<br />";
}
if (reply.platform.dnsmasq_ipset_support === null) {
text +=
_("The %s support is unknown.").format("<i>dnsmasq.ipset</i>") +
"<br />";
} else if (!reply.platform.dnsmasq_ipset_support) {
text +=
_("The %s is not supported on this system.").format(
"<i>dnsmasq.ipset</i>"
) + "<br />";
}
if (reply.platform.dnsmasq_nftset_support === null) {
text +=
_("The %s support is unknown.").format("<i>dnsmasq.nftset</i>") +
Expand Down Expand Up @@ -279,7 +251,10 @@ return view.extend({
_(
"Name, interface and at least one other field are required. Multiple local and remote " +
"addresses/devices/domains and ports can be space separated. Placeholders below represent just " +
"the format/syntax and will not be used if fields are left blank."
"the format/syntax and will not be used if fields are left blank. For more information on options, check the %sREADME%s."
).format(
'<a href="' + pkg.URL + '#PolicyOptions" target="_blank">',
"</a>"
)
);
s.rowcolors = true;
Expand Down Expand Up @@ -350,6 +325,45 @@ return view.extend({
o.datatype = "network";
o.rmempty = false;

s = m.section(
form.GridSection,
"dns_policy",
_("DNS Policies"),
_(
"Name, local address and remote DNS fields are required. Multiple local " +
"addresses/devices can be space separated. For more information on options, check the %sREADME%s."
).format(
'<a href="' + pkg.URL + '#DNSPolicyOptions" target="_blank">',
"</a>"
)
);
s.rowcolors = true;
s.sortable = true;
s.anonymous = true;
s.addremove = true;

o = s.option(form.Flag, "enabled", _("Enabled"));
o.default = "1";
o.editable = true;

o = s.option(form.Value, "name", _("Name"));
o.optional = false;

o = s.option(form.Value, "src_addr", _("Local addresses / devices"));
o.optional = false;
o.datatype =
"list(neg(or(cidr,host,ipmask,ipaddr,macaddr,network,string)))";
o.rmempty = true;
o.default = "";

o = s.option(form.Value, "dest_dns", _("Remote DNS"));
o.optional = false;
o.rmempty = false;
o.datatype = "list(or(cidr,host,network,ipaddr))";
reply.interfaces.forEach((element) => {
element === "ignore" || o.value(element);
});

s = m.section(
form.NamedSection,
"config",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,15 @@
"require rpc";
"require form";
"require baseclass";
"require pbr.status as pbr";

var pkg = {
get Name() {
return "pbr";
},
get URL() {
return "https://docs.openwrt.melmac.net/" + pkg.Name + "/";
},
};

var getInitStatus = rpc.declare({
object: "luci." + pkg.Name,
method: "getInitStatus",
params: ["name"],
});
var pkg = pbr.pkg;

return baseclass.extend({
title: _("Policy Based Routing"),

load: function () {
return Promise.all([getInitStatus(pkg.Name)]);
return Promise.all([pbr.getInitStatus(pkg.Name)]);
},

render: function (data) {
Expand Down
Loading

0 comments on commit 521dc76

Please sign in to comment.