hysteria_test.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package main
  2. import (
  3. "fmt"
  4. "testing"
  5. "time"
  6. "github.com/docker/docker/api/types/container"
  7. "github.com/metacubex/mihomo/adapter/outbound"
  8. C "github.com/metacubex/mihomo/constant"
  9. "github.com/stretchr/testify/assert"
  10. )
  11. func TestMihomo_Hysteria(t *testing.T) {
  12. cfg := &container.Config{
  13. Image: ImageHysteria,
  14. ExposedPorts: defaultExposedPorts,
  15. Cmd: []string{"server"},
  16. }
  17. hostCfg := &container.HostConfig{
  18. PortBindings: defaultPortBindings,
  19. Binds: []string{
  20. fmt.Sprintf("%s:/config.json", C.Path.Resolve("hysteria.json")),
  21. fmt.Sprintf("%s:/home/ubuntu/my.crt", C.Path.Resolve("example.org.pem")),
  22. fmt.Sprintf("%s:/home/ubuntu/my.key", C.Path.Resolve("example.org-key.pem")),
  23. },
  24. }
  25. id, err := startContainer(cfg, hostCfg, "hysteria")
  26. if err != nil {
  27. assert.FailNow(t, err.Error())
  28. }
  29. t.Cleanup(func() {
  30. cleanContainer(id)
  31. })
  32. proxy, err := outbound.NewHysteria(outbound.HysteriaOption{
  33. Name: "hysteria",
  34. Server: localIP.String(),
  35. Port: 10002,
  36. Obfs: "fuck me till the daylight",
  37. Up: "100",
  38. Down: "100",
  39. SkipCertVerify: true,
  40. })
  41. if err != nil {
  42. assert.FailNow(t, err.Error())
  43. }
  44. time.Sleep(waitTime)
  45. testSuit(t, proxy)
  46. }