-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
71 lines (58 loc) · 1.38 KB
/
main.go
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
68
69
70
71
package main
import (
"log"
"os"
"github.com/Showmax/go-fqdn"
"github.com/arnested/sshfpgo/internal/providers"
// Blank import to let dnsimple register it self.
_ "github.com/arnested/sshfpgo/internal/providers/dnsimple"
"github.com/arnested/sshfpgo/internal/sshkeygen"
"github.com/urfave/cli/v2"
)
// Version string to be set at compile time via command line (-ldflags "-X main.version=1.2.3").
var (
version string
)
func main() {
defaultHostname := fqdn.Get()
app := cli.NewApp()
app.Name = "sshfpgo"
app.Usage = "Update SSHFP DNS records"
app.EnableBashCompletion = true
app.Authors = []*cli.Author{
{
Name: "Arne Jørgensen",
Email: "arne@arnested.dk",
},
}
app.Version = version
app.Flags = []cli.Flag{
&cli.BoolFlag{
Name: "verbose",
Usage: "Verbose output",
},
&cli.BoolFlag{
Name: "dry-run",
Usage: "Do no updates",
},
&cli.StringFlag{
Name: "hostname",
Usage: "The `HOSTNAME` to update records for",
Value: defaultHostname,
},
}
app.Before = func(c *cli.Context) error {
sshkeygen.Collect(c.String("hostname"))
if c.Bool("verbose") && len(sshkeygen.SshfpRecords) == 0 {
log.Printf("No SSH host keys found.\n")
}
return nil
}
for _, provider := range providers.Providers {
provider := provider()
app.Commands = append(app.Commands, &provider)
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}