mirror of
https://codeberg.org/cunicu/cunicu.git
synced 2025-09-26 21:01:14 +08:00
move cmd package again to subdir
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
@@ -21,7 +21,7 @@ checksum:
|
||||
|
||||
builds:
|
||||
- id: wice
|
||||
main: '.'
|
||||
main: ./cmd/wice
|
||||
binary: wice
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
|
2
Makefile
2
Makefile
@@ -12,7 +12,7 @@ all: wice
|
||||
|
||||
wice:
|
||||
go generate ./...
|
||||
go build -o $@ -ldflags="$(LDFLAGS)" .
|
||||
go build -o $@ -ldflags="$(LDFLAGS)" ./cmd/wice
|
||||
|
||||
tests:
|
||||
ginkgo run $(GINKGO_OPTS)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
@@ -20,7 +20,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
RootCmd.AddCommand(addressesCmd)
|
||||
rootCmd.AddCommand(addressesCmd)
|
||||
}
|
||||
|
||||
func addresses(cmd *cobra.Command, args []string) {
|
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"go.uber.org/zap"
|
@@ -1,6 +1,6 @@
|
||||
//go:build test
|
||||
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
@@ -29,7 +29,7 @@ func init() {
|
||||
|
||||
cfg = config.NewConfig(pf)
|
||||
|
||||
RootCmd.AddCommand(daemonCmd)
|
||||
rootCmd.AddCommand(daemonCmd)
|
||||
}
|
||||
|
||||
func daemonCompletionArgs(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -43,7 +43,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
RootCmd.AddCommand(docsCmd)
|
||||
rootCmd.AddCommand(docsCmd)
|
||||
|
||||
docsCmd.AddCommand(docsManpageCmd)
|
||||
docsCmd.AddCommand(docsMarkdownCmd)
|
||||
@@ -60,7 +60,7 @@ func docsMarkdown(cmd *cobra.Command, args []string) error {
|
||||
return fmt.Errorf("failed to create directory: %w", err)
|
||||
}
|
||||
|
||||
return doc.GenMarkdownTree(RootCmd, dir)
|
||||
return doc.GenMarkdownTree(rootCmd, dir)
|
||||
}
|
||||
|
||||
func docsManpage(cmd *cobra.Command, args []string) error {
|
||||
@@ -83,5 +83,5 @@ func docsManpage(cmd *cobra.Command, args []string) error {
|
||||
Date: &d,
|
||||
}
|
||||
|
||||
return doc.GenManTree(RootCmd, header, dir)
|
||||
return doc.GenManTree(rootCmd, header, dir)
|
||||
}
|
@@ -2,17 +2,15 @@ package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"riasc.eu/wice/cmd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if os.Args[0] == "wg" {
|
||||
if err := cmd.WGCmd.Execute(); err != nil {
|
||||
if err := wgCmd.Execute(); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
} else {
|
||||
if err := cmd.RootCmd.Execute(); err != nil {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -22,7 +22,7 @@ var monitorCmd = &cobra.Command{
|
||||
var format config.OutputFormat
|
||||
|
||||
func init() {
|
||||
addClientCommand(RootCmd, monitorCmd)
|
||||
addClientCommand(rootCmd, monitorCmd)
|
||||
|
||||
f := monitorCmd.PersistentFlags()
|
||||
f.VarP(&format, "format", "f", fmt.Sprintf("Output `format` (one of: %s)", strings.Join(config.OutputFormatNames, ", ")))
|
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
@@ -42,7 +42,7 @@ Website:
|
||||
)
|
||||
|
||||
var (
|
||||
RootCmd = &cobra.Command{
|
||||
rootCmd = &cobra.Command{
|
||||
Use: "wice",
|
||||
Short: "ɯice",
|
||||
Long: "WireGuard Interactive Connectivity Establishment",
|
||||
@@ -63,17 +63,17 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
RootCmd.SetUsageTemplate(usageTemplate)
|
||||
rootCmd.SetUsageTemplate(usageTemplate)
|
||||
|
||||
cobra.OnInitialize(
|
||||
util.SetupRand,
|
||||
setupLogging,
|
||||
)
|
||||
|
||||
f := RootCmd.Flags()
|
||||
f := rootCmd.Flags()
|
||||
f.SortFlags = false
|
||||
|
||||
pf := RootCmd.PersistentFlags()
|
||||
pf := rootCmd.PersistentFlags()
|
||||
pf.VarP(&logLevel, "log-level", "d", "log level (one of: debug, info, warn, error, dpanic, panic, and fatal)")
|
||||
pf.StringVarP(&logFile, "log-file", "l", "", "path of a file to write logs to")
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
// derived from http://github.com/restic/restic
|
||||
|
||||
@@ -33,7 +33,7 @@ type SelfUpdateOptions struct {
|
||||
var selfUpdateOptions SelfUpdateOptions
|
||||
|
||||
func init() {
|
||||
RootCmd.AddCommand(selfUpdateCmd)
|
||||
rootCmd.AddCommand(selfUpdateCmd)
|
||||
|
||||
file, err := os.Executable()
|
||||
if err != nil {
|
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"net"
|
||||
@@ -28,7 +28,7 @@ func init() {
|
||||
pf.StringVarP(&listenAddress, "listen", "L", ":8080", "listen address")
|
||||
pf.BoolVarP(&secure, "secure", "S", false, "listen with TLS")
|
||||
|
||||
RootCmd.AddCommand(signalCmd)
|
||||
rootCmd.AddCommand(signalCmd)
|
||||
}
|
||||
|
||||
func signal(cmd *cobra.Command, args []string) {
|
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -18,7 +18,7 @@ var statusCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
func init() {
|
||||
addClientCommand(RootCmd, statusCmd)
|
||||
addClientCommand(rootCmd, statusCmd)
|
||||
}
|
||||
|
||||
func status(cmd *cobra.Command, args []string) {
|
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -16,7 +16,7 @@ var stopCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
func init() {
|
||||
addClientCommand(RootCmd, stopCmd)
|
||||
addClientCommand(rootCmd, stopCmd)
|
||||
}
|
||||
|
||||
func stop(cmd *cobra.Command, args []string) error {
|
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -19,7 +19,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
addClientCommand(RootCmd, syncCmd)
|
||||
addClientCommand(rootCmd, syncCmd)
|
||||
}
|
||||
|
||||
func sync(cmd *cobra.Command, args []string) error {
|
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
WGCmd = &cobra.Command{
|
||||
wgCmd = &cobra.Command{
|
||||
Use: "wg",
|
||||
Short: "WireGuard commands",
|
||||
Args: cobra.NoArgs,
|
||||
@@ -49,13 +49,13 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
RootCmd.AddCommand(WGCmd)
|
||||
rootCmd.AddCommand(wgCmd)
|
||||
|
||||
WGCmd.AddCommand(wgGenKeyCmd)
|
||||
WGCmd.AddCommand(wgGenPSKCmd)
|
||||
WGCmd.AddCommand(wgPubKeyCmd)
|
||||
wgCmd.AddCommand(wgGenKeyCmd)
|
||||
wgCmd.AddCommand(wgGenPSKCmd)
|
||||
wgCmd.AddCommand(wgPubKeyCmd)
|
||||
|
||||
addClientCommand(WGCmd, wgShowCmd)
|
||||
addClientCommand(wgCmd, wgShowCmd)
|
||||
}
|
||||
|
||||
func wgGenKey(cmd *cobra.Command, args []string) error {
|
@@ -1,6 +1,6 @@
|
||||
//go:build tracer
|
||||
|
||||
package cmd
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -24,7 +24,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
WGCmd.AddCommand(wgExtractHandshakesCmd)
|
||||
wgCmd.AddCommand(wgExtractHandshakesCmd)
|
||||
}
|
||||
|
||||
func wgExtractHandshakes(cmd *cobra.Command, args []string) error {
|
@@ -20,8 +20,8 @@
|
||||
# $ git clone github.com/stv0g/wice
|
||||
# $ cd wice
|
||||
# $ go generate -tags tracer
|
||||
# $ go build -tags tracer .
|
||||
#
|
||||
# $ go build -tags tracer ./cmd/wice
|
||||
# $ sudo ./wice wg
|
||||
|
||||
set -e
|
||||
|
||||
@@ -65,10 +65,8 @@ function cleanup() {
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
WICE="go run -tags tracer riasc.eu/wice"
|
||||
|
||||
echo -e "\n=== Start probing for WireGuard handshakes"
|
||||
${WICE} wg extract-handshakes 2> /dev/null > ${KEYS_FILE} &
|
||||
wice wg extract-handshakes 2> /dev/null > ${KEYS_FILE} &
|
||||
TRACER_PID=$!
|
||||
|
||||
echo -e "\n=== Start tshark capture"
|
||||
|
@@ -59,9 +59,9 @@ func BuildTestBinary(name string) (string, []any, error) {
|
||||
|
||||
// We compile a dummy go test binary here which just
|
||||
// invokes main(), but is instrumented for profiling.
|
||||
testBinaryPath, err = gexec.CompileTest("..", buildArgs...)
|
||||
testBinaryPath, err = gexec.CompileTest("../cmd/wice", buildArgs...)
|
||||
} else {
|
||||
testBinaryPath, err = gexec.Build("..", buildArgs...)
|
||||
testBinaryPath, err = gexec.Build("../cmd/wice", buildArgs...)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user