Adding upstream version 1.34.4.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
e393c3af3f
commit
4978089aab
4963 changed files with 677545 additions and 0 deletions
37
plugins/common/proxy/dialer.go
Normal file
37
plugins/common/proxy/dialer.go
Normal file
|
@ -0,0 +1,37 @@
|
|||
package proxy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/proxy"
|
||||
)
|
||||
|
||||
type ProxiedDialer struct {
|
||||
dialer proxy.Dialer
|
||||
}
|
||||
|
||||
func (pd *ProxiedDialer) Dial(network, addr string) (net.Conn, error) {
|
||||
return pd.dialer.Dial(network, addr)
|
||||
}
|
||||
|
||||
func (pd *ProxiedDialer) DialContext(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
if contextDialer, ok := pd.dialer.(proxy.ContextDialer); ok {
|
||||
return contextDialer.DialContext(ctx, network, addr)
|
||||
}
|
||||
|
||||
contextDialer := contextDialerShim{pd.dialer}
|
||||
return contextDialer.DialContext(ctx, network, addr)
|
||||
}
|
||||
|
||||
func (pd *ProxiedDialer) DialTimeout(network, addr string, timeout time.Duration) (net.Conn, error) {
|
||||
ctx := context.Background()
|
||||
if timeout.Seconds() != 0 {
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithTimeout(ctx, timeout)
|
||||
defer cancel()
|
||||
}
|
||||
|
||||
return pd.DialContext(ctx, network, addr)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue