Skip to content

Commit

Permalink
use a different wgenv on every run
Browse files Browse the repository at this point in the history
  • Loading branch information
julsemaan committed Dec 1, 2020
1 parent 173ffe1 commit 1eb5811
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
7 changes: 1 addition & 6 deletions binutils/binutils_linux.go
@@ -1,16 +1,11 @@
package binutils

import (
"os"
"os/exec"
"path"
)

func RunTunnel() {
home := os.Getenv("HOME")
env := path.Join(home, ".wgenv")

cmd := exec.Command("pkexec", BinPath("wireguard"), env, "--master")
cmd := exec.Command("pkexec", BinPath("wireguard"), Wgenv.Name(), "--master")
wireguardCmd = cmd
RunCmd(cmd)
}
Expand Down
3 changes: 2 additions & 1 deletion binutils/set_env_darwin.go
Expand Up @@ -6,14 +6,15 @@ import (
"fmt"
"os"
"path"
"time"

"github.com/inverse-inc/packetfence/go/sharedutils"
)

func init() {
var err error
tmp := os.Getenv("HOME")
Wgenv, err = os.OpenFile(path.Join(tmp, ".wgenv"), os.O_RDWR|os.O_CREATE, 0600)
Wgenv, err = os.OpenFile(path.Join(tmp, fmt.Sprintf(".wgenv-%d", time.Now().Unix())), os.O_RDWR|os.O_CREATE, 0600)
sharedutils.CheckError(err)
}

Expand Down
3 changes: 2 additions & 1 deletion binutils/set_env_linux.go
Expand Up @@ -6,14 +6,15 @@ import (
"fmt"
"os"
"path"
"time"

"github.com/inverse-inc/packetfence/go/sharedutils"
)

func init() {
var err error
tmp := os.Getenv("HOME")
Wgenv, err = os.OpenFile(path.Join(tmp, ".wgenv"), os.O_RDWR|os.O_CREATE, 0600)
Wgenv, err = os.OpenFile(path.Join(tmp, fmt.Sprintf(".wgenv-%d", time.Now().Unix())), os.O_RDWR|os.O_CREATE, 0600)
sharedutils.CheckError(err)
}

Expand Down
11 changes: 10 additions & 1 deletion guiwrapper/main.go
Expand Up @@ -3,6 +3,8 @@ package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"syscall"
Expand All @@ -13,6 +15,8 @@ import (
"github.com/inverse-inc/wireguard-go/wgrpc"
"github.com/inverse-inc/wireguard-go/ztn"
"github.com/joho/godotenv"

_ "net/http/pprof"
)

var rpc = wgrpc.WGRPCClient()
Expand All @@ -34,6 +38,11 @@ func main() {

go binutils.CheckParentIsAlive(quit)

go func() {
//PPROF
log.Println(http.ListenAndServe("localhost:6061", nil))
}()

setupExitSignals()
SetupAPIClientGUI(func(runTunnel bool) {
startTunnel(runTunnel)
Expand Down Expand Up @@ -99,7 +108,7 @@ func checkTunnelStatus() {
return
} else {
statusLabel.SetText(messages[status])
UpdatePeers(ctx, rpc)
//UpdatePeers(ctx, rpc)
}
}

Expand Down
2 changes: 2 additions & 0 deletions main_shared.go
Expand Up @@ -19,6 +19,8 @@ import (
"github.com/inverse-inc/wireguard-go/wgrpc"
"github.com/inverse-inc/wireguard-go/ztn"
ps "github.com/mitchellh/go-ps"

_ "net/http/pprof"
)

var connection *ztn.Connection
Expand Down

0 comments on commit 1eb5811

Please sign in to comment.