Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Simple socks5 server using go-socks5 with authentication, allowed ips list and d
|PROXY_USER|String|EMPTY|Set proxy user (also required existed PROXY_PASS)|
|PROXY_PASSWORD|String|EMPTY|Set proxy password for auth, used with PROXY_USER|
|PROXY_PORT|String|1080|Set listen port for application inside docker container|
|ALLOWED_DEST_FQDN|String|EMPTY|Allowed destination address regular expression pattern. Default allows all.|
|ALLOWED_DEST_FQDN|String|EMPTY|Allowed destination address regular expression pattern. Default allows all. Examples "(192.168.0.1|go.dev)"|
|ALLOWED_IPS|String|Empty|Set allowed IP's that can connect to proxy, separator `,`|


Expand Down
11 changes: 9 additions & 2 deletions ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ type PermitDestAddrPatternRuleSet struct {
}

func (p *PermitDestAddrPatternRuleSet) Allow(ctx context.Context, req *socks5.Request) (context.Context, bool) {
match, _ := regexp.MatchString(p.AllowedFqdnPattern, req.DestAddr.FQDN)
return ctx, match
var match bool
if req.DestAddr.FQDN != "" {
match, _ = regexp.MatchString(p.AllowedFqdnPattern, req.DestAddr.FQDN)
} else if req.DestAddr.IP != nil {
match, _ = regexp.MatchString(p.AllowedFqdnPattern, req.DestAddr.IP.String())
} else {
match = true
}
return ctx, match
}