2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 10:17:17 +08:00

feat: 网站重构1

This commit is contained in:
2025-12-01 22:50:16 +08:00
parent b17b7ccfee
commit 2b8890305c
24 changed files with 175 additions and 301 deletions

View File

@@ -137,18 +137,7 @@ func (v *baseVhost) Listen() []types.Listen {
// Apache 的监听配置通常在 VirtualHost 的参数中
// 例如: <VirtualHost *:80> 或 <VirtualHost 192.168.1.1:443>
for _, arg := range v.vhost.Args {
listen := types.Listen{
Address: arg,
Options: make(map[string]string),
}
// 检查是否是 HTTPS
if strings.Contains(arg, ":443") || v.HTTPS() {
listen.Protocol = "https"
} else {
listen.Protocol = "http"
}
listen := types.Listen{Address: arg}
result = append(result, listen)
}
@@ -583,7 +572,7 @@ func (v *baseVhost) SetRedirects(redirects []types.Redirect) error {
// ========== PHPVhost ==========
func (v *PHPVhost) PHP() int {
func (v *PHPVhost) PHP() uint {
// Apache 通常通过 FilesMatch 块配置 PHP
// 或者通过 SetHandler 指令
handler := v.vhost.GetDirectiveValue("SetHandler")
@@ -606,7 +595,7 @@ func (v *PHPVhost) PHP() int {
if len(parts) >= 2 {
major, _ := strconv.Atoi(parts[0])
minor, _ := strconv.Atoi(parts[1])
return major*10 + minor
return uint(major*10 + minor)
}
}
}
@@ -630,7 +619,7 @@ func (v *PHPVhost) PHP() int {
return 0
}
func (v *PHPVhost) SetPHP(version int) error {
func (v *PHPVhost) SetPHP(version uint) error {
// 移除现有的 PHP 配置
v.vhost.RemoveDirective("SetHandler")

View File

@@ -131,8 +131,8 @@ func (s *VhostTestSuite) TestIndexEmpty() {
func (s *VhostTestSuite) TestListen() {
listens := []types.Listen{
{Address: "*:80", Protocol: "http"},
{Address: "*:443", Protocol: "https"},
{Address: "*:80"},
{Address: "*:443"},
}
err := s.vhost.SetListen(listens)
s.NoError(err)
@@ -345,7 +345,7 @@ func (s *VhostTestSuite) TestExportWithSSL() {
func (s *VhostTestSuite) TestListenProtocolDetection() {
listens := []types.Listen{
{Address: "*:443", Protocol: "https"},
{Address: "*:443"},
}
s.NoError(s.vhost.SetListen(listens))
@@ -357,7 +357,7 @@ func (s *VhostTestSuite) TestListenProtocolDetection() {
got := s.vhost.Listen()
s.Len(got, 1)
s.Equal("https", got[0].Protocol)
s.Equal("*:443", got[0].Address)
}
func (s *VhostTestSuite) TestDirectoryBlock() {