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, 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) { 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, action = %v\n", application, icon, path, address, action) 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, optstring, sandbox) 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...") log.Print("Waiting on decision...")
decision.Cond.L.Lock() decision.Cond.L.Lock()
for !decision.Ready { for !decision.Ready {

@ -101,7 +101,7 @@ func promptInfo(msg string) {
} }
scrollbox.Add(tv) scrollbox.Add(tv)
scrollbox.SetSizeRequest(600, 100) scrollbox.SetSizeRequest(500, 100)
box, err := dialog.GetContentArea() box, err := dialog.GetContentArea()
@ -315,13 +315,21 @@ func createListStore(general bool) *gtk.ListStore {
return 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 { if listStore == nil {
listStore = globalLS listStore = globalLS
} }
iter := listStore.Append() 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 := make([]interface{}, 11)
colVals[0] = 1 colVals[0] = 1
colVals[1] = path colVals[1] = path
@ -744,8 +752,6 @@ func main() {
log.Fatal("Unable to create scrolled window:", err) log.Fatal("Unable to create scrolled window:", err)
} }
scrollbox.Add(box)
tv, err := gtk.TreeViewNew() tv, err := gtk.TreeViewNew()
if err != nil { if err != nil {
@ -839,7 +845,9 @@ func main() {
box.PackStart(bb, false, false, 5) box.PackStart(bb, false, false, 5)
box.PackStart(editbox, 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("#", 0))
tv.AppendColumn(createColumn("Path", 1)) tv.AppendColumn(createColumn("Path", 1))
@ -975,8 +983,9 @@ func main() {
}) })
scrollbox.SetSizeRequest(600, 400) scrollbox.SetSizeRequest(600, 400)
Notebook.AppendPage(scrollbox, nbLabel) // Notebook.AppendPage(scrollbox, nbLabel)
// setup_settings() Notebook.AppendPage(box, nbLabel)
// setup_settings()
mainWin.Add(Notebook) mainWin.Add(Notebook)
if userPrefs.Winheight > 0 && userPrefs.Winwidth > 0 { if userPrefs.Winheight > 0 && userPrefs.Winwidth > 0 {

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

@ -101,6 +101,12 @@ func (sc *pendingSocksConnection) src() net.IP {
} }
func (sc *pendingSocksConnection) deliverVerdict(v int) { 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 sc.verdict <- v
close(sc.verdict) close(sc.verdict)
} }

Loading…
Cancel
Save