safecurl

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

scurl

本函数类用于安全地做HTTP请求,用于防止 SSRF(服务器端请求伪造)漏洞。

简介

函数 说明
secapi.NewSafeClient 创建安全的HTTP请求客户端(推荐)
secapi.SafeCurl 安全地发起HTTP GET请求,并返回response对象
secapi.GetSafeURL 检查传入的URL是否指向内网资源

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIp

func CheckIp(ipStr string) bool

CheckIp 检查IP地址是否合法

func GetIpByDomain

func GetIpByDomain(hostname string) (string, error)

GetIpByDomain 获取域名指向IP

func GetSafeURL

func GetSafeURL(inputUrl string, innerHosts ...string) (r string, errorReturn error)

GetSafeURL 校验URL的安全性

func InetAton

func InetAton(ipStr string) int64

InetAton IP转int64

func InetNtoa

func InetNtoa(ipnr int64) net.IP

InetNtoa int64 to IP

func IsInnerIp

func IsInnerIp(ipStr string, innerHosts ...string) bool

IsInnerIp 检查是否内网IP地址

func NewSafeClient

func NewSafeClient(innerIpv4Nets ...Ipv4Net) *http.Client

NewSafeClient 安全的HTTP请求客户端

func SafeCurl

func SafeCurl(untrustedURL string, innerIpv4Nets ...Ipv4Net) *http.Response

SafeCurl 安全地发起HTTP GET请求

Types

type Ipv4Net

type Ipv4Net struct {
	Ipv4            [4]byte
	SubnetPrefixLen int
}

Jump to

Keyboard shortcuts

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