@ -6,14 +6,13 @@ import (
"io/fs"
"io/fs"
"path/filepath"
"path/filepath"
"hack-browser-data/internal/browingdata"
"github.com/moond4rk/HackBrowserData/browingdata"
"hack-browser-data/internal/browser"
"github.com/moond4rk/HackBrowserData/item"
"hack-browser-data/internal/item"
"github.com/moond4rk/HackBrowserData/utils/fileutil"
"hack-browser-data/internal/utils/fileutil"
"github.com/moond4rk/HackBrowserData/utils/typeutil"
"hack-browser-data/internal/utils/typeutil"
)
)
type f irefox struct {
type F irefox struct {
name string
name string
storage string
storage string
profilePath string
profilePath string
@ -24,9 +23,9 @@ type firefox struct {
var ErrProfilePathNotFound = errors . New ( "profile path not found" )
var ErrProfilePathNotFound = errors . New ( "profile path not found" )
// New returns a new f irefox instance.
// New returns a new F irefox instance.
func New ( name , storage , profilePath string , items [ ] item . Item ) ( [ ] browser . Browser , error ) {
func New ( name , storage , profilePath string , items [ ] item . Item ) ( [ ] * Firefox , error ) {
f := & f irefox{
f := & F irefox{
name : name ,
name : name ,
storage : storage ,
storage : storage ,
profilePath : profilePath ,
profilePath : profilePath ,
@ -37,10 +36,10 @@ func New(name, storage, profilePath string, items []item.Item) ([]browser.Browse
return nil , err
return nil , err
}
}
firefoxList := make ( [ ] browser . Browser , 0 , len ( multiItemPaths ) )
firefoxList := make ( [ ] * Firefox , 0 , len ( multiItemPaths ) )
for name , itemPaths := range multiItemPaths {
for name , itemPaths := range multiItemPaths {
firefoxList = append ( firefoxList , & f irefox{
firefoxList = append ( firefoxList , & F irefox{
name : fmt . Sprintf ( "f irefox-%s" , name ) ,
name : fmt . Sprintf ( "F irefox-%s" , name ) ,
items : typeutil . Keys ( itemPaths ) ,
items : typeutil . Keys ( itemPaths ) ,
itemPaths : itemPaths ,
itemPaths : itemPaths ,
} )
} )
@ -48,13 +47,13 @@ func New(name, storage, profilePath string, items []item.Item) ([]browser.Browse
return firefoxList , nil
return firefoxList , nil
}
}
func ( f * f irefox) getMultiItemPath ( profilePath string , items [ ] item . Item ) ( map [ string ] map [ item . Item ] string , error ) {
func ( f * F irefox) getMultiItemPath ( profilePath string , items [ ] item . Item ) ( map [ string ] map [ item . Item ] string , error ) {
multiItemPaths := make ( map [ string ] map [ item . Item ] string )
multiItemPaths := make ( map [ string ] map [ item . Item ] string )
err := filepath . Walk ( profilePath , firefoxWalkFunc ( items , multiItemPaths ) )
err := filepath . Walk ( profilePath , firefoxWalkFunc ( items , multiItemPaths ) )
return multiItemPaths , err
return multiItemPaths , err
}
}
func ( f * f irefox) copyItemToLocal ( ) error {
func ( f * F irefox) copyItemToLocal ( ) error {
for i , path := range f . itemPaths {
for i , path := range f . itemPaths {
filename := i . String ( )
filename := i . String ( )
if err := fileutil . CopyFile ( path , filename ) ; err != nil {
if err := fileutil . CopyFile ( path , filename ) ; err != nil {
@ -80,15 +79,15 @@ func firefoxWalkFunc(items []item.Item, multiItemPaths map[string]map[item.Item]
}
}
}
}
func ( f * f irefox) GetMasterKey ( ) ( [ ] byte , error ) {
func ( f * F irefox) GetMasterKey ( ) ( [ ] byte , error ) {
return f . masterKey , nil
return f . masterKey , nil
}
}
func ( f * f irefox) Name ( ) string {
func ( f * F irefox) Name ( ) string {
return f . name
return f . name
}
}
func ( f * f irefox) BrowsingData ( ) ( * browingdata . Data , error ) {
func ( f * F irefox) BrowsingData ( ) ( * browingdata . Data , error ) {
b := browingdata . New ( f . items )
b := browingdata . New ( f . items )
if err := f . copyItemToLocal ( ) ; err != nil {
if err := f . copyItemToLocal ( ) ; err != nil {