mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-08-20 00:01:46 +00:00
.github
app
core
extras
auth
correctnet
masq
obfs
outbounds
acl
speedtest
.mockery.yaml
acl.go
acl_test.go
dns_https.go
dns_standard.go
dns_system.go
interface.go
interface_test.go
mock_PluggableOutbound.go
mock_UDPConn.go
ob_direct.go
ob_direct_linux.go
ob_direct_others.go
ob_http.go
ob_socks5.go
speedtest.go
utils.go
utils_test.go
trafficlogger
transport
go.mod
go.sum
media-kit
scripts
.gitignore
CHANGELOG.md
Dockerfile
LICENSE.md
PROTOCOL.md
README.md
go.work
go.work.sum
hyperbole.py
logo.svg
platforms.txt
37 lines
796 B
Go
37 lines
796 B
Go
package outbounds
|
|
|
|
import (
|
|
"net"
|
|
|
|
"github.com/apernet/hysteria/extras/outbounds/speedtest"
|
|
)
|
|
|
|
const (
|
|
SpeedtestDest = "@SpeedTest"
|
|
)
|
|
|
|
// speedtestHandler is a PluggableOutbound that handles speed test requests.
|
|
// It's used to intercept speed test requests and return a pseudo connection that
|
|
// implements the speed test protocol.
|
|
type speedtestHandler struct {
|
|
Next PluggableOutbound
|
|
}
|
|
|
|
func NewSpeedtestHandler(next PluggableOutbound) PluggableOutbound {
|
|
return &speedtestHandler{
|
|
Next: next,
|
|
}
|
|
}
|
|
|
|
func (s *speedtestHandler) TCP(reqAddr *AddrEx) (net.Conn, error) {
|
|
if reqAddr.Host == SpeedtestDest {
|
|
return speedtest.NewServerConn(), nil
|
|
} else {
|
|
return s.Next.TCP(reqAddr)
|
|
}
|
|
}
|
|
|
|
func (s *speedtestHandler) UDP(reqAddr *AddrEx) (UDPConn, error) {
|
|
return s.Next.UDP(reqAddr)
|
|
}
|