github.com/qjfoidnh/BaiduPCS-Go@v0.0.0-20231011165705-caa18a3765f3/baidupcs/internal/panhome/panhome.go (about) 1 package panhome 2 3 import ( 4 "github.com/qjfoidnh/BaiduPCS-Go/baidupcs/expires" 5 "github.com/qjfoidnh/BaiduPCS-Go/requester" 6 "net/url" 7 ) 8 9 const ( 10 // OperationSignature signature 11 OperationSignature = "signature" 12 ) 13 14 var ( 15 panBaiduComURL = &url.URL{ 16 Scheme: "https", 17 Host: "pan.baidu.com", 18 } 19 // PanHomeUserAgent PanHome User-Agent 20 PanHomeUserAgent = "Mozilla/5.0" 21 ) 22 23 type ( 24 PanHome struct { 25 client *requester.HTTPClient 26 ua string 27 bduss string 28 29 sign1, sign3 []rune 30 timestamp string 31 32 signRes SignRes 33 signExpires expires.Expires 34 } 35 ) 36 37 func NewPanHome(client *requester.HTTPClient) *PanHome { 38 ph := PanHome{} 39 if client != nil { 40 newC := *client 41 ph.client = &newC 42 } 43 return &ph 44 } 45 46 func (ph *PanHome) lazyInit() { 47 if ph.client == nil { 48 ph.client = requester.NewHTTPClient() 49 } 50 }