util

package
v1.9.0-pre.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0, CC-BY-4.0, MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Copyright 2025 The Go MCP SDK Authors. All rights reserved. Use of this source code is governed by the license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLoopback added in v1.4.0

func IsLoopback(addr string) bool

func IsPrivateOrReserved added in v1.8.0

func IsPrivateOrReserved(ip netip.Addr) bool

IsPrivateOrReserved reports whether ip belongs to a range that must not be reachable through a server-controlled URL, as a defense against SSRF: private (RFC 1918 / RFC 4193 ULA), link-local (including the 169.254.169.254 cloud metadata endpoint), carrier-grade NAT, multicast, and the unspecified address.

func RestrictRedirects

func RestrictRedirects(c *http.Client) *http.Client

RestrictRedirects returns a copy of c, or of http.DefaultClient if c is nil, that stops after 10 requests, as net/http does by default, and follows only redirects that stay within the origin of the request they redirect and keep the method of the original request. Otherwise a server could reroute a request, with its headers and body, to another origin, or turn a POST into a bodyless GET. An upgrade from http to https on the same host, with default ports, stays within the origin.

It returns c (or http.DefaultClient) unchanged if c sets its own CheckRedirect, which then decides alone, or if the followallredirects MCPGODEBUG option is set.

func Wrapf

func Wrapf(errp *error, format string, args ...any)

Wrapf wraps *errp with the given formatted message if *errp is not nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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