mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-12-20 00:50:06 +08:00
Some checks failed
Test / test (1.20, ubuntu-latest) (push) Failing after 1s
Test / test (1.21, ubuntu-latest) (push) Failing after 1s
Test / test (1.22, ubuntu-latest) (push) Failing after 1s
Test / test (1.23, ubuntu-latest) (push) Failing after 1s
Test / test (1.24, ubuntu-latest) (push) Failing after 1s
Trigger CMFA Update / trigger-CMFA-update (push) Failing after 1s
Test / test (1.20, macos-13) (push) Has been cancelled
Test / test (1.20, macos-latest) (push) Has been cancelled
Test / test (1.20, ubuntu-24.04-arm) (push) Has been cancelled
Test / test (1.20, windows-latest) (push) Has been cancelled
Test / test (1.21, macos-13) (push) Has been cancelled
Test / test (1.21, macos-latest) (push) Has been cancelled
Test / test (1.21, ubuntu-24.04-arm) (push) Has been cancelled
Test / test (1.21, windows-latest) (push) Has been cancelled
Test / test (1.22, macos-13) (push) Has been cancelled
Test / test (1.22, macos-latest) (push) Has been cancelled
Test / test (1.22, ubuntu-24.04-arm) (push) Has been cancelled
Test / test (1.22, windows-latest) (push) Has been cancelled
Test / test (1.23, macos-13) (push) Has been cancelled
Test / test (1.23, macos-latest) (push) Has been cancelled
Test / test (1.23, ubuntu-24.04-arm) (push) Has been cancelled
Test / test (1.23, windows-latest) (push) Has been cancelled
Test / test (1.24, macos-13) (push) Has been cancelled
Test / test (1.24, macos-latest) (push) Has been cancelled
Test / test (1.24, ubuntu-24.04-arm) (push) Has been cancelled
Test / test (1.24, windows-latest) (push) Has been cancelled
34 lines
876 B
Go
34 lines
876 B
Go
package proxydialer
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
|
|
"github.com/metacubex/mihomo/component/slowdown"
|
|
M "github.com/metacubex/sing/common/metadata"
|
|
)
|
|
|
|
type SlowDownSingDialer struct {
|
|
SingDialer
|
|
Slowdown *slowdown.SlowDown
|
|
}
|
|
|
|
func (d SlowDownSingDialer) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
|
|
return slowdown.Do(d.Slowdown, ctx, func() (net.Conn, error) {
|
|
return d.SingDialer.DialContext(ctx, network, destination)
|
|
})
|
|
}
|
|
|
|
func (d SlowDownSingDialer) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error) {
|
|
return slowdown.Do(d.Slowdown, ctx, func() (net.PacketConn, error) {
|
|
return d.SingDialer.ListenPacket(ctx, destination)
|
|
})
|
|
}
|
|
|
|
func NewSlowDownSingDialer(d SingDialer, sd *slowdown.SlowDown) SlowDownSingDialer {
|
|
return SlowDownSingDialer{
|
|
SingDialer: d,
|
|
Slowdown: sd,
|
|
}
|
|
}
|