-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from roma-glushko/35-integrate-with-maxmind-le…
…gal-changes #35 integrate with maxmind legal changes
- Loading branch information
Showing
11 changed files
with
210 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package geo | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"tango/internal/infrastructure/filesystem" | ||
) | ||
|
||
// MaxMindConfResolver retrieves path to the MaxMind Geo Confi file | ||
type MaxMindConfResolver struct { | ||
homeDirResolver *filesystem.HomeDirResolver | ||
} | ||
|
||
// NewMaxMindConfResolver creates a new instance of MaxMindConfResolver | ||
func NewMaxMindConfResolver(homeDirResolver *filesystem.HomeDirResolver) *MaxMindConfResolver { | ||
return &MaxMindConfResolver{ | ||
homeDirResolver: homeDirResolver, | ||
} | ||
} | ||
|
||
// GetPath provides path to MaxMind Geo Library | ||
// there is only one possible path where the lib file can be found: $HOME/.tango/maxmind.conf | ||
// $HOME path should be different on diff OS | ||
func (r *MaxMindConfResolver) GetPath() (string, error) { | ||
homeDirectory := r.homeDirResolver.GetPath() | ||
|
||
maxmindConfPath := filepath.Join(homeDirectory, "maxmind.conf") | ||
_, maxmindConfExistError := os.Stat(maxmindConfPath) | ||
|
||
return maxmindConfPath, maxmindConfExistError | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package geodata | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
// GenerateMaxmindConfUsecase usecase | ||
type GenerateMaxmindConfUsecase struct { | ||
} | ||
|
||
// NewGenerateMaxmindConfUsecase creates a new instance of InstallMaxMindLibraryUsecase | ||
func NewGenerateMaxmindConfUsecase() *GenerateMaxmindConfUsecase { | ||
return &GenerateMaxmindConfUsecase{} | ||
} | ||
|
||
// Generate MaxMind Conf File | ||
func (u *GenerateMaxmindConfUsecase) Generate(confPath string, accountID string, licenseKey string) error { | ||
confFile, err := os.Create(confPath) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
defer confFile.Close() | ||
|
||
confFile.WriteString("# This MaxMind config file was generated by Tango \n") | ||
confFile.WriteString(fmt.Sprintf("AccountID %s\n", accountID)) | ||
confFile.WriteString(fmt.Sprintf("LicenseKey %s\n", licenseKey)) | ||
confFile.WriteString(fmt.Sprintf("EditionIDs %s\n", u.GetEditionIDs())) | ||
|
||
confFile.Sync() | ||
|
||
return nil | ||
} | ||
|
||
// GetEditionIDs retrieves MaxMind Product IDs which are used by Tango | ||
func (u *GenerateMaxmindConfUsecase) GetEditionIDs() string { | ||
return "GeoLite2-City" | ||
} |
Oops, something went wrong.