Skip to content

Commit

Permalink
use iterators for user
Browse files Browse the repository at this point in the history
  • Loading branch information
geovex committed Aug 21, 2024
1 parent 40e5cd6 commit 3fe4558
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ Inspired by [mtprotoproxy](https://github.com/alexbers/mtprotoproxy)

## Building ##

You will most likely need `go 1.21`
You will most likely need `go 1.23`

```shell
go mod download

go build ./cmd/tgp
```

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/geovex/tgp

go 1.21
go 1.23

require (
github.com/BurntSushi/toml v1.3.2
Expand Down
13 changes: 6 additions & 7 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,14 @@ func (c *Config) GetUserSecret(user string) (string, error) {
}
}

func (c *Config) IterateUsers() chan *User {
result := make(chan *User)
go func() {
defer close(result)
func (c *Config) IterateUsers() func(func(*User) bool) {
return func(fn func(*User) bool) {
for _, u := range c.users.Users {
result <- u
if fn(u) {
return
}
}
}()
return result
}
}

func (c *Config) GetDefaultSocks() (url, user, pass *string) {
Expand Down

0 comments on commit 3fe4558

Please sign in to comment.