IP

package
v0.0.0-...-d9f4d4e Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package IP provides methods for working with IP object instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Advanced

func Advanced() class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

func ClearCache

func ClearCache()

Removes all of a [param hostname]'s cached references. If no [param hostname] is given, all cached IP addresses are removed.

func EraseResolveItem

func EraseResolveItem(id int)

Removes a given item [param id] from the queue. This should be used to free a queue after it has completed to enable more queries to happen.

func GetLocalAddresses

func GetLocalAddresses() []string

Returns all the user's current IPv4 and IPv6 addresses as an array.

func GetResolveItemAddress

func GetResolveItemAddress(id int) string

Returns a queued hostname's IP address, given its queue [param id]. Returns an empty string on error or if resolution hasn't happened yet (see [method get_resolve_item_status]).

func GetResolveItemAddresses

func GetResolveItemAddresses(id int) []any

Returns resolved addresses, or an empty array if an error happened or resolution didn't happen yet (see [method get_resolve_item_status]).

func GetResolveItemStatus

func GetResolveItemStatus(id int) gdclass.IPResolverStatus

Returns a queued hostname's status as a [enum ResolverStatus] constant, given its queue [param id].

func ResolveHostname

func ResolveHostname(host string) string

Returns a given hostname's IPv4 or IPv6 address when resolved (blocking-type method). The address type returned depends on the [enum Type] constant given as [param ip_type].

func ResolveHostnameAddresses

func ResolveHostnameAddresses(host string) []string

Resolves a given hostname in a blocking way. Addresses are returned as an [Array] of IPv4 or IPv6 addresses depending on [param ip_type].

func ResolveHostnameQueueItem

func ResolveHostnameQueueItem(host string) int

Creates a queue item to resolve a hostname to an IPv4 or IPv6 address depending on the [enum Type] constant given as [param ip_type]. Returns the queue ID if successful, or [constant RESOLVER_INVALID_ID] on error.

Types

type LocalInterface

type LocalInterface struct {
	Index     string       `gd:"index"`
	Name      string       `gd:"name"`
	Friendly  string       `gd:"friendly"`
	Addresses []netip.Addr `gd:"addresses"`
}

func GetLocalInterfaces

func GetLocalInterfaces() []LocalInterface

Returns all network adapters as an array. Each adapter is a dictionary of the form: [codeblock]

{
    "index": "1", # Interface index.
    "name": "eth0", # Interface name.
    "friendly": "Ethernet One", # A friendly name (might be empty).
    "addresses": ["192.168.1.101"], # An array of IP addresses associated to this interface.
}

[/codeblock]

type ResolverStatus

type ResolverStatus = gdclass.IPResolverStatus //gd:IP.ResolverStatus
const (
	/*DNS hostname resolver status: No status.*/
	ResolverStatusNone ResolverStatus = 0
	/*DNS hostname resolver status: Waiting.*/
	ResolverStatusWaiting ResolverStatus = 1
	/*DNS hostname resolver status: Done.*/
	ResolverStatusDone ResolverStatus = 2
	/*DNS hostname resolver status: Error.*/
	ResolverStatusError ResolverStatus = 3
)

type Type

type Type = gdclass.IPType //gd:IP.Type
const (
	/*Address type: None.*/
	TypeNone Type = 0
	/*Address type: Internet protocol version 4 (IPv4).*/
	TypeIpv4 Type = 1
	/*Address type: Internet protocol version 6 (IPv6).*/
	TypeIpv6 Type = 2
	/*Address type: Any.*/
	TypeAny Type = 3
)

Jump to

Keyboard shortcuts

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