Skip to content

Commit

Permalink
v1.26.1 (#64)
Browse files Browse the repository at this point in the history
* refactor: remove used open-golang dep

* feat(ruleEngine): match process according to app name on darwin

* feat(executor): allow to enable dns cache on darwin

* Revert "feat(executor): allow to enable dns cache on darwin"

This reverts commit fcfac24.

* chore: add comment

* feat: upgrade dashboard
  • Loading branch information
igoogolx authored Jan 19, 2025
1 parent 1006a77 commit 0a13266
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 26 deletions.
20 changes: 0 additions & 20 deletions api/routes/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"github.com/go-chi/chi/v5"
"github.com/go-chi/render"
configuration2 "github.com/igoogolx/itun2socks/internal/configuration"
"github.com/skratchdot/open-golang/open"
"net"
"net/http"
"os"
Expand All @@ -17,7 +16,6 @@ func settingRouter() http.Handler {
r.Get("/interfaces", getInterfaces)
r.Get("/config-file-dir-path", getConfigDirPath)
r.Get("/executable-path", getExecutablePath)
r.Get("/open-config-file-dir", openConfigDir)
r.Put("/", setSetting)
r.Put("/reset-config", resetConfig)
return r
Expand Down Expand Up @@ -88,24 +86,6 @@ func getExecutablePath(w http.ResponseWriter, r *http.Request) {
})
}

func openConfigDir(w http.ResponseWriter, r *http.Request) {
configFilePath, err := configuration2.GetConfigFilePath()
if err != nil {
render.Status(r, http.StatusInternalServerError)
render.JSON(w, r, NewError(err.Error()))
return
}

dirPath := filepath.Dir(configFilePath)
err = open.Run(dirPath)
if err != nil {
render.Status(r, http.StatusInternalServerError)
render.JSON(w, r, NewError(err.Error()))
return
}
render.JSON(w, r, render.M{})
}

func resetConfig(w http.ResponseWriter, r *http.Request) {
err := configuration2.Reset()
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ require (
github.com/sagernet/sing v0.5.1
github.com/sagernet/sing-tun v0.4.6
github.com/sirupsen/logrus v1.9.3
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/stretchr/testify v1.10.0
go.uber.org/atomic v1.11.0
golang.org/x/sys v0.29.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc=
github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 h1:JIAuq3EEf9cgbU6AtGPK4CTG3Zf6CKMNqf0MHTggAUA=
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
Expand Down
19 changes: 17 additions & 2 deletions internal/cfg/distribution/ruleEngine/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package ruleEngine
import (
"fmt"
"github.com/igoogolx/itun2socks/internal/constants"
"os"
"path/filepath"
"runtime"
"slices"
"strings"
)

Expand All @@ -22,7 +25,19 @@ func (p Process) Type() constants.RuleType {
}

func (p Process) Match(value string) bool {
return strings.EqualFold(filepath.Base(value), p.Payload)
processName := filepath.Base(value)

if runtime.GOOS == "darwin" {
parts := strings.Split(value, string(os.PathSeparator))
targetIndex := slices.IndexFunc(parts, func(s string) bool {
return strings.HasSuffix(s, ".app")
})
if targetIndex != -1 {
processName = parts[targetIndex]
}
}

return strings.EqualFold(processName, p.Payload)
}

func (p Process) Value() string {
Expand All @@ -34,7 +49,7 @@ func (p Process) Valid() bool {
}

func NewProcessRule(ruleType constants.RuleType, payload string, policy constants.Policy) (*Process, error) {
rule := &Process{ruleType, payload, policy}
rule := &Process{ruleType, strings.TrimSpace(payload), policy}
if !rule.Valid() {
return nil, fmt.Errorf("invalid process rule")
}
Expand Down
1 change: 1 addition & 0 deletions internal/cfg/tun.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func NewTun(defaultInterfaceName string) (*Config, error) {
return nil, err
}
disableDnsCache := rawConfig.Setting.Dns.DisableCache
//FIXME: dns cache can't be always disabled
if runtime.GOOS == "darwin" {
disableDnsCache = true
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

func main() {
download("https://github.com/igoogolx/lux-rules/releases/download/v2.4.0/rules.tar.gz", filepath.Join("internal", "cfg", "distribution", "ruleEngine", "rules.tar.gz"))
download("https://github.com/igoogolx/lux-client/releases/download/v1.11.6/dist-ui.tar.gz", filepath.Join("api", "routes", "dist.tar.gz"))
download("https://github.com/igoogolx/lux-client/releases/download/v1.11.7/dist-ui.tar.gz", filepath.Join("api", "routes", "dist.tar.gz"))
}

func download(url string, outputPath string) {
Expand Down

0 comments on commit 0a13266

Please sign in to comment.