I have set up a tor relay to aid people in countries without free press. How can I limit the use to such countries (e.g. by country code) and prevent the use of my bandwith for users from all other countries?
As an anonymity network, relays don't learn geographical information of Tor clients (edit: in the general case) so this isn't possible. You could instead run a private bridge, and give out the bridge address to people in those countries (and possibly add a firewall rule to block IP addresses outside of your intended countries).