gnome-shell fmt...

shw-merge
xSmurf 7 years ago
parent c01894f35c
commit 11b8ec9818

@ -29,14 +29,14 @@ const DetailSection = new Lang.Class({
this.ipAddr = this._addDetails("IP Address:"); this.ipAddr = this._addDetails("IP Address:");
this.path = this._addDetails("Path:"); this.path = this._addDetails("Path:");
this.pid = this._addDetails("Process ID:"); this.pid = this._addDetails("Process ID:");
this.origin = this._addDetails("Origin:"); this.origin = this._addDetails("Origin:");
this.user = this._addDetails("User:"); this.user = this._addDetails("User:");
this.group = this._addDetails("Group:"); this.group = this._addDetails("Group:");
this.sandboxed = sandboxed; this.sandboxed = sandboxed;
if (sandboxed) { if (sandboxed) {
this.sandbox = this._addDetails("Sandbox:"); this.sandbox = this._addDetails("Sandbox:");
} }
this.optstring = this._addDetails(""); this.optstring = this._addDetails("");
}, },
@ -52,37 +52,37 @@ const DetailSection = new Lang.Class({
this.ipAddr.text = ip; this.ipAddr.text = ip;
this.path.text = path; this.path.text = path;
if (pid == -1) { if (pid == -1) {
this.pid.text = '[unknown]'; this.pid.text = '[unknown]';
} else { } else {
this.pid.text = pid.toString(); this.pid.text = pid.toString();
} }
this.origin.text = origin; this.origin.text = origin;
if (user != "") { if (user != "") {
this.user.text = user; this.user.text = user;
if (uid != -1) { if (uid != -1) {
this.user.text += " (" + uid.toString() + ")"; this.user.text += " (" + uid.toString() + ")";
} }
} else { } else {
this.user.text = "uid:" + uid.toString(); this.user.text = "uid:" + uid.toString();
} }
if (group != "") { if (group != "") {
this.group.text = group; this.group.text = group;
if (gid != -1) { if (gid != -1) {
this.group.text += " (" + gid.toString() + ")"; this.group.text += " (" + gid.toString() + ")";
} }
} else { } else {
this.group.text = "gid:" + gid.toString(); this.group.text = "gid:" + gid.toString();
} }
if (sandbox != "") { if (sandbox != "") {
this.sandbox.text = sandbox; this.sandbox.text = sandbox;
} }
this.optstring.text = optstring this.optstring.text = optstring
} }
}); });
@ -141,23 +141,23 @@ const OptionList = new Lang.Class({
_init: function(pid_known, sandboxed) { _init: function(pid_known, sandboxed) {
this.actor = new St.BoxLayout({vertical: true, style_class: 'fw-option-list'}); this.actor = new St.BoxLayout({vertical: true, style_class: 'fw-option-list'});
if (pid_known) { if (pid_known) {
this.buttonGroup = new ButtonGroup("Forever", "Session", "Once", "PID"); this.buttonGroup = new ButtonGroup("Forever", "Session", "Once", "PID");
} else { } else {
this.buttonGroup = new ButtonGroup("Forever", "Session", "Once"); this.buttonGroup = new ButtonGroup("Forever", "Session", "Once");
} }
this.actor.add_child(this.buttonGroup.actor); this.actor.add_child(this.buttonGroup.actor);
this.items = []; this.items = [];
this._selected; this._selected;
this.tlsGuard = false; this.tlsGuard = false;
if (sandboxed) { if (sandboxed) {
this.tlsGuard = true; this.tlsGuard = true;
} }
}, },
setOptionText: function(idx, text) { setOptionText: function(idx, text) {
if(this.items.length <= idx) { if(this.items.length <= idx) {
log("attempt to setOptionText with idx = "+ idx + " when this.items.length = "+ this.items.length) //log("SGFW: attempt to setOptionText with idx = "+ idx + " when this.items.length = "+ this.items.length)
return; return;
} }
this.items[idx].setText(text); this.items[idx].setText(text);
@ -165,12 +165,12 @@ const OptionList = new Lang.Class({
addTLSOption: function(tlsGuardEnabled) { addTLSOption: function(tlsGuardEnabled) {
let tlsg = new OptionListItem("Drop connection if not TLS with valid certificate",0); let tlsg = new OptionListItem("Drop connection if not TLS with valid certificate",0);
tlsg.setSelected(tlsGuardEnabled); tlsg.setSelected(tlsGuardEnabled);
tlsg.connect('selected', Lang.bind(this, function() { tlsg.connect('selected', Lang.bind(this, function() {
this._toggleTLSGuard(tlsg); this._toggleTLSGuard(tlsg);
})); }));
let emptyRow = new OptionListItem("",0); let emptyRow = new OptionListItem("",0);
this.actor.add_child(emptyRow.actor); this.actor.add_child(emptyRow.actor);
this.actor.add_child(tlsg.actor); this.actor.add_child(tlsg.actor);
}, },
@ -182,7 +182,7 @@ const OptionList = new Lang.Class({
} else { } else {
this.tlsGuard = true; this.tlsGuard = true;
item.actor.add_style_pseudo_class('selected'); item.actor.add_style_pseudo_class('selected');
item.setSelected(true) item.setSelected(true)
} }
}, },
@ -232,7 +232,7 @@ const OptionList = new Lang.Class({
case 3: case 3:
return RuleScope.APPLY_PROCESS; return RuleScope.APPLY_PROCESS;
default: default:
log("unexpected scope value "+ this.buttonGroup._selected); log("SGFW: unexpected scope value "+ this.buttonGroup._selected);
return RuleScope.APPLY_SESSION; return RuleScope.APPLY_SESSION;
} }
}, },
@ -248,7 +248,7 @@ const OptionList = new Lang.Class({
case RuleScope.APPLY_FOREVER: case RuleScope.APPLY_FOREVER:
return 0; return 0;
default: default:
log("unexpected scope value "+ scope); log("SGFW: unexpected scope value "+ scope);
return 1; return 1;
} }
} }
@ -479,12 +479,9 @@ const PromptDialog = new Lang.Class({
"Only PORT", "Only PORT",
"Any Connection"]); "Any Connection"]);
if (tlsguard) { if (tlsguard) {
this.optionList.addTLSOption(true); this.optionList.addTLSOption(true);
} }
// let tlsGuard = new OptionListItem("Drop connection if not TLS with valid certificate.",0);
//box.add_child(optionList.actor);
this._initialKeyFocusDestroyId = 1; this._initialKeyFocusDestroyId = 1;
this.setButtons([ this.setButtons([
@ -509,25 +506,25 @@ const PromptDialog = new Lang.Class({
} }
let verb = "DENY"; let verb = "DENY";
if(allow) { if(allow) {
verb = "ALLOW"; verb = "ALLOW";
if (this.optionList.tlsGuard) { if (this.optionList.tlsGuard) {
verb = "ALLOW_TLSONLY"; verb = "ALLOW_TLSONLY";
} else { } else {
verb = "ALLOW"; verb = "ALLOW";
} }
} }
let rule = verb + "|" + this.ruleTarget() + "|" + this.ruleSandbox(); let rule = verb + "|" + this.ruleTarget() + "|" + this.ruleSandbox();
let scope = this.optionList.selectedScope(); let scope = this.optionList.selectedScope();
this._invocation.return_value(GLib.Variant.new('(is)', [scope, rule])); this._invocation.return_value(GLib.Variant.new('(is)', [scope, rule]));
this._invocation = null; this._invocation = null;
}, },
ruleTarget: function() { ruleTarget: function() {
let base = ""; let base = "";
if(this._proto != "tcp") { if(this._proto != "tcp") {
base = this._proto + ":"; base = this._proto + ":";
} }
switch(this.optionList.selectedIdx()) { switch(this.optionList.selectedIdx()) {
case 0: case 0:
return base + this._address + ":" + this._port; return base + this._address + ":" + this._port;
@ -541,7 +538,7 @@ const PromptDialog = new Lang.Class({
}, },
ruleSandbox: function() { ruleSandbox: function() {
return this._sandbox; return this._sandbox;
}, },
ruleTLSGuard: function() { ruleTLSGuard: function() {
@ -551,29 +548,29 @@ const PromptDialog = new Lang.Class({
update: function(application, icon, path, address, port, ip, origin, uid, gid, user, group, pid, proto, tlsguard, optstring, sandbox, expanded, expert, action) { update: function(application, icon, path, address, port, ip, origin, uid, gid, user, group, pid, proto, tlsguard, optstring, sandbox, expanded, expert, action) {
this._address = address; this._address = address;
this._port = port; this._port = port;
this._proto = proto; this._proto = proto;
this._sandbox = sandbox; this._sandbox = sandbox;
this._tlsGuard = tlsguard; this._tlsGuard = tlsguard;
let port_str = (proto+"").toUpperCase() + " Port "+ port; let port_str = (proto+"").toUpperCase() + " Port "+ port;
if (proto == "icmp") { if (proto == "icmp") {
port_str = (proto+"").toUpperCase() + " Code "+ port; port_str = (proto+"").toUpperCase() + " Code "+ port;
} }
if (sandbox != "") { if (sandbox != "") {
application = application + " (sandboxed)" application = application + " (sandboxed)"
} }
this.header.setTitle(application); this.header.setTitle(application);
if (proto == "tcp") { if (proto == "tcp") {
this.header.setMessage("Wants to connect to "+ address + " on " + port_str); this.header.setMessage("Wants to connect to "+ address + " on " + port_str);
} else if (proto == "udp") { } else if (proto == "udp") {
this.header.setMessage("Wants to send data to "+ address + " on " + port_str); this.header.setMessage("Wants to send data to "+ address + " on " + port_str);
} else if (proto == "icmp") { } else if (proto == "icmp") {
this.header.setMessage("Wants to send data to "+ address + " with " + port_str); this.header.setMessage("Wants to send data to "+ address + " with " + port_str);
} }
if (expanded) { if (expanded) {
this.details.isOpen = false; this.details.isOpen = false;
@ -590,8 +587,8 @@ const PromptDialog = new Lang.Class({
} else { } else {
this.optionList.setOptionText(0, "Only "+ address + " on "+ port_str); this.optionList.setOptionText(0, "Only "+ address + " on "+ port_str);
} }
if (expert) {
if (expert) {
if (proto == "icmp") { if (proto == "icmp") {
this.optionList.setOptionText(1, "Only "+ address + " with any ICMP code"); this.optionList.setOptionText(1, "Only "+ address + " with any ICMP code");
} else if (proto == "udp") { } else if (proto == "udp") {
@ -608,7 +605,7 @@ const PromptDialog = new Lang.Class({
if (proto != "tcp") { if (proto != "tcp") {
this.optionList.setOptionText(3, "Any " + proto.toUpperCase() + " data"); this.optionList.setOptionText(3, "Any " + proto.toUpperCase() + " data");
} }
this.optionList.buttonGroup._setChecked(this.optionList.scopeToIdx(action)) this.optionList.buttonGroup._setChecked(this.optionList.scopeToIdx(action))
this.info.setDetails(ip, path, pid, uid, gid, user, group, origin, proto, optstring, sandbox); this.info.setDetails(ip, path, pid, uid, gid, user, group, origin, proto, optstring, sandbox);

@ -57,8 +57,8 @@ const FirewallPromptInterface = '<node> \
<arg type="s" direction="in" name="user" /> \ <arg type="s" direction="in" name="user" /> \
<arg type="s" direction="in" name="group" /> \ <arg type="s" direction="in" name="group" /> \
<arg type="i" direction="in" name="pid" /> \ <arg type="i" direction="in" name="pid" /> \
<arg type="s" direction="in" name="sandbox" /> \ <arg type="s" direction="in" name="sandbox" /> \
<arg type="b" direction="in" name="tlsguard" /> \ <arg type="b" direction="in" name="tlsguard" /> \
<arg type="s" direction="in" name="optstring" /> \ <arg type="s" direction="in" name="optstring" /> \
<arg type="b" direction="in" name="expanded" /> \ <arg type="b" direction="in" name="expanded" /> \
<arg type="b" direction="in" name="expert" /> \ <arg type="b" direction="in" name="expert" /> \

Loading…
Cancel
Save