Skip to content

Commit

Permalink
allow to configure bind technique in GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
julsemaan committed Dec 1, 2020
1 parent 8b4fb0c commit 173ffe1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions guiwrapper/start_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/inverse-inc/wireguard-go/binutils"
"github.com/inverse-inc/wireguard-go/util"
"github.com/inverse-inc/wireguard-go/wgrpc"
"github.com/inverse-inc/wireguard-go/ztn"
)

var spacePlaceholder = " "
Expand Down Expand Up @@ -101,6 +102,14 @@ func PromptCredentials(tabs *container.AppTabs, callback func(bool)) {
installRoutesFromServerEntry := widget.NewCheck("Install routes from server", func(bool) {})
installRoutesFromServerEntry.Checked = true

preferedBindTechniqueEntry := widget.NewSelect([]string{
string(ztn.BindUPNPGID),
string(ztn.BindSTUN),
string(ztn.BindNATPMP),
string(ztn.BindThroughPeer),
}, func(string) {})
preferedBindTechniqueEntry.PlaceHolder = string(ztn.BindAutomatic)

connect := func() {

showFormError := func(msg string) {
Expand Down Expand Up @@ -139,6 +148,10 @@ func PromptCredentials(tabs *container.AppTabs, callback func(bool)) {
}
binutils.Setenv("WG_HONOR_ROUTES", honorRoutesStr)

if preferedBindTechniqueEntry.Selected != string(ztn.BindAutomatic) {
binutils.Setenv("WG_BIND_TECHNIQUE", preferedBindTechniqueEntry.Selected)
}

PostConnect(tabs)
callback(true)
}
Expand Down Expand Up @@ -173,6 +186,10 @@ func PromptCredentials(tabs *container.AppTabs, callback func(bool)) {
widget.NewHBox(
installRoutesFromServerEntry,
),
widget.NewHBox(
widget.NewLabel("Bind technique"),
preferedBindTechniqueEntry,
),
)

Refresh()
Expand Down
1 change: 1 addition & 0 deletions ztn/bind_techniques.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
// These will get ordered in the BindTechniques.
// Lower string == tried first if available
// NAT PMP hasn't worked well in a few places so its left to be tried last
BindAutomatic = BindTechnique("AUTOMATIC")
BindUPNPGID = BindTechnique("UPNPGID")
BindSTUN = BindTechnique("STUN")
BindNATPMP = BindTechnique("NATPMP")
Expand Down

0 comments on commit 173ffe1

Please sign in to comment.