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

config: add Dialer option to connect through a proxy #296

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

HaoweiCh
Copy link

@HaoweiCh HaoweiCh commented May 7, 2020

import "golang.org/x/net/proxy"

if dialer, err := proxy.SOCKS5("tcp", "192.168.3.1:23456", nil, nil); err != nil {
	log.Fatal(err)
} else {
	cfg..Dialer = dialer
}

config.go Outdated Show resolved Hide resolved
@gknw
Copy link

gknw commented Jul 2, 2020

I want to vote for accept this PR. We are looking for a way to manage NSQ connection, and a custom dialer solved (partially) our problem. It's a convenient thing.

Copy link
Member

@mreiferson mreiferson left a comment

Choose a reason for hiding this comment

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

Left a few comments, thanks!

// Dialer affect connection when dialing an nsqd. Overwrite this to connect over proxy.
//
// Conflict with options LocalAddr and DialTimeout.
Dialer Dialer `opt:"dialer"`
Copy link
Member

Choose a reason for hiding this comment

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

We need to decide how to handle configuration specified for this opt, e.g. for command line utilities in nsqd that use --consumer-opt.

See: https://github.com/nsqio/nsq/blob/master/apps/nsq_to_file/nsq_to_file.go#L131-L135

And an example of how we handle tls_config: https://github.com/nsqio/go-nsq/blob/master/config.go#L388-L475

@@ -101,6 +107,10 @@ type Config struct {
// LocalAddr is the local address to use when dialing an nsqd.
// If empty, a local address is automatically chosen.
LocalAddr net.Addr `opt:"local_addr"`
// Dialer affect connection when dialing an nsqd. Overwrite this to connect over proxy.
//
// Conflict with options LocalAddr and DialTimeout.
Copy link
Member

Choose a reason for hiding this comment

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

Correct, this does conflict. We should probably error when a dialer and either of those two config fields are set.

@@ -101,6 +107,10 @@ type Config struct {
// LocalAddr is the local address to use when dialing an nsqd.
// If empty, a local address is automatically chosen.
LocalAddr net.Addr `opt:"local_addr"`
// Dialer affect connection when dialing an nsqd. Overwrite this to connect over proxy.
Copy link
Member

Choose a reason for hiding this comment

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

Let's use:

Dialer will be called to connect to an nsqd when set, e.g. through a proxy

@mreiferson mreiferson changed the title feature: nsqd connection over proxy (socks...) config: add Dialer option to connect through a proxy Jul 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants