-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:allow ignore SSL Verification for proxy
- Loading branch information
Showing
2 changed files
with
31 additions
and
9 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
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 |
---|---|---|
@@ -1,28 +1,46 @@ | ||
package deepl | ||
|
||
type deepLClientOption struct { | ||
httpProxy string | ||
socket5Proxy string | ||
socket5ProxyUser string | ||
socket5proxyPassword string | ||
httpProxy string | ||
socket5Proxy string | ||
socket5ProxyUser string | ||
socket5proxyPassword string | ||
ignoreSSLVerification bool | ||
} | ||
|
||
type Option func(option *deepLClientOption) | ||
|
||
// WithHttpProxy set http proxy.if both httpProxy and sock5 proxy are set, | ||
// http proxy will be over-wrote by sock5 proxy .example http://127.0.0.1:1080 | ||
func WithHttpProxy(proxy string) Option { | ||
return WithHttpProxyEx(proxy, false) | ||
} | ||
|
||
// WithHttpProxyEx set http proxy.if both httpProxy and sock5 proxy are set, | ||
// http proxy will be over-wrote by sock5 proxy .example http://http://127.0.0.1:1080 | ||
// ignoreSSLVerification: ignore SSL verification | ||
func WithHttpProxyEx(proxy string, ignoreSSLVerification bool) Option { | ||
return func(option *deepLClientOption) { | ||
option.httpProxy = proxy | ||
option.ignoreSSLVerification = ignoreSSLVerification | ||
} | ||
} | ||
|
||
// WithSocket5Proxy set socket5Proxy.if both httpProxy and sock5 proxy are set, | ||
// http proxy will be over-wrote by sock5 proxy example 127.0.0.1:1080 | ||
func WithSocket5Proxy(socket5Proxy string, userName string, password string) Option { | ||
return WithSocket5ProxyEx(socket5Proxy, userName, password, false) | ||
} | ||
|
||
// WithSocket5ProxyEx set socket5Proxy.if both httpProxy and sock5 proxy are set, | ||
// http proxy will be over-wrote by sock5 proxy example 127.0.0.1:1080 | ||
// ignoreSSLVerification: ignore SSL verification | ||
func WithSocket5ProxyEx(socket5Proxy string, userName string, password string, ignoreSSLVerification bool) Option { | ||
return func(option *deepLClientOption) { | ||
option.socket5Proxy = socket5Proxy | ||
option.socket5ProxyUser = userName | ||
option.socket5proxyPassword = password | ||
option.ignoreSSLVerification = ignoreSSLVerification | ||
} | ||
|
||
} |