host

package
v0.81.0-dev-3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:     "host",
	Short:   "host command behind the cloudflare proxy",
	Aliases: []string{"h"},
	Args:    cobra.ExactArgs(1),
	Run: func(c *cobra.Command, args []string) {
		host := args[0]

		api, err := cloudflare.NewWithAPIToken(os.Getenv("CLOUDFLARE_API_TOKEN"))
		if err != nil {
			log.Fatal(err)
		}

		ctx := context.Background()

		zoneID, err := api.ZoneIDByName(host)
		if err != nil {
			log.Fatal(err)
		}

		records, _, err := api.ListDNSRecords(
			ctx,
			cloudflare.ZoneIdentifier(zoneID),
			cloudflare.ListDNSRecordsParams{},
		)
		if err != nil {
			log.Fatal(err)
		}

		table := tablewriter.NewWriter(os.Stdout)
		table.SetBorder(false)
		table.SetHeader([]string{
			"Name",
			"Type",
			"Value",
		})
		for _, record := range records {
			if FlagAll || record.Name == host {
				table.Append([]string{br(record.Name, 30), record.Type, br(record.Content, 60)})
			}
		}
		table.Render()
	},
}
View Source
var FlagAll bool
View Source
var FlagNoBr bool

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL