Skip to content

Commit

Permalink
add support for https proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
costanic committed Jan 13, 2021
1 parent c3dd95a commit 9b1460a
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"
"net"
Expand All @@ -20,10 +21,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 9b1460a

Please sign in to comment.