-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kafka: add socks5 proxy support for kafka output plugin
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package proxy | ||
|
||
import ( | ||
"golang.org/x/net/proxy" | ||
) | ||
|
||
type Socks5ProxyConfig struct { | ||
address string `toml:"socks5_address"` | ||
username string `toml:"socks5_username"` | ||
password string `toml:"socks5_password"` | ||
} | ||
|
||
func (c* Socks5ProxyConfig) GetDialer() (*proxy.Dialer, error) { | ||
var auth *proxy.Auth | ||
if c.username != "" || c.password != "" { | ||
auth = new(proxy.Auth) | ||
auth.User = c.username | ||
auth.Password = c.password | ||
} | ||
dialer, err := proxy.SOCKS5("tcp", c.address, auth, proxy.Direct) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &dialer, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters