feat: socks5 proxy support for websocket (#10672)
This commit is contained in:
parent
063ef6d517
commit
7715b84773
|
|
@ -27,6 +27,12 @@ It can output data in any of the [supported output formats](https://github.com/i
|
|||
## Use TLS but skip chain & host verification
|
||||
# insecure_skip_verify = false
|
||||
|
||||
## Optional SOCKS5 proxy to use
|
||||
# socks5_enabled = true
|
||||
# socks5_address = "127.0.0.1:1080"
|
||||
# socks5_username = "alice"
|
||||
# socks5_password = "pass123"
|
||||
|
||||
## Data format to output.
|
||||
## Each data format has it's own unique set of configuration options, read
|
||||
## more about them here:
|
||||
|
|
|
|||
|
|
@ -36,6 +36,12 @@ var sampleConfig = `
|
|||
## Use TLS but skip chain & host verification
|
||||
# insecure_skip_verify = false
|
||||
|
||||
## Optional SOCKS5 proxy to use
|
||||
# socks5_enabled = true
|
||||
# socks5_address = "127.0.0.1:1080"
|
||||
# socks5_username = "alice"
|
||||
# socks5_password = "pass123"
|
||||
|
||||
## Data format to output.
|
||||
## Each data format has it's own unique set of configuration options, read
|
||||
## more about them here:
|
||||
|
|
@ -63,6 +69,7 @@ type WebSocket struct {
|
|||
UseTextFrames bool `toml:"use_text_frames"`
|
||||
Log telegraf.Logger `toml:"-"`
|
||||
proxy.HTTPProxy
|
||||
proxy.Socks5ProxyConfig
|
||||
tls.ClientConfig
|
||||
|
||||
conn *ws.Conn
|
||||
|
|
@ -112,6 +119,14 @@ func (w *WebSocket) Connect() error {
|
|||
TLSClientConfig: tlsCfg,
|
||||
}
|
||||
|
||||
if w.Socks5ProxyEnabled {
|
||||
netDialer, err := w.Socks5ProxyConfig.GetDialer()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error connecting to socks5 proxy: %v", err)
|
||||
}
|
||||
dialer.NetDial = netDialer.Dial
|
||||
}
|
||||
|
||||
headers := http.Header{}
|
||||
for k, v := range w.Headers {
|
||||
headers.Set(k, v)
|
||||
|
|
|
|||
Loading…
Reference in New Issue