net

package
v0.0.0-...-7e1b392 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigPath         = "/config/net.conf"
	DefaultDNSTimeout  = 5
	DefaultHTTPTimeout = 30
	DefaultUserAgent   = "AvyOS/1.0"
)
View Source
const (
	TypeA     uint16 = 1
	TypeAAAA  uint16 = 28
	TypeCNAME uint16 = 5
	TypeMX    uint16 = 15
	TypeTXT   uint16 = 16
	TypeNS    uint16 = 2

	ClassIN uint16 = 1
)

DNS record types

Variables

This section is empty.

Functions

func Dial

func Dial(network, address string) (net.Conn, error)

Dial connects to the address using the default dialer

func DialTLS

func DialTLS(network, address string) (*tls.Conn, error)

DialTLS connects to the address over TLS using the default dialer

func DialTimeout

func DialTimeout(network, address string, timeout time.Duration) (net.Conn, error)

DialTimeout connects to the address with a custom timeout

func LookupHost

func LookupHost(host string) ([]string, error)

LookupHost is a convenience function using the default resolver

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a custom HTTP client

func NewClient

func NewClient() *Client

NewClient creates a new HTTP client

func (*Client) Do

func (c *Client) Do(req *Request) (*Response, error)

Do performs an HTTP request

func (*Client) Get

func (c *Client) Get(url string) (*Response, error)

Get performs an HTTP GET request

func (*Client) Post

func (c *Client) Post(url string, contentType string, body io.Reader) (*Response, error)

Post performs an HTTP POST request

type Config

type Config struct {
	DNS  DNSConfig
	HTTP HTTPConfig
	TLS  TLSConfig
}

Config holds network configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default network configuration

func GetConfig

func GetConfig() *Config

GetConfig returns the current global configuration

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads network configuration from the config file

func ReloadConfig

func ReloadConfig() (*Config, error)

ReloadConfig forces a reload of the configuration

type DNSConfig

type DNSConfig struct {
	Servers []string
	Timeout int
	Cache   bool
}

DNSConfig holds DNS resolver configuration

type DNSQuestion

type DNSQuestion struct {
	Name  string
	Type  uint16
	Class uint16
}

DNSQuestion represents a DNS question

type DNSRecord

type DNSRecord struct {
	Name  string
	Type  uint16
	Class uint16
	TTL   uint32
	Data  string
}

DNSRecord represents a DNS record

type DNSResponse

type DNSResponse struct {
	ID        uint16
	Questions []DNSQuestion
	Answers   []DNSRecord
	Authority []DNSRecord
	Extra     []DNSRecord
}

DNSResponse represents a DNS response

type Dialer

type Dialer struct {
	Timeout  time.Duration
	Resolver *Resolver
	Config   *Config
	Pool     *x509.CertPool
}

Dialer provides custom connection dialing with AvyOS DNS resolution

func NewDialer

func NewDialer() *Dialer

NewDialer creates a new Dialer with default configuration

func (*Dialer) Dial

func (d *Dialer) Dial(network, address string) (net.Conn, error)

Dial connects to the address using custom DNS resolution

func (*Dialer) DialTLS

func (d *Dialer) DialTLS(network, address string) (*tls.Conn, error)

DialTLS connects to the address over TLS using custom DNS resolution

type HTTPConfig

type HTTPConfig struct {
	UserAgent       string
	Timeout         int
	FollowRedirects bool
	MaxRedirects    int
}

HTTPConfig holds HTTP client configuration

type Request

type Request struct {
	Method  string
	URL     string
	Host    string
	Path    string
	Headers map[string]string
	Body    io.Reader
}

Request represents an HTTP request

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver is a custom DNS resolver

func DefaultResolver

func DefaultResolver() *Resolver

DefaultResolver returns the default DNS resolver

func NewResolver

func NewResolver(servers []string, timeout time.Duration, enableCache bool) *Resolver

NewResolver creates a new DNS resolver

func (*Resolver) LookupHost

func (r *Resolver) LookupHost(host string) ([]string, error)

LookupHost resolves a hostname to IP addresses

func (*Resolver) Query

func (r *Resolver) Query(name string, qtype uint16) ([]DNSRecord, error)

Query performs a DNS query

type Response

type Response struct {
	StatusCode int
	Status     string
	Headers    map[string]string
	Body       io.ReadCloser
	Request    *Request
}

Response represents an HTTP response

func Get

func Get(url string) (*Response, error)

Get performs an HTTP GET request using the default client

func Post

func Post(url string, contentType string, body io.Reader) (*Response, error)

Post performs an HTTP POST request using the default client

type TLSConfig

type TLSConfig struct {
	Verify        bool
	CertPath      string
	InsecureHosts []string
}

TLSConfig holds TLS configuration

Jump to

Keyboard shortcuts

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