feat: add hysteria
This commit is contained in:
54
test/hysteria_test.go
Normal file
54
test/hysteria_test.go
Normal file
@ -0,0 +1,54 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Dreamacro/clash/adapter/outbound"
|
||||
C "github.com/Dreamacro/clash/constant"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestClash_Hysteria(t *testing.T) {
|
||||
cfg := &container.Config{
|
||||
Image: ImageHysteria,
|
||||
ExposedPorts: defaultExposedPorts,
|
||||
Cmd: []string{"server"},
|
||||
}
|
||||
hostCfg := &container.HostConfig{
|
||||
PortBindings: defaultPortBindings,
|
||||
Binds: []string{
|
||||
fmt.Sprintf("%s:/config.json", C.Path.Resolve("hysteria.json")),
|
||||
fmt.Sprintf("%s:/home/ubuntu/my.crt", C.Path.Resolve("example.org.pem")),
|
||||
fmt.Sprintf("%s:/home/ubuntu/my.key", C.Path.Resolve("example.org-key.pem")),
|
||||
},
|
||||
}
|
||||
|
||||
id, err := startContainer(cfg, hostCfg, "hysteria")
|
||||
if err != nil {
|
||||
assert.FailNow(t, err.Error())
|
||||
}
|
||||
|
||||
t.Cleanup(func() {
|
||||
cleanContainer(id)
|
||||
})
|
||||
|
||||
proxy, err := outbound.NewHysteria(outbound.HysteriaOption{
|
||||
Name: "hysteria",
|
||||
Server: localIP.String(),
|
||||
Port: 10002,
|
||||
Obfs: "fuck me till the daylight",
|
||||
UpMbps: 100,
|
||||
DownMbps: 100,
|
||||
UDP: true,
|
||||
SkipCertVerify: true,
|
||||
})
|
||||
if err != nil {
|
||||
assert.FailNow(t, err.Error())
|
||||
}
|
||||
|
||||
time.Sleep(waitTime)
|
||||
testSuit(t, proxy)
|
||||
}
|
Reference in New Issue
Block a user