Skip to content

wg genkey each run if not provided #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions cmd/tunnel/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
b64 "encoding/base64"
"fmt"
"io"
"log"
Expand All @@ -11,6 +12,7 @@ import (
"os/signal"
"time"

"github.com/dchest/uniuri"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors"

Expand Down Expand Up @@ -47,8 +49,9 @@ func main() {
&cli.StringFlag{
Name: "wireguard-key",
Aliases: []string{"wg-key"},
Usage: "The private key for the wireguard client. It should be base64 encoded. You must specify this or wireguard-key-file.",
Usage: "The private key for the wireguard client. It should be base64 encoded. Defaults to a new random key. wireguard-key-file will over-ride this option.",
EnvVars: []string{"TUNNEL_WIREGUARD_KEY"},
Value: b64.StdEncoding.EncodeToString([]byte(uniuri.NewLen(32))),
},
&cli.StringFlag{
Name: "wireguard-key-file",
Expand Down Expand Up @@ -76,12 +79,6 @@ func runApp(ctx *cli.Context) error {
if apiURL == "" {
return xerrors.New("api-url is required. See --help for more information.")
}
if wireguardKey == "" && wireguardKeyFile == "" {
return xerrors.New("wireguard-key or wireguard-key-file is required. See --help for more information.")
}
if wireguardKey != "" && wireguardKeyFile != "" {
return xerrors.New("Only one of wireguard-key or wireguard-key-file can be specified. See --help for more information.")
}

if ctx.Args().Len() != 1 {
return xerrors.New("exactly one argument (target-address) is required. See --help for more information.")
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dchest/uniuri v1.2.0 // indirect
github.com/dlclark/regexp2 v1.8.1 // indirect
github.com/fatih/color v1.14.1 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dchest/uniuri v1.2.0 h1:koIcOUdrTIivZgSLhHQvKgqdWZq5d7KdMEWF1Ud6+5g=
github.com/dchest/uniuri v1.2.0/go.mod h1:fSzm4SLHzNZvWLvWJew423PhAzkpNQYq+uNLq4kxhkY=
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/dlclark/regexp2 v1.8.1 h1:6Lcdwya6GjPUNsBct8Lg/yRPwMhABj269AAzdGSiR+0=
github.com/dlclark/regexp2 v1.8.1/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
Expand Down