-
Notifications
You must be signed in to change notification settings - Fork 0
/
edge.go
58 lines (50 loc) · 1.72 KB
/
edge.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Edge Browser shared text cookies with IE up to Fall Creators Update 1709 of Windows 10.
// After that cookies were store in the ESE database WebCacheV01.dat up to Edge v44.
// Currently cookies are stored in the same way as the Chrome browser stores them.
package edge
import (
"net/http"
"os"
"github.com/dvgamerr-app/go-kooky"
"github.com/dvgamerr-app/go-kooky/internal/chrome"
"github.com/dvgamerr-app/go-kooky/internal/cookies"
"github.com/dvgamerr-app/go-kooky/internal/ie"
)
func ReadCookies(filename string, filters ...kooky.Filter) ([]*kooky.Cookie, error) {
s, err := cookieStore(filename, filters...)
if err != nil {
return nil, err
}
defer s.Close()
return s.ReadCookies(filters...)
}
// CookieJar returns an initiated http.CookieJar based on the cookies stored by
// the Edge browser. Set cookies are memory stored and do not modify any
// browser files.
func CookieJar(filename string, filters ...kooky.Filter) (http.CookieJar, error) {
j, err := cookieStore(filename, filters...)
if err != nil {
return nil, err
}
defer j.Close()
if err := j.InitJar(); err != nil {
return nil, err
}
return j, nil
}
// CookieStore has to be closed with CookieStore.Close() after use.
func CookieStore(filename string, filters ...kooky.Filter) (kooky.CookieStore, error) {
return cookieStore(filename, filters...)
}
func cookieStore(filename string, filters ...kooky.Filter) (*cookies.CookieJar, error) {
m := map[string]func(f *os.File, s *ie.CookieStore, browser string){
`sqlite`: func(f *os.File, s *ie.CookieStore, browser string) {
f.Close()
c := &chrome.CookieStore{}
c.FileNameStr = filename
c.BrowserStr = `edge`
s.CookieStore = c
},
}
return ie.GetCookieStore(filename, `edge`, m, filters...)
}