Update golangci-lint version

This commit is contained in:
Gerhard Tan
2025-09-29 09:54:58 +08:00
parent d119834272
commit f628c39287
8 changed files with 55 additions and 39 deletions

View File

@ -18,9 +18,9 @@ jobs:
- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: '1.24'
- name: Run
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v8
with:
version: v1.61
version: v2.5

View File

@ -18,7 +18,7 @@ jobs:
- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: '1.24'
- name: Setup VS environment
shell: powershell

View File

@ -21,7 +21,7 @@ jobs:
- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: '1.24'
- name: Setup VS environment
shell: powershell
@ -72,7 +72,7 @@ jobs:
- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: '1.24'
- name: Test
run: go test -v ./...

View File

@ -1,13 +1,31 @@
run:
timeout: 5m
version: "2"
linters:
disable-all: true
default: none
enable:
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- whitespace
- unused
- whitespace
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- staticcheck
text: should not use dot imports
paths:
- third_party$
- builtin$
- examples$
formatters:
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$

View File

@ -347,7 +347,7 @@ func (conf *ClientConfig) saveINI(path string) error {
if err = common.ReflectFrom(&conf.ClientCommon); err != nil {
return err
}
for k, v := range conf.ClientCommon.Metas {
for k, v := range conf.Metas {
common.Key("meta_" + k).SetValue(v)
}
for k, v := range conf.OIDCAdditionalEndpointParams {
@ -464,7 +464,7 @@ func (conf *ClientConfig) Copy(all bool) *ClientConfig {
newConf := NewDefaultClientConfig()
newConf.ClientCommon = conf.ClientCommon
// We can't share the same log file between different configs
newConf.ClientCommon.LogFile = ""
newConf.LogFile = ""
if all {
for _, proxy := range conf.Proxies {
var newProxy = *proxy

View File

@ -521,7 +521,7 @@ func clientProxyBaseToV1(c *BaseProxyConf) (v1.ProxyBaseConfig, error) {
if err != nil {
return r, err
}
r.ProxyBackend.LocalPort = localPort
r.LocalPort = localPort
}
bl, err := types.NewBandwidthQuantity(c.BandwidthLimit)
if err != nil {
@ -530,7 +530,7 @@ func clientProxyBaseToV1(c *BaseProxyConf) (v1.ProxyBaseConfig, error) {
r.Transport.BandwidthLimit = bl
switch c.Plugin {
case consts.PluginHttp2Https:
r.ProxyBackend.Plugin.ClientPluginOptions = &v1.HTTP2HTTPSPluginOptions{
r.Plugin.ClientPluginOptions = &v1.HTTP2HTTPSPluginOptions{
Type: c.Plugin,
LocalAddr: c.PluginLocalAddr,
HostHeaderRewrite: c.PluginHostHeaderRewrite,
@ -539,7 +539,7 @@ func clientProxyBaseToV1(c *BaseProxyConf) (v1.ProxyBaseConfig, error) {
},
}
case consts.PluginHttp2Http:
r.ProxyBackend.Plugin.ClientPluginOptions = &v1.HTTP2HTTPPluginOptions{
r.Plugin.ClientPluginOptions = &v1.HTTP2HTTPPluginOptions{
Type: c.Plugin,
LocalAddr: c.PluginLocalAddr,
HostHeaderRewrite: c.PluginHostHeaderRewrite,
@ -548,13 +548,13 @@ func clientProxyBaseToV1(c *BaseProxyConf) (v1.ProxyBaseConfig, error) {
},
}
case consts.PluginHttpProxy:
r.ProxyBackend.Plugin.ClientPluginOptions = &v1.HTTPProxyPluginOptions{
r.Plugin.ClientPluginOptions = &v1.HTTPProxyPluginOptions{
Type: c.Plugin,
HTTPUser: c.PluginHttpUser,
HTTPPassword: c.PluginHttpPasswd,
}
case consts.PluginHttps2Http:
r.ProxyBackend.Plugin.ClientPluginOptions = &v1.HTTPS2HTTPPluginOptions{
r.Plugin.ClientPluginOptions = &v1.HTTPS2HTTPPluginOptions{
Type: c.Plugin,
LocalAddr: c.PluginLocalAddr,
HostHeaderRewrite: c.PluginHostHeaderRewrite,
@ -566,7 +566,7 @@ func clientProxyBaseToV1(c *BaseProxyConf) (v1.ProxyBaseConfig, error) {
KeyPath: c.PluginKeyPath,
}
case consts.PluginHttps2Https:
r.ProxyBackend.Plugin.ClientPluginOptions = &v1.HTTPS2HTTPSPluginOptions{
r.Plugin.ClientPluginOptions = &v1.HTTPS2HTTPSPluginOptions{
Type: c.Plugin,
LocalAddr: c.PluginLocalAddr,
HostHeaderRewrite: c.PluginHostHeaderRewrite,
@ -578,13 +578,13 @@ func clientProxyBaseToV1(c *BaseProxyConf) (v1.ProxyBaseConfig, error) {
KeyPath: c.PluginKeyPath,
}
case consts.PluginSocks5:
r.ProxyBackend.Plugin.ClientPluginOptions = &v1.Socks5PluginOptions{
r.Plugin.ClientPluginOptions = &v1.Socks5PluginOptions{
Type: c.Plugin,
Username: c.PluginUser,
Password: c.PluginPasswd,
}
case consts.PluginStaticFile:
r.ProxyBackend.Plugin.ClientPluginOptions = &v1.StaticFilePluginOptions{
r.Plugin.ClientPluginOptions = &v1.StaticFilePluginOptions{
Type: c.Plugin,
LocalPath: c.PluginLocalPath,
StripPrefix: c.PluginStripPrefix,
@ -592,12 +592,12 @@ func clientProxyBaseToV1(c *BaseProxyConf) (v1.ProxyBaseConfig, error) {
HTTPPassword: c.PluginHttpPasswd,
}
case consts.PluginUnixDomain:
r.ProxyBackend.Plugin.ClientPluginOptions = &v1.UnixDomainSocketPluginOptions{
r.Plugin.ClientPluginOptions = &v1.UnixDomainSocketPluginOptions{
Type: c.Plugin,
UnixPath: c.PluginUnixPath,
}
case consts.PluginTLS2Raw:
r.ProxyBackend.Plugin.ClientPluginOptions = &v1.TLS2RawPluginOptions{
r.Plugin.ClientPluginOptions = &v1.TLS2RawPluginOptions{
Type: c.Plugin,
LocalAddr: c.PluginLocalAddr,
CrtPath: c.PluginCrtPath,

View File

@ -499,25 +499,25 @@ func (pd *EditProxyDialog) onSave() {
}
}
// Update metadata
pd.binder.Proxy.Metas = pd.metaModel.AsMap()
pd.binder.Metas = pd.metaModel.AsMap()
// Update role
if pd.binder.Visitor {
pd.binder.Proxy.Role = "visitor"
pd.binder.Role = "visitor"
} else {
pd.binder.Proxy.Role = ""
pd.binder.Role = ""
}
// Update bandwidth
if pd.binder.BandwidthNum > 0 {
pd.binder.Proxy.BandwidthLimit = strconv.FormatInt(pd.binder.BandwidthNum, 10) + pd.binder.BandwidthUnit
if pd.binder.Proxy.BandwidthLimitMode == consts.BandwidthMode[0] {
pd.binder.Proxy.BandwidthLimitMode = ""
pd.binder.BandwidthLimit = strconv.FormatInt(pd.binder.BandwidthNum, 10) + pd.binder.BandwidthUnit
if pd.binder.BandwidthLimitMode == consts.BandwidthMode[0] {
pd.binder.BandwidthLimitMode = ""
}
} else {
pd.binder.Proxy.BandwidthLimit = ""
pd.binder.Proxy.BandwidthLimitMode = ""
pd.binder.BandwidthLimit = ""
pd.binder.BandwidthLimitMode = ""
}
pd.binder.Proxy.LocalPort = strings.TrimSpace(pd.binder.Proxy.LocalPort)
pd.binder.Proxy.RemotePort = strings.TrimSpace(pd.binder.Proxy.RemotePort)
pd.binder.LocalPort = strings.TrimSpace(pd.binder.LocalPort)
pd.binder.RemotePort = strings.TrimSpace(pd.binder.RemotePort)
if ok := pd.validateProxy(pd.binder.Proxy); !ok {
return
}

View File

@ -238,10 +238,8 @@ func (pv *PanelView) Invalidate(state bool) {
pv.addressText.SetText(addr)
}
pv.protoImage.SetVisible(data.TLSEnable || data.Protocol == consts.ProtoWSS || data.Protocol == consts.ProtoQUIC)
proto := data.Protocol
if proto == "" {
proto = consts.ProtoTCP
} else if proto == consts.ProtoWebsocket {
proto := util.GetOrElse(data.Protocol, consts.ProtoTCP)
if proto == consts.ProtoWebsocket {
proto = "ws"
}
proto = strings.ToUpper(proto)