Skip to content

Commit

Permalink
Merged for version alpha.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaidiz committed Sep 2, 2020
2 parents 5946e97 + 5db62f0 commit 1643d3b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
23 changes: 14 additions & 9 deletions gui/maingui.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gui

import (
"time"
"path/filepath"
"fmt"

Expand All @@ -14,7 +13,7 @@ import (
"github.com/rhaidiz/broxy/util"
)

var broxyTitle = "Broxy (1.0.0-alpha.3)"
var broxyTitle = "Broxy (1.0.0-alpha.4)"

// Broxygui is the main GUI made of tabs
type Broxygui struct {
Expand Down Expand Up @@ -58,18 +57,18 @@ func (g *Broxygui) createMenuBar(){
menuBar := g.MenuBar().AddMenu2("&File")

newAction := widgets.NewQAction2("New project", g)
saveAction := widgets.NewQAction2("Persist project", g)
//saveAction := widgets.NewQAction2("Persist project", g)
openAction := widgets.NewQAction2("Open project...", g)

menuBar.AddActions([]*widgets.QAction{})
menuBar.AddActions([]*widgets.QAction{newAction, saveAction,openAction})
menuBar.AddActions([]*widgets.QAction{newAction, openAction})

newAction.SetShortcuts2(gui.QKeySequence__New)
saveAction.SetShortcuts2(gui.QKeySequence__SaveAs)
//saveAction.SetShortcuts2(gui.QKeySequence__SaveAs)
openAction.SetShortcuts2(gui.QKeySequence__Open)

newAction.ConnectTriggered(g.newProjectAction)
saveAction.ConnectTriggered(g.saveProjectAction)
//saveAction.ConnectTriggered(g.saveProjectAction)
openAction.ConnectTriggered(g.openProjectAction)

}
Expand Down Expand Up @@ -128,9 +127,15 @@ func (g *Broxygui) saveProjectAction(b bool){


func (g *Broxygui) newProjectAction(b bool){
p := filepath.Join(util.GetTmpDir(), fmt.Sprintf("%d",time.Now().UnixNano()))
fmt.Println(p)
c, err := project.NewPersistentProject("NewProject",p)
var fileDialog = widgets.NewQFileDialog2(g, "Create new project", "", "")
fileDialog.SetAcceptMode(widgets.QFileDialog__AcceptSave)
if fileDialog.Exec() != int(widgets.QDialog__Accepted) {
return
}
var fn = fileDialog.SelectedFiles()[0]
dir, file := filepath.Split(fn)

c, err := project.NewPersistentProject(file,dir)

if err != nil {
g.ShowErrorMessage(fmt.Sprintf("Error while creating project: %s",err))
Expand Down
15 changes: 11 additions & 4 deletions gui/projectgui.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/widgets"
"time"
//"time"
"path/filepath"
)

Expand Down Expand Up @@ -141,13 +141,20 @@ func (g *Projectgui) itemDoubleClicked(item *widgets.QListWidgetItem){

func (g *Projectgui) newProject(b bool) {

p := filepath.Join(util.GetTmpDir(), fmt.Sprintf("%d",time.Now().UnixNano()))
c, err := project.NewPersistentProject("NewProject",p)
var fileDialog = widgets.NewQFileDialog2(g, "Create new project", "", "")
fileDialog.SetAcceptMode(widgets.QFileDialog__AcceptSave)
if fileDialog.Exec() != int(widgets.QDialog__Accepted) {
return
}
var fn = fileDialog.SelectedFiles()[0]
dir, file := filepath.Split(fn)

c, err := project.NewPersistentProject(file,dir)
if err != nil {
g.showErrorMessage(fmt.Sprintf("Error while creating a new project: %s",err))
}

// temporary, for now, everytime I create a new project I save it in the history
g.history.Add(&project.Project{file,dir})
gui := NewBroxygui(nil,0)
s := bcore.NewSession(g.config, c, gui)
//Load All modules
Expand Down
5 changes: 3 additions & 2 deletions modules/coreproxy/coreproxy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,11 @@ func (c *Controller) onReq(r *http.Request, ctx *goproxy.ProxyCtx) (*http.Reques
}
ips, err := net.LookupHost(r.Host)
var ip string
if err == nil {
if err != nil {
ip = "Unknown host"
}else{
ip = ips[0]
}
ip = ips[0]
// this is the original request, save it for the history
httpItem.Req = &model.Request{
ID: count + ctx.Session,
Expand Down
13 changes: 1 addition & 12 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,7 @@ func GetSettingsDir() string {

// GetTmpDir returns the path to a temporary folder
func GetTmpDir() string {
if runtime.GOOS == "linux" {
return filepath.Join("/tmp")
}

if runtime.GOOS == "darwin" {
return filepath.Join("/tmp")
}

if runtime.GOOS == "windows" {
return filepath.Join(os.Getenv("TEMP"))
}
return "./"
return os.TempDir()
}

func IsNil(i interface{}) bool {
Expand Down

0 comments on commit 1643d3b

Please sign in to comment.