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

chore: update dependences

This commit is contained in:
耗子
2024-12-27 12:56:59 +08:00
parent d47a764848
commit bd365c4e15
5 changed files with 201 additions and 68 deletions

View File

@@ -1,3 +1,5 @@
//go:build !windows
// Package chattr https://github.com/g0rbe/go-chattr/pull/3
package chattr
@@ -66,7 +68,7 @@ const (
func ioctl(f *os.File, request uintptr, attrp *uint32) error {
argp := uintptr(unsafe.Pointer(attrp))
_, _, errno := syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), request, argp)
_, _, errno := syscall.SyscallN(syscall.SYS_IOCTL, f.Fd(), request, argp)
if errno != 0 {
return os.NewSyscallError("ioctl", errno)
}

View File

@@ -0,0 +1,115 @@
//go:build windows
package chattr
/*
A package for change attribute of a file on Linux, similar to the chattr command.
Example to set the immutable attribute to a file:
file, err := os.OpenFile("file.txt", os.O_RDONLY, 0666)
if err != nil {
panic(err)
}
defer file.Close()
err = chattr.SetAttr(file, chattr.FS_IMMUTABLE_FL)
if err != nil {
panic(err)
}
*/
import (
"errors"
"os"
)
// from /usr/include/linux/fs.h
const (
FS_SECRM_FL uint32 = 0x00000001 /* Secure deletion */
FS_UNRM_FL uint32 = 0x00000002 /* Undelete */
FS_COMPR_FL uint32 = 0x00000004 /* Compress file */
FS_SYNC_FL uint32 = 0x00000008 /* Synchronous updates */
FS_IMMUTABLE_FL uint32 = 0x00000010 /* Immutable file */
FS_APPEND_FL uint32 = 0x00000020 /* writes to file may only append */
FS_NODUMP_FL uint32 = 0x00000040 /* do not dump file */
FS_NOATIME_FL uint32 = 0x00000080 /* do not update atime */
FS_DIRTY_FL uint32 = 0x00000100
FS_COMPRBLK_FL uint32 = 0x00000200 /* One or more compressed clusters */
FS_NOCOMP_FL uint32 = 0x00000400 /* Don't compress */
FS_ENCRYPT_FL uint32 = 0x00000800 /* Encrypted file */
FS_BTREE_FL uint32 = 0x00001000 /* btree format dir */
FS_INDEX_FL uint32 = 0x00001000 /* hash-indexed directory */
FS_IMAGIC_FL uint32 = 0x00002000 /* AFS directory */
FS_JOURNAL_DATA_FL uint32 = 0x00004000 /* Reserved for ext3 */
FS_NOTAIL_FL uint32 = 0x00008000 /* file tail should not be merged */
FS_DIRSYNC_FL uint32 = 0x00010000 /* dirsync behaviour (directories only) */
FS_TOPDIR_FL uint32 = 0x00020000 /* Top of directory hierarchies*/
FS_HUGE_FILE_FL uint32 = 0x00040000 /* Reserved for ext4 */
FS_EXTENT_FL uint32 = 0x00080000 /* Extents */
FS_EA_INODE_FL uint32 = 0x00200000 /* Inode used for large EA */
FS_EOFBLOCKS_FL uint32 = 0x00400000 /* Reserved for ext4 */
FS_NOCOW_FL uint32 = 0x00800000 /* Do not cow file */
FS_INLINE_DATA_FL uint32 = 0x10000000 /* Reserved for ext4 */
FS_PROJINHERIT_FL uint32 = 0x20000000 /* Create with parents projid */
FS_RESERVED_FL uint32 = 0x80000000 /* reserved for ext2 lib */
)
// from ioctl_list manpage
const (
FS_IOC_GETFLAGS uintptr = 0x80086601
FS_IOC_SETFLAGS uintptr = 0x40086602
)
func ioctl(f *os.File, request uintptr, attrp *uint32) error {
return errors.New("not supported on windows")
}
// GetAttrs retrieves the attributes of a file.
func GetAttrs(f *os.File) (uint32, error) {
attr := uint32(1)
err := ioctl(f, FS_IOC_GETFLAGS, &attr)
return attr, err
}
// SetAttr sets the given attribute.
func SetAttr(f *os.File, attr uint32) error {
attrs, err := GetAttrs(f)
if err != nil {
return err
}
attrs |= attr
return ioctl(f, FS_IOC_SETFLAGS, &attrs)
}
// UnsetAttr unsets the given attribute.
func UnsetAttr(f *os.File, attr uint32) error {
attrs, err := GetAttrs(f)
if err != nil {
return err
}
attrs ^= attrs & attr
return ioctl(f, FS_IOC_SETFLAGS, &attrs)
}
// IsAttr checks whether the given attribute is set.
func IsAttr(f *os.File, attr uint32) (bool, error) {
attrs, err := GetAttrs(f)
if err != nil {
return false, err
}
if (attrs & attr) != 0 {
return true, nil
}
return false, nil
}

View File

@@ -14,7 +14,7 @@ func (p *Parser) GetListen() ([][]string, error) {
var result [][]string
for _, dir := range directives {
result = append(result, dir.GetParameters())
result = append(result, p.parameters2Slices(dir.GetParameters()))
}
return result, nil
@@ -26,7 +26,7 @@ func (p *Parser) GetServerName() ([]string, error) {
return nil, err
}
return directive.GetParameters(), nil
return p.parameters2Slices(directive.GetParameters()), nil
}
func (p *Parser) GetIndex() ([]string, error) {
@@ -35,7 +35,7 @@ func (p *Parser) GetIndex() ([]string, error) {
return nil, err
}
return directive.GetParameters(), nil
return p.parameters2Slices(directive.GetParameters()), nil
}
func (p *Parser) GetIndexWithComment() ([]string, []string, error) {
@@ -44,7 +44,7 @@ func (p *Parser) GetIndexWithComment() ([]string, []string, error) {
return nil, nil, err
}
return directive.GetParameters(), directive.GetComment(), nil
return p.parameters2Slices(directive.GetParameters()), directive.GetComment(), nil
}
func (p *Parser) GetRoot() (string, error) {
@@ -52,11 +52,11 @@ func (p *Parser) GetRoot() (string, error) {
if err != nil {
return "", err
}
if len(directive.GetParameters()) == 0 {
if len(p.parameters2Slices(directive.GetParameters())) == 0 {
return "", nil
}
return directive.GetParameters()[0], nil
return directive.GetParameters()[0].GetValue(), nil
}
func (p *Parser) GetRootWithComment() (string, []string, error) {
@@ -64,11 +64,11 @@ func (p *Parser) GetRootWithComment() (string, []string, error) {
if err != nil {
return "", nil, err
}
if len(directive.GetParameters()) == 0 {
if len(p.parameters2Slices(directive.GetParameters())) == 0 {
return "", directive.GetComment(), nil
}
return directive.GetParameters()[0], directive.GetComment(), nil
return directive.GetParameters()[0].GetValue(), directive.GetComment(), nil
}
func (p *Parser) GetIncludes() (includes []string, comments [][]string, err error) {
@@ -81,7 +81,7 @@ func (p *Parser) GetIncludes() (includes []string, comments [][]string, err erro
if len(dir.GetParameters()) != 1 {
return nil, nil, fmt.Errorf("invalid include directive, expected 1 parameter but got %d", len(dir.GetParameters()))
}
includes = append(includes, dir.GetParameters()[0])
includes = append(includes, dir.GetParameters()[0].GetValue())
comments = append(comments, dir.GetComment())
}
@@ -96,10 +96,10 @@ func (p *Parser) GetPHP() int {
var result int
for _, dir := range directives {
if slices.ContainsFunc(dir.GetParameters(), func(s string) bool {
if slices.ContainsFunc(p.parameters2Slices(dir.GetParameters()), func(s string) bool {
return strings.HasPrefix(s, "enable-php-") && strings.HasSuffix(s, ".conf")
}) {
_, _ = fmt.Sscanf(dir.GetParameters()[0], "enable-php-%d.conf", &result)
_, _ = fmt.Sscanf(dir.GetParameters()[0].GetValue(), "enable-php-%d.conf", &result)
}
}
@@ -111,7 +111,7 @@ func (p *Parser) GetHTTPS() bool {
if err != nil {
return false
}
if len(directive.GetParameters()) == 0 {
if len(p.parameters2Slices(directive.GetParameters())) == 0 {
return false
}
@@ -124,7 +124,7 @@ func (p *Parser) GetHTTPSProtocols() []string {
return nil
}
return directive.GetParameters()
return p.parameters2Slices(directive.GetParameters())
}
func (p *Parser) GetHTTPSCiphers() string {
@@ -132,11 +132,11 @@ func (p *Parser) GetHTTPSCiphers() string {
if err != nil {
return ""
}
if len(directive.GetParameters()) == 0 {
if len(p.parameters2Slices(directive.GetParameters())) == 0 {
return ""
}
return directive.GetParameters()[0]
return directive.GetParameters()[0].GetValue()
}
func (p *Parser) GetOCSP() bool {
@@ -144,11 +144,11 @@ func (p *Parser) GetOCSP() bool {
if err != nil {
return false
}
if len(directive.GetParameters()) == 0 {
if len(p.parameters2Slices(directive.GetParameters())) == 0 {
return false
}
return directive.GetParameters()[0] == "on"
return directive.GetParameters()[0].GetValue() == "on"
}
func (p *Parser) GetHSTS() bool {
@@ -158,7 +158,7 @@ func (p *Parser) GetHSTS() bool {
}
for _, dir := range directives {
if slices.Contains(dir.GetParameters(), "Strict-Transport-Security") {
if slices.Contains(p.parameters2Slices(dir.GetParameters()), "Strict-Transport-Security") {
return true
}
}
@@ -174,7 +174,7 @@ func (p *Parser) GetHTTPSRedirect() bool {
for _, dir := range directives {
for _, dir2 := range dir.GetBlock().GetDirectives() {
if dir2.GetName() == "return" && slices.Contains(dir2.GetParameters(), "https://$host$request_uri") {
if dir2.GetName() == "return" && slices.Contains(p.parameters2Slices(dir2.GetParameters()), "https://$host$request_uri") {
return true
}
}
@@ -189,9 +189,9 @@ func (p *Parser) GetAltSvc() string {
return ""
}
for i, param := range directive.GetParameters() {
if strings.HasPrefix(param, "Alt-Svc") && i+1 < len(directive.GetParameters()) {
return directive.GetParameters()[i+1]
for i, param := range p.parameters2Slices(directive.GetParameters()) {
if strings.HasPrefix(param, "Alt-Svc") && i+1 < len(p.parameters2Slices(directive.GetParameters())) {
return p.parameters2Slices(directive.GetParameters())[i+1]
}
}
@@ -203,11 +203,11 @@ func (p *Parser) GetAccessLog() (string, error) {
if err != nil {
return "", err
}
if len(directive.GetParameters()) == 0 {
if len(p.parameters2Slices(directive.GetParameters())) == 0 {
return "", nil
}
return directive.GetParameters()[0], nil
return directive.GetParameters()[0].GetValue(), nil
}
func (p *Parser) GetErrorLog() (string, error) {
@@ -215,9 +215,9 @@ func (p *Parser) GetErrorLog() (string, error) {
if err != nil {
return "", err
}
if len(directive.GetParameters()) == 0 {
if len(p.parameters2Slices(directive.GetParameters())) == 0 {
return "", nil
}
return directive.GetParameters()[0], nil
return directive.GetParameters()[0].GetValue(), nil
}

View File

@@ -142,7 +142,7 @@ func (p *Parser) Set(key string, directives []*config.Directive) error {
}
for _, directive := range directives {
directive.SetParent(block)
directive.SetParent(block.GetParent())
block.Directives = append(block.Directives, directive)
}
@@ -163,7 +163,7 @@ func (p *Parser) sortDirectives(directives []config.IDirective, orderIndex map[s
if orderIndex[a.GetName()] != orderIndex[b.GetName()] {
return orderIndex[a.GetName()] - orderIndex[b.GetName()]
}
return slices.Compare(a.GetParameters(), b.GetParameters())
return slices.Compare(p.parameters2Slices(a.GetParameters()), p.parameters2Slices(b.GetParameters()))
})
for _, directive := range directives {
@@ -172,3 +172,19 @@ func (p *Parser) sortDirectives(directives []config.IDirective, orderIndex map[s
}
}
}
func (p *Parser) slices2Parameters(slices []string) []config.Parameter {
var parameters []config.Parameter
for _, slice := range slices {
parameters = append(parameters, config.Parameter{Value: slice})
}
return parameters
}
func (p *Parser) parameters2Slices(parameters []config.Parameter) []string {
var s []string
for _, parameter := range parameters {
s = append(s, parameter.Value)
}
return s
}

View File

@@ -13,7 +13,7 @@ func (p *Parser) SetListen(listen [][]string) error {
for _, l := range listen {
directives = append(directives, &config.Directive{
Name: "listen",
Parameters: l,
Parameters: p.slices2Parameters(l),
})
}
@@ -32,7 +32,7 @@ func (p *Parser) SetServerName(serverName []string) error {
return p.Set("server", []*config.Directive{
{
Name: "server_name",
Parameters: serverName,
Parameters: p.slices2Parameters(serverName),
},
})
}
@@ -45,7 +45,7 @@ func (p *Parser) SetIndex(index []string) error {
return p.Set("server", []*config.Directive{
{
Name: "index",
Parameters: index,
Parameters: p.slices2Parameters(index),
},
})
}
@@ -58,7 +58,7 @@ func (p *Parser) SetIndexWithComment(index []string, comment []string) error {
return p.Set("server", []*config.Directive{
{
Name: "index",
Parameters: index,
Parameters: p.slices2Parameters(index),
Comment: comment,
},
})
@@ -72,7 +72,7 @@ func (p *Parser) SetRoot(root string) error {
return p.Set("server", []*config.Directive{
{
Name: "root",
Parameters: []string{root},
Parameters: []config.Parameter{{Value: root}},
},
})
}
@@ -85,7 +85,7 @@ func (p *Parser) SetRootWithComment(root string, comment []string) error {
return p.Set("server", []*config.Directive{
{
Name: "root",
Parameters: []string{root},
Parameters: []config.Parameter{{Value: root}},
Comment: comment,
},
})
@@ -104,7 +104,7 @@ func (p *Parser) SetIncludes(includes []string, comments [][]string) error {
}
directives = append(directives, &config.Directive{
Name: "include",
Parameters: []string{item},
Parameters: []config.Parameter{{Value: item}},
Comment: comment,
})
}
@@ -125,13 +125,13 @@ func (p *Parser) SetPHP(php int) error {
var foundFlag bool
for _, item := range old {
// 查找enable-php的配置
if slices.ContainsFunc(item.GetParameters(), func(s string) bool {
if slices.ContainsFunc(p.parameters2Slices(item.GetParameters()), func(s string) bool {
return strings.HasPrefix(s, "enable-php-") && strings.HasSuffix(s, ".conf")
}) {
foundFlag = true
directives = append(directives, &config.Directive{
Name: item.GetName(),
Parameters: []string{fmt.Sprintf("enable-php-%d.conf", php)},
Parameters: []config.Parameter{{Value: fmt.Sprintf("enable-php-%d.conf", php)}},
Comment: item.GetComment(),
})
} else {
@@ -148,7 +148,7 @@ func (p *Parser) SetPHP(php int) error {
if !foundFlag {
directives = append(directives, &config.Directive{
Name: "include",
Parameters: []string{fmt.Sprintf("enable-php-%d.conf", php)},
Parameters: []config.Parameter{{Value: fmt.Sprintf("enable-php-%d.conf", php)}},
})
}
@@ -192,35 +192,35 @@ func (p *Parser) SetHTTPS(cert, key string) error {
return p.Set("server", []*config.Directive{
{
Name: "ssl_certificate",
Parameters: []string{cert},
Parameters: []config.Parameter{{Value: cert}},
},
{
Name: "ssl_certificate_key",
Parameters: []string{key},
Parameters: []config.Parameter{{Value: key}},
},
{
Name: "ssl_session_timeout",
Parameters: []string{"1d"},
Parameters: []config.Parameter{{Value: "1d"}},
},
{
Name: "ssl_session_cache",
Parameters: []string{"shared:SSL:10m"},
Parameters: []config.Parameter{{Value: "shared:SSL:10m"}},
},
{
Name: "ssl_protocols",
Parameters: []string{"TLSv1.2", "TLSv1.3"},
Parameters: []config.Parameter{{Value: "TLSv1.2"}, {Value: "TLSv1.3"}},
},
{
Name: "ssl_ciphers",
Parameters: []string{"ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305"},
Parameters: []config.Parameter{{Value: "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305"}},
},
{
Name: "ssl_prefer_server_ciphers",
Parameters: []string{"off"},
Parameters: []config.Parameter{{Value: "off"}},
},
{
Name: "ssl_early_data",
Parameters: []string{"on"},
Parameters: []config.Parameter{{Value: "on"}},
},
})
}
@@ -233,7 +233,7 @@ func (p *Parser) SetHTTPSProtocols(protocols []string) error {
return p.Set("server", []*config.Directive{
{
Name: "ssl_protocols",
Parameters: protocols,
Parameters: p.slices2Parameters(protocols),
},
})
}
@@ -246,7 +246,7 @@ func (p *Parser) SetHTTPSCiphers(ciphers string) error {
return p.Set("server", []*config.Directive{
{
Name: "ssl_ciphers",
Parameters: []string{ciphers},
Parameters: []config.Parameter{{Value: ciphers}},
},
})
}
@@ -263,11 +263,11 @@ func (p *Parser) SetOCSP(ocsp bool) error {
return p.Set("server", []*config.Directive{
{
Name: "ssl_stapling",
Parameters: []string{"on"},
Parameters: []config.Parameter{{Value: "on"}},
},
{
Name: "ssl_stapling_verify",
Parameters: []string{"on"},
Parameters: []config.Parameter{{Value: "on"}},
},
})
}
@@ -287,12 +287,12 @@ func (p *Parser) SetHSTS(hsts bool) error {
var directives []*config.Directive
var foundFlag bool
for _, dir := range old {
if slices.Contains(dir.GetParameters(), "Strict-Transport-Security") {
if slices.Contains(p.parameters2Slices(dir.GetParameters()), "Strict-Transport-Security") {
foundFlag = true
if hsts {
directives = append(directives, &config.Directive{
Name: dir.GetName(),
Parameters: []string{"Strict-Transport-Security", "max-age=31536000"},
Parameters: []config.Parameter{{Value: "Strict-Transport-Security"}, {Value: "max-age=31536000"}},
Comment: dir.GetComment(),
})
}
@@ -308,7 +308,7 @@ func (p *Parser) SetHSTS(hsts bool) error {
if !foundFlag && hsts {
directives = append(directives, &config.Directive{
Name: "add_header",
Parameters: []string{"Strict-Transport-Security", "max-age=31536000"},
Parameters: []config.Parameter{{Value: "Strict-Transport-Security"}, {Value: "max-age=31536000"}},
})
}
@@ -329,7 +329,7 @@ func (p *Parser) SetHTTPRedirect(httpRedirect bool) error {
var foundFlag bool
for _, dir := range ifs { // 所有 if
if !httpRedirect {
if len(dir.GetParameters()) == 3 && dir.GetParameters()[0] == "($scheme" && dir.GetParameters()[1] == "=" && dir.GetParameters()[2] == "http)" {
if len(dir.GetParameters()) == 3 && dir.GetParameters()[0].GetValue() == "($scheme" && dir.GetParameters()[1].GetValue() == "=" && dir.GetParameters()[2].GetValue() == "http)" {
continue
}
}
@@ -337,12 +337,12 @@ func (p *Parser) SetHTTPRedirect(httpRedirect bool) error {
for _, dir2 := range dir.GetBlock().GetDirectives() { // 每个 if 中所有指令
if !httpRedirect {
// 不启用http重定向则判断并移除特定的return指令
if dir2.GetName() != "return" && !slices.Contains(dir2.GetParameters(), "https://$host$request_uri") {
if dir2.GetName() != "return" && !slices.Contains(p.parameters2Slices(dir2.GetParameters()), "https://$host$request_uri") {
ifDirectives = append(ifDirectives, dir2)
}
} else {
// 启用http重定向需要检查防止重复添加
if dir2.GetName() == "return" && slices.Contains(dir2.GetParameters(), "https://$host$request_uri") {
if dir2.GetName() == "return" && slices.Contains(p.parameters2Slices(dir2.GetParameters()), "https://$host$request_uri") {
foundFlag = true
}
ifDirectives = append(ifDirectives, dir2)
@@ -364,13 +364,13 @@ func (p *Parser) SetHTTPRedirect(httpRedirect bool) error {
ifDir := &config.Directive{
Name: "if",
Block: &config.Block{},
Parameters: []string{"($scheme", "=", "http)"},
Parameters: []config.Parameter{{Value: "($scheme"}, {Value: "="}, {Value: "http)"}},
}
redirectDir := &config.Directive{
Name: "return",
Parameters: []string{"308", "https://$host$request_uri"},
Parameters: []config.Parameter{{Value: "308"}, {Value: "https://$host$request_uri"}},
}
redirectDir.SetParent(ifDir.GetBlock())
redirectDir.SetParent(ifDir.GetParent())
ifBlock := ifDir.GetBlock().(*config.Block)
ifBlock.Directives = append(ifBlock.Directives, redirectDir)
directives = append(directives, ifDir)
@@ -393,7 +393,7 @@ func (p *Parser) SetHTTPRedirect(httpRedirect bool) error {
for _, dir := range errorPages {
if !httpRedirect {
// 不启用https重定向则判断并移除特定的return指令
if !slices.Contains(dir.GetParameters(), "497") && !slices.Contains(dir.GetParameters(), "https://$host:$server_port$request_uri") {
if !slices.Contains(p.parameters2Slices(dir.GetParameters()), "497") && !slices.Contains(p.parameters2Slices(dir.GetParameters()), "https://$host:$server_port$request_uri") {
directives = append(directives, &config.Directive{
Block: dir.GetBlock(),
Name: dir.GetName(),
@@ -403,7 +403,7 @@ func (p *Parser) SetHTTPRedirect(httpRedirect bool) error {
}
} else {
// 启用https重定向需要检查防止重复添加
if slices.Contains(dir.GetParameters(), "497") && slices.Contains(dir.GetParameters(), "https://$host:$server_port$request_uri") {
if slices.Contains(p.parameters2Slices(dir.GetParameters()), "497") && slices.Contains(p.parameters2Slices(dir.GetParameters()), "https://$host:$server_port$request_uri") {
found497 = true
}
directives = append(directives, &config.Directive{
@@ -418,7 +418,7 @@ func (p *Parser) SetHTTPRedirect(httpRedirect bool) error {
if !found497 && httpRedirect {
directives = append(directives, &config.Directive{
Name: "error_page",
Parameters: []string{"497", "=308", "https://$host:$server_port$request_uri"},
Parameters: []config.Parameter{{Value: "497"}, {Value: "=308"}, {Value: "https://$host:$server_port$request_uri"}},
})
}
@@ -437,12 +437,12 @@ func (p *Parser) SetAltSvc(altSvc string) error {
var directives []*config.Directive
var foundFlag bool
for _, dir := range old {
if slices.Contains(dir.GetParameters(), "Alt-Svc") {
if slices.Contains(p.parameters2Slices(dir.GetParameters()), "Alt-Svc") {
foundFlag = true
if altSvc != "" { // 为空表示要删除
directives = append(directives, &config.Directive{
Name: dir.GetName(),
Parameters: []string{"Alt-Svc", altSvc},
Parameters: []config.Parameter{{Value: "Alt-Svc"}, {Value: altSvc}},
Comment: dir.GetComment(),
})
}
@@ -458,7 +458,7 @@ func (p *Parser) SetAltSvc(altSvc string) error {
if !foundFlag && altSvc != "" {
directives = append(directives, &config.Directive{
Name: "add_header",
Parameters: []string{"Alt-Svc", altSvc},
Parameters: []config.Parameter{{Value: "Alt-Svc"}, {Value: altSvc}},
})
}
@@ -473,7 +473,7 @@ func (p *Parser) SetAccessLog(accessLog string) error {
return p.Set("server", []*config.Directive{
{
Name: "access_log",
Parameters: []string{accessLog},
Parameters: []config.Parameter{{Value: accessLog}},
},
})
}
@@ -486,7 +486,7 @@ func (p *Parser) SetErrorLog(errorLog string) error {
return p.Set("server", []*config.Directive{
{
Name: "error_log",
Parameters: []string{errorLog},
Parameters: []config.Parameter{{Value: errorLog}},
},
})
}