1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
diff --git a/cmd/tailproxy/args.gen.go b/cmd/tailproxy/args.gen.go
new file mode 100644
index 0000000000000000000000000000000000000000..c15baafe5bd27436a6b2aa05afaa9b1949b7bf3a
--- /dev/null
+++ b/cmd/tailproxy/args.gen.go
@@ -0,0 +1,61 @@
+// Code generated by gen from schema.cue; DO NOT EDIT.
+
+package main
+
+import (
+ "errors"
+ "flag"
+ "fmt"
+)
+
+type cliArgs struct {
+ // Tailscale hostname
+ Hostname string
+ // Tailscale one-time auth key
+ AuthKey string
+ // Path to a file containing a Tailscale auth key (takes precedence over auth-key)
+ AuthKeyFile string
+ // Expose on Tailscale funnel
+ Funnel bool
+ // tsnet data directory
+ DataDir string
+ // Host to proxy
+ Host string
+ // Port to proxy
+ Port int
+}
+
+// defaultArgs returns the defaults from schema.cue.
+func defaultArgs() cliArgs {
+ return cliArgs{
+ DataDir: ".tailproxy",
+ Host: "localhost",
+ }
+}
+
+// registerFlags defines a flag for every field of c, using c's current
+// values as flag defaults.
+func registerFlags(fs *flag.FlagSet, c *cliArgs) {
+ fs.StringVar(&c.Hostname, "hostname", c.Hostname, "Tailscale hostname")
+ fs.StringVar(&c.AuthKey, "auth-key", c.AuthKey, "Tailscale one-time auth key")
+ fs.StringVar(&c.AuthKeyFile, "auth-key-file", c.AuthKeyFile, "Path to a file containing a Tailscale auth key (takes precedence over auth-key)")
+ fs.BoolVar(&c.Funnel, "funnel", c.Funnel, "Expose on Tailscale funnel")
+ fs.StringVar(&c.DataDir, "data-dir", c.DataDir, "tsnet data directory")
+ fs.StringVar(&c.Host, "host", c.Host, "Host to proxy")
+ fs.IntVar(&c.Port, "port", c.Port, "Port to proxy")
+}
+
+// validate checks c against the constraints in schema.cue.
+func (c *cliArgs) validate() error {
+ var errs []error
+ if c.DataDir == "" {
+ errs = append(errs, errors.New("data-dir: must not be empty"))
+ }
+ if c.Port < 1 {
+ errs = append(errs, fmt.Errorf("port: must be >= 1, got %v", c.Port))
+ }
+ if c.Port > 65535 {
+ errs = append(errs, fmt.Errorf("port: must be <= 65535, got %v", c.Port))
+ }
+ return errors.Join(errs...)
+}
|