Add Country-Based IP Filtering (--allowed-countries flag)#16
Open
mreza0100 wants to merge 1 commit intossmirr:masterfrom
Open
Add Country-Based IP Filtering (--allowed-countries flag)#16mreza0100 wants to merge 1 commit intossmirr:masterfrom
mreza0100 wants to merge 1 commit intossmirr:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi there to internet robin hoods!
Problem
Conduit proxy operators who want to specifically serve users in censored regions (e.g., Iran) currently have no way to restrict connections by country. Since Conduit uses WebRTC via Psiphon's broker, traditional IP filtering at the OS level (iptables, firewalld) doesn't work—the filtering must happen at the application layer using GeoIP lookup.
Solution
This PR adds a
--allowed-countriesflag that filters incoming connections based on GeoIP country code. Only connections from specified countries are allowed; all others are blocked and logged.Changes
New package:
cli/internal/filter/country_filter.goIsAllowed(ip)returns whether connection should proceedModified files:
cli/internal/config/config.go- Pass AllowedCountries through configcli/cmd/start.go- Add--allowed-countriesStringSlice flagcli/internal/conduit/service.go- Initialize filter and check connections inOnInproxyConnectionEstablishedcallbackUsage
Output
Notes
github.com/oschwald/geoip2-golangdependencygeo.EnsureDatabase()--allowed-countriesflag is not set (default behavior unchanged)