-
Notifications
You must be signed in to change notification settings - Fork 313
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
Improvement/naive detection of nat #292
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ | |
package server | ||
|
||
import ( | ||
"fmt" | ||
log "github.com/cihub/seelog" | ||
"github.com/ethereum/go-ethereum/accounts/keystore" | ||
identity_handler "github.com/mysterium/node/cmd/commands/server/identity" | ||
"github.com/mysterium/node/communication" | ||
|
@@ -73,23 +75,14 @@ func NewCommandWith( | |
createSigner, | ||
) | ||
|
||
var locationResolver location.Resolver | ||
if options.LocationCountry != "" { | ||
locationResolver = location.NewResolverFake(options.LocationCountry) | ||
} else if options.LocationDatabase != "" { | ||
locationResolver = location.NewResolver(filepath.Join(options.DirectoryConfig, options.LocationDatabase)) | ||
} else { | ||
locationResolver = location.NewResolver(filepath.Join(options.DirectoryConfig, defaultLocationDatabase)) | ||
} | ||
|
||
locationDetector := location.NewDetectorWithLocationResolver(ipResolver, locationResolver) | ||
locationResolver := locationResolver(options) | ||
|
||
return &Command{ | ||
identityLoader: func() (identity.Identity, error) { | ||
return identity_handler.LoadIdentity(identityHandler, options.Identity, options.Passphrase) | ||
}, | ||
createSigner: createSigner, | ||
locationDetector: locationDetector, | ||
locationResolver: locationResolver, | ||
ipResolver: ipResolver, | ||
mysteriumClient: mysteriumClient, | ||
natService: natService, | ||
|
@@ -137,11 +130,36 @@ func NewCommandWith( | |
checkOpenvpn: func() error { | ||
return openvpn.CheckOpenvpnBinary(options.OpenvpnBinary) | ||
}, | ||
openvpnServiceAddress: func(outboundIP, publicIP string) string { | ||
//TODO public ip could be overriden by arg options if needed | ||
if publicIP != outboundIP { | ||
forwardInfo := fmt.Sprintf("%s:%v -> %s:%v", publicIP, options.OpenvpnPort, outboundIP, options.OpenvpnPort) | ||
log.Warnf( | ||
`WARNING: It seems that publicaly visible ip: [%s] does not match your local machines ip: [%s]. | ||
You should probaly need to do port forwarding on your router: %s.`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, did not see that it's already like that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
publicIP, | ||
outboundIP, | ||
forwardInfo, | ||
) | ||
|
||
} | ||
|
||
return publicIP | ||
}, | ||
protocol: options.Protocol, | ||
proposalAnnouncementStopped: &sync.WaitGroup{}, | ||
} | ||
} | ||
|
||
func locationResolver(options CommandOptions) location.Resolver { | ||
switch { | ||
case options.LocationCountry != "": | ||
return location.NewResolverFake(options.LocationCountry) | ||
default: | ||
return location.NewResolver(filepath.Join(options.DirectoryConfig, options.LocationDatabase)) | ||
} | ||
} | ||
|
||
// TODO this function can be aligned with client function when client and server options will merge into | ||
func getNetworkDefinition(options CommandOptions) metadata.NetworkDefinition { | ||
network := metadata.DefaultNetwork | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't we doing option
openvpn.ip
with this?For those who wants has different public IP and wats to map it in router
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is not such option at the moment. And this is a quick detection with posibility for user to take some action.