Files
3x-ui-agent/internal/web/job/limit_ip_disconnect_test.go
Sanaei f727d04f65
Release 3X-UI for Docker / build (push) Canceled after 0s
Release 3X-UI / build (386) (push) Canceled after 0s
Release 3X-UI / build (amd64) (push) Canceled after 0s
Release 3X-UI / build (arm64) (push) Canceled after 0s
Release 3X-UI / build (armv5) (push) Canceled after 0s
Release 3X-UI / build (armv6) (push) Canceled after 0s
Release 3X-UI / build (armv7) (push) Canceled after 0s
Release 3X-UI / build (s390x) (push) Canceled after 0s
Release 3X-UI / Build for Windows (amd64) (push) Canceled after 0s
Release 3X-UI / Publish rolling dev release (push) Canceled after 0s
v3.7.0
2026-08-24 15:07:15 +02:00

43 lines
1.2 KiB
Go

package job
import (
"strings"
"testing"
"github.com/mhsanaei/3x-ui/v3/internal/database/model"
"github.com/mhsanaei/3x-ui/v3/internal/logger"
)
// The protocol gate must let hysteria through: XrayAPI supports it, and the
// skip left over-limit Hysteria2 sessions alive until the fail2ban ban caught up.
func TestDisconnectClientTemporarilyAllowsHysteria(t *testing.T) {
setupIntegrationDB(t)
const email = "hy2-limit-probe"
inbound := &model.Inbound{
Id: 1,
Protocol: model.Hysteria,
Tag: "hy2-limit-probe-tag",
Settings: `{"clients":[]}`,
}
clients := []model.Client{{Email: email, Auth: "secret"}}
(&CheckClientIpJob{}).disconnectClientTemporarily(inbound, email, clients)
var unsupported, attempted bool
for _, line := range logger.GetLogs(500, "warning") {
if strings.Contains(line, "Temporary disconnect is not supported for protocol hysteria") {
unsupported = true
}
if strings.Contains(line, "Failed to remove user "+email) {
attempted = true
}
}
if unsupported {
t.Fatal("hysteria was rejected by the protocol gate")
}
if !attempted {
t.Fatal("expected a remove attempt against the Xray API for hysteria")
}
}