From 0acbc83e40b34723f50179d126058b6a32366125 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 1 May 2026 00:10:30 +0300 Subject: [PATCH] Add directory skeleton and CLI entry point with Cobra - Create internal/{app,config,engine,divert,socks5,bypass,checker,service,tray,procscan,updater} with placeholder doc.go per package. - Add .gitkeep stubs for internal/frontend, third_party/{windivert,icons}, installer/, .forgejo/workflows/, docs/. - Implement cmd/drover/main.go: Cobra root with Version/Commit/BuildDate ldflags, --config global flag, and stub subcommands (check, update --check-only, service install/uninstall/start/stop). - Add github.com/spf13/cobra v1.10.2 dependency. Co-Authored-By: Claude Opus 4.7 (1M context) --- .forgejo/workflows/.gitkeep | 0 cmd/drover/main.go | 93 ++++++++++++++++++++++++++++++++++ docs/.gitkeep | 0 go.mod | 7 +++ go.sum | 10 ++++ installer/.gitkeep | 0 internal/app/doc.go | 2 + internal/bypass/doc.go | 2 + internal/checker/doc.go | 2 + internal/config/doc.go | 2 + internal/divert/doc.go | 2 + internal/engine/doc.go | 2 + internal/frontend/.gitkeep | 0 internal/procscan/doc.go | 2 + internal/service/doc.go | 2 + internal/socks5/doc.go | 2 + internal/tray/doc.go | 2 + internal/updater/doc.go | 2 + third_party/icons/.gitkeep | 0 third_party/windivert/.gitkeep | 0 20 files changed, 132 insertions(+) create mode 100644 .forgejo/workflows/.gitkeep create mode 100644 cmd/drover/main.go create mode 100644 docs/.gitkeep create mode 100644 go.sum create mode 100644 installer/.gitkeep create mode 100644 internal/app/doc.go create mode 100644 internal/bypass/doc.go create mode 100644 internal/checker/doc.go create mode 100644 internal/config/doc.go create mode 100644 internal/divert/doc.go create mode 100644 internal/engine/doc.go create mode 100644 internal/frontend/.gitkeep create mode 100644 internal/procscan/doc.go create mode 100644 internal/service/doc.go create mode 100644 internal/socks5/doc.go create mode 100644 internal/tray/doc.go create mode 100644 internal/updater/doc.go create mode 100644 third_party/icons/.gitkeep create mode 100644 third_party/windivert/.gitkeep diff --git a/.forgejo/workflows/.gitkeep b/.forgejo/workflows/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/cmd/drover/main.go b/cmd/drover/main.go new file mode 100644 index 0000000..b855e92 --- /dev/null +++ b/cmd/drover/main.go @@ -0,0 +1,93 @@ +// Command drover is the entry point for the Discord proxy CLI. +package main + +import ( + "fmt" + "os" + + "github.com/spf13/cobra" +) + +// Build-time variables, populated via -ldflags "-X main.Version=... -X main.Commit=... -X main.BuildDate=...". +var ( + Version = "dev" + Commit = "dev" + BuildDate = "dev" +) + +// configPath is the path to the TOML config file, set via the --config global flag. +// Reserved for use in later phases. +var configPath string + +func main() { + if err := newRootCmd().Execute(); err != nil { + // Cobra already prints the error; just exit non-zero. + os.Exit(1) + } +} + +func newRootCmd() *cobra.Command { + root := &cobra.Command{ + Use: "drover", + Short: "Discord proxy via SOCKS5 + WinDivert", + Version: fmt.Sprintf("%s (commit %s, built %s)", Version, Commit, BuildDate), + SilenceUsage: true, + SilenceErrors: false, + } + + // Custom version template: "drover-go vX.Y.Z (commit abc1234, built 2026-05-01)". + root.SetVersionTemplate(fmt.Sprintf("drover-go v%s (commit %s, built %s)\n", Version, Commit, BuildDate)) + + root.PersistentFlags().StringVar(&configPath, "config", "", "path to TOML config file (reserved)") + + root.AddCommand(newCheckCmd()) + root.AddCommand(newUpdateCmd()) + root.AddCommand(newServiceCmd()) + + return root +} + +func newCheckCmd() *cobra.Command { + return &cobra.Command{ + Use: "check", + Short: "Run the 7-step proxy diagnostic", + RunE: func(cmd *cobra.Command, args []string) error { + fmt.Fprintln(cmd.OutOrStdout(), "TODO: 7-step diagnostic") + return nil + }, + } +} + +func newUpdateCmd() *cobra.Command { + var checkOnly bool + cmd := &cobra.Command{ + Use: "update", + Short: "Self-update via the Forgejo Releases API", + RunE: func(cmd *cobra.Command, args []string) error { + fmt.Fprintln(cmd.OutOrStdout(), "TODO: update check") + _ = checkOnly // wired up for the upcoming implementation + return nil + }, + } + cmd.Flags().BoolVar(&checkOnly, "check-only", false, "only check for an update, do not apply") + return cmd +} + +func newServiceCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "service", + Short: "Manage the drover Windows service", + } + for _, name := range []string{"install", "uninstall", "start", "stop"} { + name := name + cmd.AddCommand(&cobra.Command{ + Use: name, + Short: fmt.Sprintf("%s the drover Windows service", name), + RunE: func(cmd *cobra.Command, args []string) error { + fmt.Fprintf(cmd.OutOrStdout(), "TODO: service %s\n", name) + return nil + }, + }) + } + return cmd +} diff --git a/docs/.gitkeep b/docs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/go.mod b/go.mod index bcb0fe2..e57c872 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,10 @@ module git.okcu.io/root/drover-go go 1.23 + +require github.com/spf13/cobra v1.10.2 + +require ( + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/spf13/pflag v1.0.9 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..a6ee3e0 --- /dev/null +++ b/go.sum @@ -0,0 +1,10 @@ +github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= +github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= +github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY= +github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/installer/.gitkeep b/installer/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/internal/app/doc.go b/internal/app/doc.go new file mode 100644 index 0000000..16b506d --- /dev/null +++ b/internal/app/doc.go @@ -0,0 +1,2 @@ +// Package app wires the Wails application (Go ↔ JS bindings). +package app diff --git a/internal/bypass/doc.go b/internal/bypass/doc.go new file mode 100644 index 0000000..eb5ce30 --- /dev/null +++ b/internal/bypass/doc.go @@ -0,0 +1,2 @@ +// Package bypass implements DPI bypass via fake QUIC injection. +package bypass diff --git a/internal/checker/doc.go b/internal/checker/doc.go new file mode 100644 index 0000000..d296802 --- /dev/null +++ b/internal/checker/doc.go @@ -0,0 +1,2 @@ +// Package checker runs the 7-step proxy diagnostic. +package checker diff --git a/internal/config/doc.go b/internal/config/doc.go new file mode 100644 index 0000000..058e6e5 --- /dev/null +++ b/internal/config/doc.go @@ -0,0 +1,2 @@ +// Package config loads and validates the TOML configuration. +package config diff --git a/internal/divert/doc.go b/internal/divert/doc.go new file mode 100644 index 0000000..a3a2a7e --- /dev/null +++ b/internal/divert/doc.go @@ -0,0 +1,2 @@ +// Package divert wraps WinDivert for kernel-level packet capture. +package divert diff --git a/internal/engine/doc.go b/internal/engine/doc.go new file mode 100644 index 0000000..48d136d --- /dev/null +++ b/internal/engine/doc.go @@ -0,0 +1,2 @@ +// Package engine orchestrates the packet processing pipeline. +package engine diff --git a/internal/frontend/.gitkeep b/internal/frontend/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/internal/procscan/doc.go b/internal/procscan/doc.go new file mode 100644 index 0000000..9879081 --- /dev/null +++ b/internal/procscan/doc.go @@ -0,0 +1,2 @@ +// Package procscan resolves process IDs via Toolhelp32. +package procscan diff --git a/internal/service/doc.go b/internal/service/doc.go new file mode 100644 index 0000000..d8cd8db --- /dev/null +++ b/internal/service/doc.go @@ -0,0 +1,2 @@ +// Package service installs the Windows service and exposes the IPC named pipe. +package service diff --git a/internal/socks5/doc.go b/internal/socks5/doc.go new file mode 100644 index 0000000..6ea1863 --- /dev/null +++ b/internal/socks5/doc.go @@ -0,0 +1,2 @@ +// Package socks5 implements a SOCKS5 client (CONNECT + UDP ASSOCIATE, RFC 1928 + 1929). +package socks5 diff --git a/internal/tray/doc.go b/internal/tray/doc.go new file mode 100644 index 0000000..a31c301 --- /dev/null +++ b/internal/tray/doc.go @@ -0,0 +1,2 @@ +// Package tray manages the system tray icon. +package tray diff --git a/internal/updater/doc.go b/internal/updater/doc.go new file mode 100644 index 0000000..b76d752 --- /dev/null +++ b/internal/updater/doc.go @@ -0,0 +1,2 @@ +// Package updater performs self-update via the Forgejo Releases API. +package updater diff --git a/third_party/icons/.gitkeep b/third_party/icons/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/third_party/windivert/.gitkeep b/third_party/windivert/.gitkeep new file mode 100644 index 0000000..e69de29