Documentation ¶
Index ¶
- Constants
- Variables
- func AliyunSigner(accessKeyID, accessSecret string, params *url.Values)
- func AuthHeaderValue(signature, accessKey string, signedHeaders []string) string
- func BaiduCanonicalURI(r *http.Request) string
- func BaiduSigner(accessKeyID, accessSecret string, r *http.Request)
- func CanonicalHeaders(r *http.Request, signerHeaders []string) string
- func CanonicalQueryString(r *http.Request) string
- func CanonicalRequest(r *http.Request, signedHeaders []string) (string, error)
- func CanonicalURI(r *http.Request) string
- func CreateHTTPClient() *http.Client
- func CreateNoProxyHTTPClient(network string) *http.Client
- func GenerateToken(username string) string
- func GetConfigFilePath() string
- func GetConfigFilePathDefault() string
- func GetHTTPResponse(resp *http.Response, err error, result interface{}) error
- func GetHTTPResponseOrg(resp *http.Response, err error) ([]byte, error)
- func GetRequestIPStr(r *http.Request) (addr string)
- func HashPassword(password string) (string, error)
- func HexEncodeSHA256Hash(body []byte) (string, error)
- func HmacSha256Hex(secret, message string) string
- func HmacSign(signMethod string, httpMethod string, appKeySecret string, vals url.Values) (signature []byte)
- func HmacSignToB64(signMethod string, httpMethod string, appKeySecret string, vals url.Values) (signature string)
- func InitBackupDNS(customDNS, lang string)
- func InitLogLang(lang string) string
- func IsHashedPassword(password string) bool
- func IsPrivateNetwork(remoteAddr string) bool
- func IsRunInDocker() bool
- func Log(key string, args ...interface{})
- func LogStr(key string, args ...interface{}) string
- func LookupHost(url string) error
- func OpenExplorer(url string)
- func Ordinal(x int, lang string) string
- func PasswordOK(hashedPassword, password string) bool
- func RequestPayload(r *http.Request) ([]byte, error)
- func SetDNS(dns string)
- func SetInsecureSkipVerify()
- func SignStringToSign(stringToSign string, signingKey []byte) (string, error)
- func SignedHeaders(r *http.Request) []string
- func SplitLines(s string) []string
- func StringToSign(canonicalRequest string, t time.Time) (string, error)
- func TencentCloudSigner(secretId string, secretKey string, r *http.Request, action string, ...)
- func TrafficRouteSigner(method string, query map[string][]string, header map[string]string, ak string, ...) (*http.Request, error)
- func WaitInternet(addresses []string)
- func WriteString(strs ...string) string
- type Credentials
- type IpCache
- type RequestParam
- type SignRequest
- type Signer
Constants ¶
const ( BasicDateFormat = "20060102T150405Z" Algorithm = "SDK-HMAC-SHA256" HeaderXDate = "X-Sdk-Date" HeaderHost = "host" HeaderAuthorization = "Authorization" HeaderContentSha256 = "X-Sdk-Content-Sha256" )
const (
BaiduDateFormat = "2006-01-02T15:04:05Z"
)
const ConfigFilePathENV = "DDNS_CONFIG_FILE_PATH"
const DockerEnvFile string = "/.dockerenv"
DockerEnvFile Docker容器中包含的文件
const Host = "open.volcengineapi.com"
const IPCacheTimesENV = "DDNS_IP_CACHE_TIMES"
const Region = "cn-north-1"
const Service = "DNS"
const Version = "2018-08-01"
Variables ¶
var BackupDNS = []string{"1.1.1.1", "8.8.8.8", "9.9.9.9", "223.5.5.5"}
BackupDNS will be used if DNS error occurs.
var ForceCompareGlobal = true
Functions ¶
func AliyunSigner ¶
AliyunSigner AliyunSigner
func AuthHeaderValue ¶
Get the finalized value for the "Authorization" header. The signature parameter is the output from SignStringToSign
func BaiduCanonicalURI ¶
func BaiduSigner ¶
BaiduSigner set Authorization header
func CanonicalHeaders ¶
CanonicalHeaders
func CanonicalRequest ¶
Build a CanonicalRequest from a regular request string
CanonicalRequest =
HTTPRequestMethod + '\n' + CanonicalURI + '\n' + CanonicalQueryString + '\n' + CanonicalHeaders + '\n' + SignedHeaders + '\n' + HexEncode(Hash(RequestPayload))
func CreateHTTPClient ¶
CreateHTTPClient Create Default HTTP Client
func CreateNoProxyHTTPClient ¶
CreateNoProxyHTTPClient Create NoProxy HTTP Client
func GenerateToken ¶ added in v6.5.0
GenerateToken 生成Token
func GetConfigFilePathDefault ¶
func GetConfigFilePathDefault() string
GetConfigFilePathDefault 获得默认的配置文件路径
func GetHTTPResponse ¶
GetHTTPResponse 处理HTTP结果,返回序列化的json
func GetHTTPResponseOrg ¶
GetHTTPResponseOrg 处理HTTP结果,返回byte
func GetRequestIPStr ¶
GetRequestIPStr get IP string from request
func HashPassword ¶ added in v6.6.0
HashPassword 密码哈希
func HexEncodeSHA256Hash ¶
HexEncodeSHA256Hash returns hexcode of sha256
func HmacSha256Hex ¶
func HmacSignToB64 ¶
func InitBackupDNS ¶ added in v6.3.1
func InitBackupDNS(customDNS, lang string)
func InitLogLang ¶
func IsHashedPassword ¶ added in v6.6.0
IsHashedPassword 是否是哈希密码
func IsPrivateNetwork ¶
IsPrivateNetwork 是否为私有地址 https://en.wikipedia.org/wiki/Private_network
func LookupHost ¶ added in v6.2.0
LookupHost looks up the host based on the given URL using the dialer.Resolver. A wrapper for net.Resolver.LookupHost.
func Ordinal ¶ added in v6.2.1
Ordinal returns the ordinal format of the given number.
See also: https://github.com/dustin/go-humanize/blob/master/ordinals.go
func PasswordOK ¶ added in v6.6.0
PasswordOK 检查密码
func SetDNS ¶ added in v6.2.0
func SetDNS(dns string)
SetDNS sets the dialer.Resolver to use the given DNS server.
func SetInsecureSkipVerify ¶
func SetInsecureSkipVerify()
SetInsecureSkipVerify 将所有 http.Transport 的 InsecureSkipVerify 设置为 true
func SignStringToSign ¶
Create the HWS Signature.
func SplitLines ¶ added in v6.2.2
SplitLines splits a string into lines by '\r\n' or '\n'.
func StringToSign ¶
Create a "String to Sign".
func TencentCloudSigner ¶
func TencentCloudSigner(secretId string, secretKey string, r *http.Request, action string, payload string)
TencentCloudSigner 腾讯云签名方法 v3 https://cloud.tencent.com/document/api/1427/56189#Golang
func TrafficRouteSigner ¶ added in v6.7.0
func TrafficRouteSigner(method string, query map[string][]string, header map[string]string, ak string, sk string, action string, body []byte) (*http.Request, error)
第三步:创建一个 DNS 的 API 请求函数。签名计算的过程包含在该函数中。
func WaitInternet ¶ added in v6.3.0
func WaitInternet(addresses []string)
Wait blocks until the Internet is connected.
See also:
func WriteString ¶
WriteString creates a new string using strings.Builder.
Types ¶
type Credentials ¶ added in v6.7.0
身份证明结构体
type RequestParam ¶ added in v6.7.0
type RequestParam struct { Body []byte Method string Date time.Time Path string Host string QueryList url.Values }
第二步:准备需要用到的结构体定义。 签算请求结构体
Source Files ¶
- aliyun_signer.go
- aliyun_signer_util.go
- baidu_signer.go
- bcrypt.go
- docker_util.go
- escape.go
- http_client_util.go
- http_util.go
- huawei_signer.go
- ip_cache.go
- messages.go
- net.go
- net_resolver.go
- open_explorer.go
- ordinal.go
- string.go
- tencent_cloud_signer.go
- termux.go
- token.go
- traffic_route_signer.go
- user.go
- wait_internet.go