Skip to content

Commit

Permalink
add support for https proxy
Browse files Browse the repository at this point in the history
Cherry-picking the proxy support from v1.4.2-1 tag.

gorilla#548
(cherry picked from commit 9b1460a)
Signed-off-by: Janne Kiiskilä <[email protected]>
  • Loading branch information
costanic authored and JanneKiiskila committed May 28, 2024
1 parent ac0789b commit e5dff72
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package websocket

import (
"bufio"
"crypto/tls"
"encoding/base64"
"errors"
"log"
Expand All @@ -23,10 +24,21 @@ func (fn netDialerFunc) Dial(network, addr string) (net.Conn, error) {
return fn(network, addr)
}

type tlsDialer struct {
}

func (t *tlsDialer) Dial(network, addr string) (c net.Conn, err error) {
return tls.DialWithDialer(&net.Dialer{}, network, addr, &tls.Config{})
}

func init() {
proxy.RegisterDialerType("http", func(proxyURL *url.URL, forwardDialer proxy.Dialer) (proxy.Dialer, error) {
return &httpProxyDialer{proxyURL: proxyURL, forwardDial: forwardDialer.Dial}, nil
})
proxy_RegisterDialerType("https", func(proxyURL *url.URL, forwardDialer proxy_Dialer) (proxy_Dialer, error) {
dialer := &tlsDialer{}
return &httpProxyDialer{proxyURL: proxyURL, forwardDial: dialer.Dial}, nil
})
}

type httpProxyDialer struct {
Expand Down

0 comments on commit e5dff72

Please sign in to comment.