Add -tls-proxy-outbound-port flag to jafar (useful for non-HTTPS protocols)

Edit README to make it explicit that tlsproxy has nothing to do with HTTP and can be
used with any TCP protocol that does TLS handshakes.
This commit is contained in:
ooni noob 2022-11-23 10:56:06 +01:00
commit 508c4293d5
4 changed files with 26 additions and 13 deletions

View file

@ -21,8 +21,9 @@ type Dialer interface {
// CensoringProxy is a censoring TLS proxy
type CensoringProxy struct {
keywords []string
dial func(network, address string) (net.Conn, error)
keywords []string
dial func(network, address string) (net.Conn, error)
outboundPort string
}
// NewCensoringProxy creates a new CensoringProxy instance using
@ -31,13 +32,18 @@ type CensoringProxy struct {
// the SNII record of a ClientHello. dnsNetwork and dnsAddress are
// settings to configure the upstream, non censored DNS.
func NewCensoringProxy(
keywords []string, uncensored Dialer,
keywords []string, uncensored Dialer, outboundPort *string,
) *CensoringProxy {
defaultPort := "443"
if outboundPort == nil {
outboundPort = &defaultPort
}
return &CensoringProxy{
keywords: keywords,
dial: func(network, address string) (net.Conn, error) {
return uncensored.DialContext(context.Background(), network, address)
},
outboundPort: *outboundPort,
}
}
@ -146,7 +152,7 @@ func (p *CensoringProxy) handle(clientconn net.Conn) {
return
}
}
serverconn, err := p.dial("tcp", net.JoinHostPort(sni, "443"))
serverconn, err := p.dial("tcp", net.JoinHostPort(sni, p.outboundPort))
if err != nil {
log.WithError(err).Warn("tlsproxy: p.dial failed")
alertclose(clientconn)