clientip

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package clientip provides client IP extraction utilities. 客户端 IP 提取工具。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromRemote

func FromRemote(remoteAddr string) (netip.Addr, bool)

FromRemote parses IP from remote address string. FromRemote 从远程地址字符串解析 IP。

func FromRequest

func FromRequest(r *http.Request, opts Options) (netip.Addr, bool)

FromRequest extracts client IP using the provided trust policy. FromRequest 按传入的信任策略提取客户端 IP。

Example / 示例:

ip, ok := clientip.FromRequest(r, clientip.Options{})

Types

type Options

type Options struct {
	TrustedProxies []netip.Prefix
}

Options controls whether forwarded headers may be trusted. Options 控制是否允许信任转发头。

Jump to

Keyboard shortcuts

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