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) <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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=
|
||||
@@ -0,0 +1,2 @@
|
||||
// Package app wires the Wails application (Go ↔ JS bindings).
|
||||
package app
|
||||
@@ -0,0 +1,2 @@
|
||||
// Package bypass implements DPI bypass via fake QUIC injection.
|
||||
package bypass
|
||||
@@ -0,0 +1,2 @@
|
||||
// Package checker runs the 7-step proxy diagnostic.
|
||||
package checker
|
||||
@@ -0,0 +1,2 @@
|
||||
// Package config loads and validates the TOML configuration.
|
||||
package config
|
||||
@@ -0,0 +1,2 @@
|
||||
// Package divert wraps WinDivert for kernel-level packet capture.
|
||||
package divert
|
||||
@@ -0,0 +1,2 @@
|
||||
// Package engine orchestrates the packet processing pipeline.
|
||||
package engine
|
||||
@@ -0,0 +1,2 @@
|
||||
// Package procscan resolves process IDs via Toolhelp32.
|
||||
package procscan
|
||||
@@ -0,0 +1,2 @@
|
||||
// Package service installs the Windows service and exposes the IPC named pipe.
|
||||
package service
|
||||
@@ -0,0 +1,2 @@
|
||||
// Package socks5 implements a SOCKS5 client (CONNECT + UDP ASSOCIATE, RFC 1928 + 1929).
|
||||
package socks5
|
||||
@@ -0,0 +1,2 @@
|
||||
// Package tray manages the system tray icon.
|
||||
package tray
|
||||
@@ -0,0 +1,2 @@
|
||||
// Package updater performs self-update via the Forgejo Releases API.
|
||||
package updater
|
||||
Vendored
Vendored
Reference in New Issue
Block a user