-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
google-safe-search-example #78
base: master
Are you sure you want to change the base?
Conversation
Sorted those soft-tabs :) |
|
||
# build google force safe search ruls for rubyDNS | ||
|
||
google_domains = `curl https://www.google.com/supported_domains 2>> /dev/null | sed "s/^.//g"`.split("\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be improved.
require 'async'
require 'async/http/internet'
google_domains = Sync do
internet = Async::HTTP::Internet.new
response = internet.get("https://www.google.com/supported_domains")
response.read.split(/\n/)
ensure
response&.close
end
IN = Resolv::DNS::Resource::IN | ||
|
||
# Start the RubyDNS server | ||
RubyDNS::run_server(INTERFACES) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
domains = Regexp.union(google_domains)
# Start the RubyDNS server
RubyDNS::run_server(INTERFACES) do
@logger.debug!
match(domains, IN::A) do |transaction|
transaction.respond!(Name.create('forcesafesearch.google.com'), resource_class: IN::CNAME)
end
otherwise do |transaction|
transaction.passthrough!(UPSTREAM)
end
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might need to tweak domains
but this should avoid having to generate a script/server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
domains = /#{Regexp.union(google_domains)}\z/
maybe sufficient.
@logger.debug! | ||
|
||
#match google.com | ||
match(/^google.com$/, IN::A) do |transaction| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to preserve sub-domains such as admin.google.com, docs.google.com etc.
It may be necessary to do an exact match. Maybe Google handles this? Probably better to only override the specific top level domains for the force safe search?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do like the idea you suggested if that can work. Even if it is just matching the exact domains within an array.
Example added for forced Google safe search using DNS.