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