1 Commits

Author SHA1 Message Date
Vladislav Yarmak
2569c5e584 proxy sni experiments 2022-09-29 18:53:00 +03:00
2 changed files with 6 additions and 6 deletions

View File

@@ -251,7 +251,7 @@ func run() int {
} }
proxyNetAddr := net.JoinHostPort(proxyHostname, strconv.FormatUint(uint64(ASSUMED_PROXY_PORT), 10)) proxyNetAddr := net.JoinHostPort(proxyHostname, strconv.FormatUint(uint64(ASSUMED_PROXY_PORT), 10))
handlerDialer := NewProxyDialer(proxyNetAddr, proxyHostname, auth, caPool, dialer) handlerDialer := NewProxyDialer(proxyNetAddr, "a", auth, caPool, dialer)
mainLogger.Info("Endpoint: %s", proxyNetAddr) mainLogger.Info("Endpoint: %s", proxyNetAddr)
mainLogger.Info("Starting proxy server...") mainLogger.Info("Starting proxy server...")
handler := NewProxyHandler(handlerDialer, proxyLogger) handler := NewProxyHandler(handlerDialer, proxyLogger)

View File

@@ -91,7 +91,7 @@ func (d *ProxyDialer) DialContext(ctx context.Context, network, address string)
conn, err := d.next.DialContext(ctx, "tcp", d.address) conn, err := d.next.DialContext(ctx, "tcp", d.address)
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("proxy dial failed: %w", err)
} }
if d.tlsServerName != "" { if d.tlsServerName != "" {
@@ -134,21 +134,21 @@ func (d *ProxyDialer) DialContext(ctx context.Context, network, address string)
rawreq, err := httputil.DumpRequest(req, false) rawreq, err := httputil.DumpRequest(req, false)
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("unable to prepare request for proxy: %w", err)
} }
_, err = conn.Write(rawreq) _, err = conn.Write(rawreq)
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("unable to send request to proxy: %w", err)
} }
proxyResp, err := readResponse(conn, req) proxyResp, err := readResponse(conn, req)
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("unable to read proxy response: %w", err)
} }
if proxyResp.StatusCode != http.StatusOK { if proxyResp.StatusCode != http.StatusOK {
return nil, errors.New(fmt.Sprintf("bad response from upstream proxy server: %s", proxyResp.Status)) return nil, fmt.Errorf("bad response from upstream proxy server: %s", proxyResp.Status)
} }
return conn, nil return conn, nil