From 87a026a13e3bc3122b1e5fe7bff74f2f971bfd4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=8D=E1=B4=8F=E1=B4=8F=C9=B4D4=CA=80=E1=B4=8B?= Date: Sat, 2 Apr 2022 16:59:34 +0800 Subject: [PATCH] refactor: format project layout --- cmd/cmd.go | 2 +- internal/browser/browser.go | 2 +- internal/browser/browser_test.go | 2 +- internal/browser/chromium/chromium.go | 2 +- internal/browser/firefox/firefox.go | 2 +- internal/{browser => }/data/bookmark.go | 0 internal/{browser => }/data/browsingdata.go | 0 internal/{browser => }/data/cookie.go | 1 + internal/{browser => }/data/creditcard.go | 1 + internal/{browser => }/data/download.go | 1 + internal/{browser => }/data/history.go | 1 + internal/{browser => }/data/password.go | 1 + internal/item/item.go | 84 +++++++++---------- internal/{browser => }/outputter/outputter.go | 2 +- 14 files changed, 53 insertions(+), 48 deletions(-) rename internal/{browser => }/data/bookmark.go (100%) rename internal/{browser => }/data/browsingdata.go (100%) rename internal/{browser => }/data/cookie.go (99%) rename internal/{browser => }/data/creditcard.go (99%) rename internal/{browser => }/data/download.go (99%) rename internal/{browser => }/data/history.go (99%) rename internal/{browser => }/data/password.go (99%) rename internal/{browser => }/outputter/outputter.go (97%) diff --git a/cmd/cmd.go b/cmd/cmd.go index 0630b02..ec484f8 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -8,8 +8,8 @@ import ( "github.com/urfave/cli/v2" "hack-browser-data/internal/browser" - "hack-browser-data/internal/browser/outputter" "hack-browser-data/internal/log" + "hack-browser-data/internal/outputter" ) var ( diff --git a/internal/browser/browser.go b/internal/browser/browser.go index 7d5b7cc..d520b8d 100644 --- a/internal/browser/browser.go +++ b/internal/browser/browser.go @@ -4,7 +4,7 @@ import ( "os" "strings" - "hack-browser-data/internal/browser/data" + "hack-browser-data/internal/data" ) type Browser interface { diff --git a/internal/browser/browser_test.go b/internal/browser/browser_test.go index a9965d7..4fbab5d 100644 --- a/internal/browser/browser_test.go +++ b/internal/browser/browser_test.go @@ -4,8 +4,8 @@ import ( "fmt" "testing" - "hack-browser-data/internal/browser/outputter" "hack-browser-data/internal/log" + "hack-browser-data/internal/outputter" ) func TestPickChromium(t *testing.T) { diff --git a/internal/browser/chromium/chromium.go b/internal/browser/chromium/chromium.go index 874b673..ae87642 100644 --- a/internal/browser/chromium/chromium.go +++ b/internal/browser/chromium/chromium.go @@ -8,7 +8,7 @@ import ( "path/filepath" "strings" - "hack-browser-data/internal/browser/data" + "hack-browser-data/internal/data" "hack-browser-data/internal/item" ) diff --git a/internal/browser/firefox/firefox.go b/internal/browser/firefox/firefox.go index 12a22da..2a0d42a 100644 --- a/internal/browser/firefox/firefox.go +++ b/internal/browser/firefox/firefox.go @@ -9,7 +9,7 @@ import ( "path/filepath" "strings" - "hack-browser-data/internal/browser/data" + "hack-browser-data/internal/data" "hack-browser-data/internal/item" ) diff --git a/internal/browser/data/bookmark.go b/internal/data/bookmark.go similarity index 100% rename from internal/browser/data/bookmark.go rename to internal/data/bookmark.go diff --git a/internal/browser/data/browsingdata.go b/internal/data/browsingdata.go similarity index 100% rename from internal/browser/data/browsingdata.go rename to internal/data/browsingdata.go diff --git a/internal/browser/data/cookie.go b/internal/data/cookie.go similarity index 99% rename from internal/browser/data/cookie.go rename to internal/data/cookie.go index 7b3dd83..c3f098e 100644 --- a/internal/browser/data/cookie.go +++ b/internal/data/cookie.go @@ -6,6 +6,7 @@ import ( "sort" "hack-browser-data/internal/browser/item" + "hack-browser-data/internal/decrypter" "hack-browser-data/internal/utils" diff --git a/internal/browser/data/creditcard.go b/internal/data/creditcard.go similarity index 99% rename from internal/browser/data/creditcard.go rename to internal/data/creditcard.go index a8b386c..10085d8 100644 --- a/internal/browser/data/creditcard.go +++ b/internal/data/creditcard.go @@ -7,6 +7,7 @@ import ( _ "github.com/mattn/go-sqlite3" "hack-browser-data/internal/browser/item" + "hack-browser-data/internal/decrypter" ) diff --git a/internal/browser/data/download.go b/internal/data/download.go similarity index 99% rename from internal/browser/data/download.go rename to internal/data/download.go index 1ae6995..debadb5 100644 --- a/internal/browser/data/download.go +++ b/internal/data/download.go @@ -9,6 +9,7 @@ import ( "github.com/tidwall/gjson" "hack-browser-data/internal/browser/item" + "hack-browser-data/internal/utils" _ "github.com/mattn/go-sqlite3" diff --git a/internal/browser/data/history.go b/internal/data/history.go similarity index 99% rename from internal/browser/data/history.go rename to internal/data/history.go index 1cc4d4c..3f0c5de 100644 --- a/internal/browser/data/history.go +++ b/internal/data/history.go @@ -6,6 +6,7 @@ import ( "sort" "hack-browser-data/internal/browser/item" + "hack-browser-data/internal/utils" _ "github.com/mattn/go-sqlite3" diff --git a/internal/browser/data/password.go b/internal/data/password.go similarity index 99% rename from internal/browser/data/password.go rename to internal/data/password.go index f8e55f0..1de6742 100644 --- a/internal/browser/data/password.go +++ b/internal/data/password.go @@ -10,6 +10,7 @@ import ( "time" "hack-browser-data/internal/browser/item" + decrypter2 "hack-browser-data/internal/decrypter" "hack-browser-data/internal/utils" diff --git a/internal/item/item.go b/internal/item/item.go index 79f3933..30bb101 100644 --- a/internal/item/item.go +++ b/internal/item/item.go @@ -1,34 +1,7 @@ package item import ( - "hack-browser-data/internal/browser/data" -) - -type Item int - -const ( - ChromiumKey Item = iota - ChromiumPassword - ChromiumCookie - ChromiumBookmark - ChromiumHistory - ChromiumDownload - ChromiumCreditCard - ChromiumLocalStorage - ChromiumExtension - - YandexPassword - YandexCreditCard - - FirefoxKey4 - FirefoxPassword - FirefoxCookie - FirefoxBookmark - FirefoxHistory - FirefoxDownload - FirefoxCreditCard - FirefoxLocalStorage - FirefoxExtension + data2 "hack-browser-data/internal/data" ) var DefaultFirefox = []Item{ @@ -67,6 +40,33 @@ var DefaultChromium = []Item{ ChromiumExtension, } +type Item int + +const ( + ChromiumKey Item = iota + ChromiumPassword + ChromiumCookie + ChromiumBookmark + ChromiumHistory + ChromiumDownload + ChromiumCreditCard + ChromiumLocalStorage + ChromiumExtension + + YandexPassword + YandexCreditCard + + FirefoxKey4 + FirefoxPassword + FirefoxCookie + FirefoxBookmark + FirefoxHistory + FirefoxDownload + FirefoxCreditCard + FirefoxLocalStorage + FirefoxExtension +) + func (i Item) FileName() string { switch i { case ChromiumKey: @@ -161,40 +161,40 @@ func (i Item) String() string { } } -func (i Item) NewBrowsingData() data.BrowsingData { +func (i Item) NewBrowsingData() data2.BrowsingData { switch i { case ChromiumKey: return nil case ChromiumPassword: - return &data.ChromiumPassword{} + return &data2.ChromiumPassword{} case ChromiumCookie: - return &data.ChromiumCookie{} + return &data2.ChromiumCookie{} case ChromiumBookmark: - return &data.ChromiumBookmark{} + return &data2.ChromiumBookmark{} case ChromiumDownload: - return &data.ChromiumDownload{} + return &data2.ChromiumDownload{} case ChromiumLocalStorage: return nil case ChromiumCreditCard: - return &data.ChromiumCreditCard{} + return &data2.ChromiumCreditCard{} case ChromiumExtension: return nil case ChromiumHistory: - return &data.ChromiumHistory{} + return &data2.ChromiumHistory{} case YandexPassword: - return &data.ChromiumPassword{} + return &data2.ChromiumPassword{} case YandexCreditCard: - return &data.ChromiumCreditCard{} + return &data2.ChromiumCreditCard{} case FirefoxPassword: - return &data.FirefoxPassword{} + return &data2.FirefoxPassword{} case FirefoxCookie: - return &data.FirefoxCookie{} + return &data2.FirefoxCookie{} case FirefoxBookmark: - return &data.FirefoxBookmark{} + return &data2.FirefoxBookmark{} case FirefoxDownload: - return &data.FirefoxDownload{} + return &data2.FirefoxDownload{} case FirefoxHistory: - return &data.FirefoxHistory{} + return &data2.FirefoxHistory{} default: return nil } diff --git a/internal/browser/outputter/outputter.go b/internal/outputter/outputter.go similarity index 97% rename from internal/browser/outputter/outputter.go rename to internal/outputter/outputter.go index 355cf08..0d1ff63 100644 --- a/internal/browser/outputter/outputter.go +++ b/internal/outputter/outputter.go @@ -10,7 +10,7 @@ import ( "github.com/gocarina/gocsv" jsoniter "github.com/json-iterator/go" - "hack-browser-data/internal/browser/data" + "hack-browser-data/internal/data" ) type outPutter struct {