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

rpcclient: Errors when connecting via proxy #1005

Open
davecgh opened this issue Aug 16, 2017 · 6 comments
Open

rpcclient: Errors when connecting via proxy #1005

davecgh opened this issue Aug 16, 2017 · 6 comments

Comments

@davecgh
Copy link
Member

davecgh commented Aug 16, 2017

From @sturd on August 3, 2017 15:59

I have been trying to connect my application via a local SOCKS 5 proxy, but I'm getting errors when I do so.

I have bitcoind running on a network at address 192.168.1.10 (example). The RPC server is running on the default port of 8332. On my local machine, outside of that network, I have an SSH tunnel with my SOCKS 5 proxy, listening on port 1080, as per the SOCKS default.

My ConnConfig setup looks like;

  Conf := &btcrpcclient.ConnConfig{
    Host: "192.168.1.10:8332",
    User: "sturd",
    Pass: "sturd's password",
    HTTPPostMode: true,
    DisableTLS: true,
    Proxy: "127.0.0.1",
  }

With this configuration, attempting to execute a RPC command results in the error;

Post http://192.168.1.10:8332: proxyconnect tcp: dial tcp :0: connectex: The requested address is not valid in its context.

Is there a correct way to format the Proxy string which I'm missing?

Copied from original issue: btcsuite/btcrpcclient#129

@davecgh
Copy link
Member Author

davecgh commented Aug 16, 2017

From @dajohi on August 3, 2017 16:36

Does
Proxy: "127.0.0.1:1080",
work?

@davecgh
Copy link
Member Author

davecgh commented Aug 16, 2017

From @sturd on August 3, 2017 17:51

No it doesn't. I'm getting;

parse 127.0.0.1:1080: first path segment in URL cannot contain colon

with that configuration.

@davecgh
Copy link
Member Author

davecgh commented Aug 16, 2017

From @dajohi on August 3, 2017 21:37

http://127.0.0.1:1080

@davecgh
Copy link
Member Author

davecgh commented Aug 16, 2017

From @sturd on August 4, 2017 7:57

Getting;

Post http://192.168.1.10:8332: EOF

when prefixing the http:// scheme. Same as when prefixing with socks:// as the scheme.

@davecgh
Copy link
Member Author

davecgh commented Aug 16, 2017

From @sturd on August 4, 2017 15:5

Have managed to work around this by removing;

var proxyFunc func(*http.Request) (*url.URL, error)
if config.Proxy != "" {
	proxyURL, err := url.Parse(config.Proxy)
	if err != nil {
		return nil, err
	}
	proxyFunc = http.ProxyURL(proxyURL)
}

and instead overwriting the client.Transport with a new one where Dial() is provided by socks.Proxy{}. It kinda resembles the solution which is implemented for the websocket proxy configuration further down.

@davecgh
Copy link
Member Author

davecgh commented Aug 16, 2017

From @sturd on August 4, 2017 15:30

A little stuck for time, at the moment, but can test and submit a patch this weekend if it would be helpful.

@davecgh davecgh changed the title Errors when connecting via proxy rpcclient: Errors when connecting via proxy Aug 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant