netutils

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: MIT Imports: 16 Imported by: 0

README

Gadget Network Utilities Plugin

This is a Gadget plugin that allows Gadget to perform various network utility functions.

Note that Gadget -- and therefore any plugin for Gadget -- is still very much a work in progress, so please don't use it in production yet (or if you do, don't complain).

How do I use this plugin?

In your main.go for using Gadget, your main() function should instruct you bot, which is created using gadget.Setup() needs to be instructed to Router.AddMentionRoutes(netutils.GetMentionRoutes()). This usually looks like this:

package main

import (
	gadget "github.com/gadget-bot/gadget/core"
	netutils "github.com/gadget-bot/gadget-plugin-netutils"
)

func main() {
	// This is the Gadget bot
	myBot := gadget.Setup()

	// Add your custom plugins here
	myBot.Router.AddMentionRoutes(netutils.GetMentionRoutes())

	// This launches your bot
	myBot.Run()
}

What can this plugin do?

In your chat, you can perform the following actions:

  • whois <DOMAIN|IP|ASN> - Queries public WHOIS for the given object.
    • Parameters:
      • <DOMAIN|IP|ASN> either a domain name, an IP address, or an ASN.
  • hping [get|post|head] URL [COUNT] [INTERVAL(s|ms)] - Performs an HTTP request to the given URL with some optional parameters.
    • Parameters:
      • [get|post|head] - optional Allows specificy the HTTP Request Type (default: get)
        • URL - The HTTP or HTTPS URL
        • [COUNT] - optional The number of times to attempt the "ping" (default: 3)
        • [INTERVAL(s|ms)] - optional The time to wait, in either seconds (s) or milliseconds (ms), between requests (default: 2s)
    • Notes:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMentionRoutes

func GetMentionRoutes() []router.MentionRoute

GetMentionRoutes is used to retrieve all Mention Routes from this plugin

Types

type HTTPPing

type HTTPPing struct {
	TLSSkipVerify bool
	// contains filtered or unexported fields
}

HTTPPing stores information about each HTTP request

func (HTTPPing) IPVersion

func (p HTTPPing) IPVersion(t string) string

IPVersion determines the IP version (IPv4 or IPv6) for a request

func (*HTTPPing) Ping

func (p *HTTPPing) Ping() (HTTPResult, error)

Ping performs the actual HTTP request

type HTTPResult

type HTTPResult struct {
	StatusCode int
	TotalTime  float64
	Size       int
	Proto      string
	Server     string
	Status     string
	Trace      HTTPTrace
}

HTTPResult contains information about a particular HTTP response

type HTTPTrace

type HTTPTrace struct {
	ConnectionTime  float64
	TimeToFirstByte float64
}

HTTPTrace contains tracing data about HTTP responses

Jump to

Keyboard shortcuts

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