2022-06-07 13:38:45 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types/container"
|
2023-11-03 21:01:45 +08:00
|
|
|
"github.com/metacubex/mihomo/adapter/outbound"
|
|
|
|
C "github.com/metacubex/mihomo/constant"
|
2022-06-07 13:38:45 +08:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2023-11-03 21:01:45 +08:00
|
|
|
func TestMihomo_Hysteria(t *testing.T) {
|
2022-06-07 13:38:45 +08:00
|
|
|
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",
|
2022-06-14 21:05:52 +08:00
|
|
|
Up: "100",
|
|
|
|
Down: "100",
|
2022-06-07 13:38:45 +08:00
|
|
|
SkipCertVerify: true,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
assert.FailNow(t, err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
time.Sleep(waitTime)
|
|
|
|
testSuit(t, proxy)
|
|
|
|
}
|