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 - name: Setup Go environment
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version: '1.23' go-version: '1.24'
- name: Run - name: Run
uses: golangci/golangci-lint-action@v4 uses: golangci/golangci-lint-action@v8
with: with:
version: v1.61 version: v2.5

View File

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

View File

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

View File

@ -1,13 +1,31 @@
run: version: "2"
timeout: 5m
linters: linters:
disable-all: true default: none
enable: enable:
- gosimple
- govet - govet
- ineffassign - ineffassign
- staticcheck - staticcheck
- typecheck
- whitespace
- unused - 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 { if err = common.ReflectFrom(&conf.ClientCommon); err != nil {
return err return err
} }
for k, v := range conf.ClientCommon.Metas { for k, v := range conf.Metas {
common.Key("meta_" + k).SetValue(v) common.Key("meta_" + k).SetValue(v)
} }
for k, v := range conf.OIDCAdditionalEndpointParams { for k, v := range conf.OIDCAdditionalEndpointParams {
@ -464,7 +464,7 @@ func (conf *ClientConfig) Copy(all bool) *ClientConfig {
newConf := NewDefaultClientConfig() newConf := NewDefaultClientConfig()
newConf.ClientCommon = conf.ClientCommon newConf.ClientCommon = conf.ClientCommon
// We can't share the same log file between different configs // We can't share the same log file between different configs
newConf.ClientCommon.LogFile = "" newConf.LogFile = ""
if all { if all {
for _, proxy := range conf.Proxies { for _, proxy := range conf.Proxies {
var newProxy = *proxy var newProxy = *proxy

View File

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

View File

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

View File

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