Upgraded standalone fw-prompt for DBus compatibility with new fw-daemon.

Averted potential panic issue in SOCKS5 listener.
Fixed strange whole-window scrolling behavior in fw-prompt.
Removed verbose debug output in fw-prompt.
shw-merge
Stephen Watt 7 years ago
parent a3fa1b1285
commit e3ab56486b

@ -63,9 +63,9 @@ func newDbusServer() (*dbusServer, error) {
}
func (ds *dbusServer) RequestPrompt(application, icon, path, address string, port int32, ip, origin, proto string, uid, gid int32, username, groupname string, pid int32, sandbox string,
optstring string, expanded, expert bool, action int32) (int32, string, *dbus.Error) {
log.Printf("request prompt: app = %s, icon = %s, path = %s, address = %s, action = %v\n", application, icon, path, address, action)
decision := addRequest(nil, path, proto, int(pid), ip, address, int(port), int(uid), int(gid), origin, optstring, sandbox)
is_socks bool, optstring string, expanded, expert bool, action int32) (int32, string, *dbus.Error) {
log.Printf("request prompt: app = %s, icon = %s, path = %s, address = %s, is_socks = %v, action = %v\n", application, icon, path, address, is_socks, action)
decision := addRequest(nil, path, proto, int(pid), ip, address, int(port), int(uid), int(gid), origin, is_socks, optstring, sandbox)
log.Print("Waiting on decision...")
decision.Cond.L.Lock()
for !decision.Ready {

@ -101,7 +101,7 @@ func promptInfo(msg string) {
}
scrollbox.Add(tv)
scrollbox.SetSizeRequest(600, 100)
scrollbox.SetSizeRequest(500, 100)
box, err := dialog.GetContentArea()
@ -315,13 +315,21 @@ func createListStore(general bool) *gtk.ListStore {
return listStore
}
func addRequest(listStore *gtk.ListStore, path, proto string, pid int, ipaddr, hostname string, port, uid, gid int, origin, optstring string, sandbox string) *decisionWaiter {
func addRequest(listStore *gtk.ListStore, path, proto string, pid int, ipaddr, hostname string, port, uid, gid int, origin string, is_socks bool, optstring string, sandbox string) *decisionWaiter {
if listStore == nil {
listStore = globalLS
}
iter := listStore.Append()
if (is_socks) {
if ((optstring != "") && (strings.Index(optstring, "SOCKS") == -1)) {
optstring = "SOCKS5 / " + optstring
} else if (optstring == "") {
optstring = "SOCKS5"
}
}
colVals := make([]interface{}, 11)
colVals[0] = 1
colVals[1] = path
@ -744,8 +752,6 @@ func main() {
log.Fatal("Unable to create scrolled window:", err)
}
scrollbox.Add(box)
tv, err := gtk.TreeViewNew()
if err != nil {
@ -839,7 +845,9 @@ func main() {
box.PackStart(bb, false, false, 5)
box.PackStart(editbox, false, false, 5)
box.PackStart(tv, false, true, 5)
scrollbox.Add(tv)
// box.PackStart(tv, false, true, 5)
box.PackStart(scrollbox, false, true, 5)
tv.AppendColumn(createColumn("#", 0))
tv.AppendColumn(createColumn("Path", 1))
@ -975,8 +983,9 @@ func main() {
})
scrollbox.SetSizeRequest(600, 400)
Notebook.AppendPage(scrollbox, nbLabel)
// setup_settings()
// Notebook.AppendPage(scrollbox, nbLabel)
Notebook.AppendPage(box, nbLabel)
// setup_settings()
mainWin.Add(Notebook)
if userPrefs.Winheight > 0 && userPrefs.Winwidth > 0 {

@ -79,7 +79,7 @@ func (p *prompter) processNextPacket() bool {
empty := true
for {
pc, empty = p.nextConnection()
fmt.Println("processNextPacket() loop; empty = ", empty, " / pc = ", pc)
// fmt.Println("XXX: processNextPacket() loop; empty = ", empty, " / pc = ", pc)
if pc == nil && empty {
return false
} else if pc == nil {
@ -90,7 +90,7 @@ func (p *prompter) processNextPacket() bool {
}
p.lock.Unlock()
defer p.lock.Lock()
fmt.Println("Waiting for prompt lock go...")
// fmt.Println("XXX: Waiting for prompt lock go...")
for {
promptLock.Lock()
if outstandingPrompts >= MAX_PROMPTS {
@ -106,9 +106,9 @@ func (p *prompter) processNextPacket() bool {
break
}
fmt.Println("Passed prompt lock!")
// fmt.Println("XXX: Passed prompt lock!")
outstandingPrompts++
fmt.Println("Incremented outstanding to ", outstandingPrompts)
// fmt.Println("XXX: Incremented outstanding to ", outstandingPrompts)
promptLock.Unlock()
// if !pc.getPrompting() {
pc.setPrompting(true)
@ -120,7 +120,7 @@ func (p *prompter) processNextPacket() bool {
func processReturn(pc pendingConnection) {
promptLock.Lock()
outstandingPrompts--
fmt.Println("Return decremented outstanding to ", outstandingPrompts)
// fmt.Println("XXX: Return decremented outstanding to ", outstandingPrompts)
promptLock.Unlock()
pc.setPrompting(false)
}

@ -101,6 +101,12 @@ func (sc *pendingSocksConnection) src() net.IP {
}
func (sc *pendingSocksConnection) deliverVerdict(v int) {
defer func() {
if r := recover(); r != nil {
log.Warning("SOCKS5 server recovered from panic while delivering firewall verdict:", r)
}
}()
sc.verdict <- v
close(sc.verdict)
}

Loading…
Cancel
Save