Skip to content

Commit 761b8fc

Browse files
committed
fix http trafic
1 parent 416baa2 commit 761b8fc

4 files changed

Lines changed: 19 additions & 19 deletions

File tree

cmd/volter-client/main_linux.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,11 +460,12 @@ func deriveIPv6Gateway(cidr string) (string, error) {
460460
if err != nil {
461461
return "", err
462462
}
463-
ip = ip.Mask(ipNet.Mask)
464-
b := ip.To16()
465-
if b == nil {
466-
return "", fmt.Errorf("not ipv6: %s", cidr)
463+
if ip.To4() != nil {
464+
return "", fmt.Errorf("not an IPv6 address: %s", cidr)
467465
}
466+
ip = ip.Mask(ipNet.Mask)
467+
b := make(net.IP, len(ip))
468+
copy(b, ip)
468469
b[15] = 1
469-
return net.IP(b).String(), nil
470+
return b.String(), nil
470471
}

internal/config/config.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,10 @@ func MergeAntiDpiTransportTopUpInPlace(prot *ProtectionOptions, transport string
475475
base.JunkStyle = "tls"
476476
}
477477
if strings.TrimSpace(base.FlushPolicy) == "" {
478-
base.FlushPolicy = "perChunk"
478+
base.FlushPolicy = "once"
479479
}
480480
if tcpish {
481481
base.DpiVolterTransportObfuscate = true
482-
if base.FlushJitterMaxMs <= 0 {
483-
base.FlushJitterMaxMs = 18
484-
}
485482
if !base.PreambleRotate && strings.TrimSpace(base.PreambleProfile) == "" {
486483
base.PreambleRotate = true
487484
}

internal/netcfg/routes_linux.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,30 @@ func GetDefaultRoute() (DefaultRoute, error) {
3636
func AddBypass(serverIP net.IP, dr DefaultRoute) error {
3737
ip := serverIP.String()
3838
if serverIP.To4() != nil {
39+
// IPv4 — обычный ip route, gateway совпадает по семейству.
3940
ip += "/32"
40-
} else {
41-
ip += "/128"
41+
if dr.Gateway != "" {
42+
return run("ip", "route", "replace", ip, "via", dr.Gateway, "dev", dr.Dev)
43+
}
44+
return run("ip", "route", "replace", ip, "dev", dr.Dev)
4245
}
43-
if dr.Gateway != "" {
44-
return run("ip", "route", "replace", ip, "via", dr.Gateway, "dev", dr.Dev)
46+
// IPv6 — нужен ip -6 route, gateway обязан быть IPv6.
47+
ip += "/128"
48+
if dr.Gateway != "" && net.ParseIP(dr.Gateway).To4() == nil {
49+
return run("ip", "-6", "route", "replace", ip, "via", dr.Gateway, "dev", dr.Dev)
4550
}
46-
return run("ip", "route", "replace", ip, "dev", dr.Dev)
51+
return run("ip", "-6", "route", "replace", ip, "dev", dr.Dev)
4752
}
4853

4954
func DelBypass(serverIP net.IP) {
5055
ip := serverIP.String()
5156
if serverIP.To4() != nil {
5257
ip += "/32"
58+
_ = execIgnore("ip", "route", "del", ip)
5359
} else {
5460
ip += "/128"
61+
_ = execIgnore("ip", "-6", "route", "del", ip)
5562
}
56-
_ = execIgnore("ip", "route", "del", ip)
5763
}
5864

5965
func AddDefaultViaTun(tun string, metric int) error {

internal/tunnel/tunnel.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"context"
66
"crypto/x509"
77
"fmt"
8-
"math/rand"
98
"net"
109
"strings"
1110
"syscall"
@@ -36,9 +35,6 @@ func Dial(serverAddrs []string, targetIP net.IP, targetPort uint16, token string
3635
targetIP.String(), targetPort, serverAddrs, start, needHopAck(prot))
3736
for round := 0; round < 3; round++ {
3837
for i := 0; i < len(serverAddrs); i++ {
39-
if round == 0 && i == 0 {
40-
time.Sleep(time.Duration(rand.Int63n(56)) * time.Millisecond)
41-
}
4238
addr := serverAddrs[(start+i)%len(serverAddrs)]
4339
clientlog.Trace("Dial attempt round=%d i=%d addr=%s", round, i, addr)
4440
c, err := dialServer(addr, token)

0 commit comments

Comments
 (0)