Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ jobs:
sudo apt install -y socat
timeout 60 socat /dev/null TCP4:tcpbin.com:4242

- name: Test No SNI
run: |
HOST_IP=$(dig +short ubuntu.com | head -n1)
timeout 60 curl "https://$HOST_IP:443" -v || :
sudo snap logs aproxy.aproxy | grep -Fq host=$HOST_IP:443

- name: Test Access Logs
run: |
sudo snap logs aproxy.aproxy | grep -Fq "example.com:80"
Expand Down
24 changes: 14 additions & 10 deletions aproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"net/url"
"os"
"os/signal"
"strconv"
"strings"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -356,17 +357,20 @@ func HandleConn(conn net.Conn, proxy string) {
if err != nil {
logger.Error("failed to preread SNI from connection", "error", err)
return
} else {
host := fmt.Sprintf("%s:%d", sni, dst.Port)
logger = logger.With("host", host)
proxyConn, err := DialProxyConnect(proxy, host)
if err != nil {
logger.Error("failed to connect to http proxy", "error", err)
return
}
logger.Info("relay TLS connection to proxy")
RelayTCP(consigned, proxyConn, logger)
}
hostname := sni
if hostname == "" {
hostname = dst.IP.String()
}
host := net.JoinHostPort(hostname, strconv.Itoa(dst.Port))
logger = logger.With("host", host)
proxyConn, err := DialProxyConnect(proxy, host)
if err != nil {
logger.Error("failed to connect to http proxy", "error", err)
return
}
logger.Info("relay TLS connection to proxy")
RelayTCP(consigned, proxyConn, logger)
case 80, 11371:
host, err := PrereadHttpHost(consigned)
if err != nil {
Expand Down