Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linter errors in "command_run.identity" and "location" #104

Merged
merged 1 commit into from Jan 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions cmd/mysterium_server/command_run/identity/handler.go
Expand Up @@ -8,21 +8,21 @@ import (

type handler struct {
manager identity.IdentityManagerInterface
identityApi server.Client
identityAPI server.Client
cache identity.IdentityCacheInterface
signerFactory identity.SignerFactory
}

//NewHandler creates new identity handler used by node
func NewHandler(
manager identity.IdentityManagerInterface,
identityApi server.Client,
identityAPI server.Client,
cache identity.IdentityCacheInterface,
signerFactory identity.SignerFactory,
) HandlerInterface {
return &handler{
manager: manager,
identityApi: identityApi,
identityAPI: identityAPI,
cache: cache,
signerFactory: signerFactory,
}
Expand Down Expand Up @@ -54,7 +54,7 @@ func (h *handler) UseNew(passphrase string) (id identity.Identity, err error) {
return
}

if err = h.identityApi.RegisterIdentity(id, h.signerFactory(id)); err != nil {
if err = h.identityAPI.RegisterIdentity(id, h.signerFactory(id)); err != nil {
return
}

Expand Down
1 change: 1 addition & 0 deletions cmd/mysterium_server/command_run/identity/interface.go
Expand Up @@ -2,6 +2,7 @@ package identity

import "github.com/mysterium/node/identity"

// HandlerInterface allows selecting identity to be used
type HandlerInterface interface {
UseExisting(address string) (identity.Identity, error)
UseLast() (identity.Identity, error)
Expand Down
5 changes: 3 additions & 2 deletions cmd/mysterium_server/command_run/identity/loading.go
Expand Up @@ -2,10 +2,11 @@ package identity

import "github.com/mysterium/node/identity"

type IdentitySelector func() (identity.Identity, error)
// Selector selects the identity
type Selector func() (identity.Identity, error)

// LoadIdentity selects and unlocks identity
func LoadIdentity(identitySelector IdentitySelector, identityManager identity.IdentityManagerInterface, passphrase string) (identity.Identity, error) {
func LoadIdentity(identitySelector Selector, identityManager identity.IdentityManagerInterface, passphrase string) (identity.Identity, error) {
id, err := identitySelector()

if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions location/detection.go
Expand Up @@ -9,10 +9,12 @@ import (
// Database downloaded from http://dev.maxmind.com/geoip/geoip2/geolite2/
const Database = "data/GeoLite2-Country.mmdb"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code source has nothing common with environment there compiled application is executed

  • This config should be configured from CLI argument --ip-database
    OR
  • This config should be loader from ConfigDirectory + "/GeoLite2-Country.mmdb"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - I am working on that in a separate PR, because this PR is not related to this issue.


// DetectCountry maps ip to country using default database
func DetectCountry(ip string) (string, error) {
return DetectCountryWithDatabase(ip, Database)
}

// DetectCountryWithDatabase maps ip to country using custom database
func DetectCountryWithDatabase(ip, database string) (string, error) {
db, err := geoip2.Open(database)
if err != nil {
Expand Down