Skip to content

Commit

Permalink
Add proxy config
Browse files Browse the repository at this point in the history
  • Loading branch information
bakaoh committed Mar 27, 2019
1 parent cbccf09 commit dbc00aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ func (b *Broker) Open(conf *Config) error {

if conf.Net.TLS.Enable {
b.conn, b.connErr = tls.DialWithDialer(&dialer, "tcp", b.addr, conf.Net.TLS.Config)
} else if conf.Net.Proxy.Enable {
b.conn, b.connErr = conf.Net.Proxy.Dialer.Dial("tcp", b.addr)
} else {
b.conn, b.connErr = dialer.Dial("tcp", b.addr)
}
Expand Down
9 changes: 9 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

"github.com/rcrowley/go-metrics"
"golang.org/x/net/proxy"
)

const defaultClientID = "sarama"
Expand Down Expand Up @@ -85,6 +86,14 @@ type Config struct {
// network being dialed.
// If nil, a local address is automatically chosen.
LocalAddr net.Addr

Proxy struct {
// Whether or not to use proxy when connecting to the broker
// (defaults to false).
Enable bool
// The proxy dialer to use enabled (defaults to nil).
Dialer proxy.Dialer
}
}

// Metadata is the namespace for metadata management properties used by the
Expand Down

0 comments on commit dbc00aa

Please sign in to comment.