mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2025-11-21 00:53:44 -08:00
fix naming from fluxxmpp to fluuxmpp
This commit is contained in:
committed by
Mickaël Rémond
parent
76f59be5ed
commit
6e65ba2a0b
41
cmd/fluuxmpp/check.go
Normal file
41
cmd/fluuxmpp/check.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/bdlm/log"
|
||||
"github.com/spf13/cobra"
|
||||
"gosrc.io/xmpp"
|
||||
)
|
||||
|
||||
var domain = ""
|
||||
var cmdCheck = &cobra.Command{
|
||||
Use: "check <host[:port]>",
|
||||
Short: "is a command-line to check if you XMPP TLS certificate is valid and warn you before it expires",
|
||||
Example: "fluuxmpp check chat.sum7.eu:5222 --domain meckerspace.de",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
runCheck(args[0], domain)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
cmdRoot.AddCommand(cmdCheck)
|
||||
cmdCheck.Flags().StringVarP(&domain, "domain", "d", "", "domain if host handle multiple domains")
|
||||
}
|
||||
|
||||
func runCheck(address, domain string) {
|
||||
logger := log.WithFields(map[string]interface{}{
|
||||
"address": address,
|
||||
"domain": domain,
|
||||
})
|
||||
client, err := xmpp.NewChecker(address, domain)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal("Error: ", err)
|
||||
}
|
||||
|
||||
if err = client.Check(); err != nil {
|
||||
logger.Fatal("Failed connection check: ", err)
|
||||
}
|
||||
|
||||
logger.Println("All checks passed")
|
||||
}
|
||||
Reference in New Issue
Block a user