mirror of
https://github.com/rclone/rclone.git
synced 2025-01-10 16:28:30 +01:00
fshttp: rework address parsing for DSCP (fixes #5293)
This commit is contained in:
parent
04a1f673f0
commit
85b8ba9469
@ -3,6 +3,7 @@ package fshttp
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net"
|
"net"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rclone/rclone/fs"
|
"github.com/rclone/rclone/fs"
|
||||||
@ -53,15 +54,14 @@ func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.
|
|||||||
return c, err
|
return c, err
|
||||||
}
|
}
|
||||||
if d.tclass != 0 {
|
if d.tclass != 0 {
|
||||||
if addr, ok := c.RemoteAddr().(*net.IPAddr); ok {
|
// IPv6 addresses must have two or more ":"
|
||||||
if addr.IP.To16() != nil && addr.IP.To4() == nil {
|
if strings.Count(c.RemoteAddr().String(), ":") > 1 {
|
||||||
err = ipv6.NewConn(c).SetTrafficClass(d.tclass)
|
err = ipv6.NewConn(c).SetTrafficClass(d.tclass)
|
||||||
} else {
|
} else {
|
||||||
err = ipv4.NewConn(c).SetTOS(d.tclass)
|
err = ipv4.NewConn(c).SetTOS(d.tclass)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c, err
|
return c, err
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newTimeoutConn(c, d.timeout)
|
return newTimeoutConn(c, d.timeout)
|
||||||
|
Loading…
Reference in New Issue
Block a user