Set Dial function of Dialer












0















I am trying to get DNS requests to tunnel through my company's proxy by using the HTTP CONNECT method.



The library I am using to make the DNS requests supports setting a custom net.Dialer on an instance of dns.Client. I found another library that claims to act as a drop-in replacement for net.Dialer that supports initiating TCP connections through a proxy using the HTTP CONNECT method.



However, I can't figure out how to get this to work with these two libraries.



I have tried setting the Dialer field of dns.Client, but it complains about incompatible types:



client := &dns.Client{
Net: "tcp",
Timeout: time.Duration(forwarder.Timeout) * time.Second,
}

if forwarder.Proxy != nil {
client.Dialer = http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer))
}


Yields:



cannot use http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer)) (type *http_dialer.HttpTunnel) as type *net.Dialer in assignment


So I tried casting it:



client := &dns.Client{
Net: "tcp",
Timeout: time.Duration(forwarder.Timeout) * time.Second,
}

if forwarder.Proxy != nil {
client.Dialer = net.Dialer(*http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer)))
}


But that yields:



cannot convert *http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer)) (type http_dialer.HttpTunnel) to type net.Dialer


Finally, I tried setting the Dial function of dns.Client.Dialer to the Dial function in the http_dialer.HttpTunnel returned by http_dialer#New:



client := &dns.Client{
Net: "tcp",
Timeout: time.Duration(forwarder.Timeout) * time.Second,
}


if forwarder.Proxy != nil {
client.Dialer.Dial = http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer)).Dial
}


But that yielded:



cannot assign to client.Dialer.Dial


So I how do I set the Dialer of my DNS client?










share|improve this question























  • There is a proxy that you have (or want) to tunnel through to reach the internet, but you can't resolve the proxy's name without also tunneling DNS through it? This sounds like chicken-egg to me.

    – Peter
    Nov 28 '18 at 9:30













  • This isn't for resolving the proxy's name, this is for resolving names of things that aren't on our network.

    – wheeler
    Nov 28 '18 at 13:26











  • The proxy does that though. If I proxy a request for stackoverflow.com, my host never resolves that name. It just sends CONNECT https://stackoverflow.com/ HTTP/1.1 to the proxy.

    – Peter
    Nov 28 '18 at 14:13











  • I know the proxy does that, this is part of a multi-application suite that makes a non-transparent proxy, transparent. As such, i need to do some sort of DNS resolution of addresses that are not on our network.

    – wheeler
    Nov 28 '18 at 16:20
















0















I am trying to get DNS requests to tunnel through my company's proxy by using the HTTP CONNECT method.



The library I am using to make the DNS requests supports setting a custom net.Dialer on an instance of dns.Client. I found another library that claims to act as a drop-in replacement for net.Dialer that supports initiating TCP connections through a proxy using the HTTP CONNECT method.



However, I can't figure out how to get this to work with these two libraries.



I have tried setting the Dialer field of dns.Client, but it complains about incompatible types:



client := &dns.Client{
Net: "tcp",
Timeout: time.Duration(forwarder.Timeout) * time.Second,
}

if forwarder.Proxy != nil {
client.Dialer = http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer))
}


Yields:



cannot use http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer)) (type *http_dialer.HttpTunnel) as type *net.Dialer in assignment


So I tried casting it:



client := &dns.Client{
Net: "tcp",
Timeout: time.Duration(forwarder.Timeout) * time.Second,
}

if forwarder.Proxy != nil {
client.Dialer = net.Dialer(*http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer)))
}


But that yields:



cannot convert *http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer)) (type http_dialer.HttpTunnel) to type net.Dialer


Finally, I tried setting the Dial function of dns.Client.Dialer to the Dial function in the http_dialer.HttpTunnel returned by http_dialer#New:



client := &dns.Client{
Net: "tcp",
Timeout: time.Duration(forwarder.Timeout) * time.Second,
}


if forwarder.Proxy != nil {
client.Dialer.Dial = http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer)).Dial
}


But that yielded:



cannot assign to client.Dialer.Dial


So I how do I set the Dialer of my DNS client?










share|improve this question























  • There is a proxy that you have (or want) to tunnel through to reach the internet, but you can't resolve the proxy's name without also tunneling DNS through it? This sounds like chicken-egg to me.

    – Peter
    Nov 28 '18 at 9:30













  • This isn't for resolving the proxy's name, this is for resolving names of things that aren't on our network.

    – wheeler
    Nov 28 '18 at 13:26











  • The proxy does that though. If I proxy a request for stackoverflow.com, my host never resolves that name. It just sends CONNECT https://stackoverflow.com/ HTTP/1.1 to the proxy.

    – Peter
    Nov 28 '18 at 14:13











  • I know the proxy does that, this is part of a multi-application suite that makes a non-transparent proxy, transparent. As such, i need to do some sort of DNS resolution of addresses that are not on our network.

    – wheeler
    Nov 28 '18 at 16:20














0












0








0








I am trying to get DNS requests to tunnel through my company's proxy by using the HTTP CONNECT method.



The library I am using to make the DNS requests supports setting a custom net.Dialer on an instance of dns.Client. I found another library that claims to act as a drop-in replacement for net.Dialer that supports initiating TCP connections through a proxy using the HTTP CONNECT method.



However, I can't figure out how to get this to work with these two libraries.



I have tried setting the Dialer field of dns.Client, but it complains about incompatible types:



client := &dns.Client{
Net: "tcp",
Timeout: time.Duration(forwarder.Timeout) * time.Second,
}

if forwarder.Proxy != nil {
client.Dialer = http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer))
}


Yields:



cannot use http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer)) (type *http_dialer.HttpTunnel) as type *net.Dialer in assignment


So I tried casting it:



client := &dns.Client{
Net: "tcp",
Timeout: time.Duration(forwarder.Timeout) * time.Second,
}

if forwarder.Proxy != nil {
client.Dialer = net.Dialer(*http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer)))
}


But that yields:



cannot convert *http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer)) (type http_dialer.HttpTunnel) to type net.Dialer


Finally, I tried setting the Dial function of dns.Client.Dialer to the Dial function in the http_dialer.HttpTunnel returned by http_dialer#New:



client := &dns.Client{
Net: "tcp",
Timeout: time.Duration(forwarder.Timeout) * time.Second,
}


if forwarder.Proxy != nil {
client.Dialer.Dial = http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer)).Dial
}


But that yielded:



cannot assign to client.Dialer.Dial


So I how do I set the Dialer of my DNS client?










share|improve this question














I am trying to get DNS requests to tunnel through my company's proxy by using the HTTP CONNECT method.



The library I am using to make the DNS requests supports setting a custom net.Dialer on an instance of dns.Client. I found another library that claims to act as a drop-in replacement for net.Dialer that supports initiating TCP connections through a proxy using the HTTP CONNECT method.



However, I can't figure out how to get this to work with these two libraries.



I have tried setting the Dialer field of dns.Client, but it complains about incompatible types:



client := &dns.Client{
Net: "tcp",
Timeout: time.Duration(forwarder.Timeout) * time.Second,
}

if forwarder.Proxy != nil {
client.Dialer = http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer))
}


Yields:



cannot use http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer)) (type *http_dialer.HttpTunnel) as type *net.Dialer in assignment


So I tried casting it:



client := &dns.Client{
Net: "tcp",
Timeout: time.Duration(forwarder.Timeout) * time.Second,
}

if forwarder.Proxy != nil {
client.Dialer = net.Dialer(*http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer)))
}


But that yields:



cannot convert *http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer)) (type http_dialer.HttpTunnel) to type net.Dialer


Finally, I tried setting the Dial function of dns.Client.Dialer to the Dial function in the http_dialer.HttpTunnel returned by http_dialer#New:



client := &dns.Client{
Net: "tcp",
Timeout: time.Duration(forwarder.Timeout) * time.Second,
}


if forwarder.Proxy != nil {
client.Dialer.Dial = http_dialer.New(forwarder.Proxy, http_dialer.WithDialer(client.Dialer)).Dial
}


But that yielded:



cannot assign to client.Dialer.Dial


So I how do I set the Dialer of my DNS client?







go dns






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 28 '18 at 0:33









wheelerwheeler

872820




872820













  • There is a proxy that you have (or want) to tunnel through to reach the internet, but you can't resolve the proxy's name without also tunneling DNS through it? This sounds like chicken-egg to me.

    – Peter
    Nov 28 '18 at 9:30













  • This isn't for resolving the proxy's name, this is for resolving names of things that aren't on our network.

    – wheeler
    Nov 28 '18 at 13:26











  • The proxy does that though. If I proxy a request for stackoverflow.com, my host never resolves that name. It just sends CONNECT https://stackoverflow.com/ HTTP/1.1 to the proxy.

    – Peter
    Nov 28 '18 at 14:13











  • I know the proxy does that, this is part of a multi-application suite that makes a non-transparent proxy, transparent. As such, i need to do some sort of DNS resolution of addresses that are not on our network.

    – wheeler
    Nov 28 '18 at 16:20



















  • There is a proxy that you have (or want) to tunnel through to reach the internet, but you can't resolve the proxy's name without also tunneling DNS through it? This sounds like chicken-egg to me.

    – Peter
    Nov 28 '18 at 9:30













  • This isn't for resolving the proxy's name, this is for resolving names of things that aren't on our network.

    – wheeler
    Nov 28 '18 at 13:26











  • The proxy does that though. If I proxy a request for stackoverflow.com, my host never resolves that name. It just sends CONNECT https://stackoverflow.com/ HTTP/1.1 to the proxy.

    – Peter
    Nov 28 '18 at 14:13











  • I know the proxy does that, this is part of a multi-application suite that makes a non-transparent proxy, transparent. As such, i need to do some sort of DNS resolution of addresses that are not on our network.

    – wheeler
    Nov 28 '18 at 16:20

















There is a proxy that you have (or want) to tunnel through to reach the internet, but you can't resolve the proxy's name without also tunneling DNS through it? This sounds like chicken-egg to me.

– Peter
Nov 28 '18 at 9:30







There is a proxy that you have (or want) to tunnel through to reach the internet, but you can't resolve the proxy's name without also tunneling DNS through it? This sounds like chicken-egg to me.

– Peter
Nov 28 '18 at 9:30















This isn't for resolving the proxy's name, this is for resolving names of things that aren't on our network.

– wheeler
Nov 28 '18 at 13:26





This isn't for resolving the proxy's name, this is for resolving names of things that aren't on our network.

– wheeler
Nov 28 '18 at 13:26













The proxy does that though. If I proxy a request for stackoverflow.com, my host never resolves that name. It just sends CONNECT https://stackoverflow.com/ HTTP/1.1 to the proxy.

– Peter
Nov 28 '18 at 14:13





The proxy does that though. If I proxy a request for stackoverflow.com, my host never resolves that name. It just sends CONNECT https://stackoverflow.com/ HTTP/1.1 to the proxy.

– Peter
Nov 28 '18 at 14:13













I know the proxy does that, this is part of a multi-application suite that makes a non-transparent proxy, transparent. As such, i need to do some sort of DNS resolution of addresses that are not on our network.

– wheeler
Nov 28 '18 at 16:20





I know the proxy does that, this is part of a multi-application suite that makes a non-transparent proxy, transparent. As such, i need to do some sort of DNS resolution of addresses that are not on our network.

– wheeler
Nov 28 '18 at 16:20












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53510367%2fset-dial-function-of-dialer%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53510367%2fset-dial-function-of-dialer%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)