summaryrefslogtreecommitdiff
path: root/cmd/resolver/resolver.go
AgeCommit message (Collapse)Author
2024-03-21all: move repository to SourceHutShulhan
2024-03-21all: replace module "share" with "pakakeh.go"Shulhan
The module "share" has been moved to new repository at SourceHut and we rename it to make it more unique instead of common English words "share".
2024-02-04all: apply recommendation from linter reviveShulhan
2023-09-23cmd/resolver: replace "math/rand" with "crypto/rand"Shulhan
The random number from "math/rand" is predictable if the seed is known. Even though the random number here is only for generating unique request ID, we still need to prevent this by using more secure random number.
2023-09-23go.mod: update all dependencies and set Go mod version to 1.20Shulhan
The update on share module affect the following changes, * lib/dns: removing dns.ZoneRecords, replacing it with map[string][]*dns.ResourceRecord * lib/dns: file Name in Zone renamed to Origin * lib/dns: replace call to Caches.InternalPopulate with InternalPopulateZone that accept zone as parameter
2022-06-09all: change the HTTP API to update hosts in block.dShulhan
We have HTTP API to enable or disable block.d by batch by passing all block.d records. The name of HTTP API is /v2/block.d/update and this is duplicate with API to update the content of hosts in block.d. This changes fix this by creating new HTTP API /v2/block.d/fetch that fetch the latest hosts file from specific block.d by its name. While at it, - reformat html and JavaScript files using js-beautify - rename constants and methods for HTTP APIs - add and update comments for some HTTP APIs
2022-05-22all: use the exported Blockd type instead of interface{}Shulhan
Since we have exported the Blockd type from rescached package, any Blockd operation on the HTTP server and on the client on cmd/resolver can use it instead of using interface{}.
2022-05-22cmd/resolver: implement command to list hosts in block.dShulhan
Given the following command $ resolver block.d It will print all hosts in block.d in the JSON format, for example { "pgl.yoyo.org": { "Name": "pgl.yoyo.org", "URL": "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts\u0026showintro=0\u0026startdate[day]=\u0026startdate[month]=\u0026startdate[year]=\u0026mimetype=plaintext", "LastUpdated": "2022-04-20 01:54:30 WIB", "IsEnabled": false }, "someonewhocares.org": { "Name": "someonewhocares.org", "URL": "http://someonewhocares.org/hosts/hosts", "LastUpdated": "2022-04-20 00:53:22 WIB", "IsEnabled": false }, "winhelp2002.mvps.org": { "Name": "winhelp2002.mvps.org", "URL": "http://winhelp2002.mvps.org/hosts.txt", "LastUpdated": "2022-04-20 01:35:38 WIB", "IsEnabled": false } }
2022-05-17cmd/resolver: implement command to delete record on zoneShulhan
Given the following command $ resolver zone.d rr delete <zone> <"@" | subdomain> <type> <class> <value> It will delete the record in zone by given subdomain, type, class, and value.
2022-05-16cmd/resolver: implement command to get records on zoneShulhan
Given the following command, $ resolver zone.d rr get <zone> It will fetch and print all records in the specific <zone>.
2022-05-16cmd/resolver: add command to fetch and print all zonesShulhan
The command has the following format, resolver zone.d
2022-05-15cmd/resolver: implement command to add new record to zoneShulhan
The command has the following signature, zone.d rr add <zone> <"@" | subdomain> <ttl> <type> <class> <value> ...:: The domain name can be set to origin using "@" or empty string, subdomain (without ending with "."), or fully qualified domain name (end with "."). If ttl is set to 0, it will default to 604800 (7 days). List of valid type are A, NS, CNAME, PTR, MX, TXT, and AAAA. List of valid class are IN, CS, HS.
2022-05-14cmd/resolver: implement command to create and delete zone fileShulhan
The command to create new zone file has the following signature: zone.d create <name> While command to delete zone file has the following signature: zone.d delete <name>
2022-05-13cmd/resolver: implement command to delete record on hosts fileShulhan
The command has the following signature, resolver hosts.d rr delete <name> <domain> Given the hosts name "hosts" and domain "my.hosts" it will delete all records that have domain name "my.hosts" inside the file.
2022-05-11cmd/resolver: implement command to add new record to hosts fileShulhan
The command has the following signature, resolver hosts.d rr add <name> <domain> <value> Given the hosts file name "hosts" and domain "my.hosts" with value "127.0.0.1", it will add new line "127.0.0.1 my.hosts" to the "hosts" file. If the domain name already exists, the new record will be appended instead of replaced.
2022-04-24cmd/resolver: move handling command env to resolverShulhan
2022-04-24cmd/resolver: simplify handling command "caches"Shulhan
Instead of splitting them into three methods, merge them into single method doCmdCaches.
2022-04-24cmd/resolver: simplify method to handle block.d commandShulhan
Instead of splitting them into three methods, merge them into single method.
2022-04-24cmd/resolver: implement command to manage hosts.dShulhan
The resolver cli now have command "hosts.d" to create, delete, and get the hosts file inside the hosts.d in the rescached server.
2022-04-21cmd/resolver: implement command to disable or enable hosts in block.dShulhan
The following command enable specific hosts in block.d by name: resolver block.d enable <name> and the following command disable it resolver block.d disable <name>
2022-04-20cmd/resolver: implement command to update block.d hosts by its nameShulhan
The following command: "resolver block.d update x" will fetch the latest hosts file from the block.d provider "x" based on its registered URL.
2022-04-16cmd/resolver: implement sub command to update environmentShulhan
The env command now accept sub command "update" with argument path to the file or "-" for standard input. The content of file is formatted using JSON, the same as output of "env" command. If the content of file is valid, server will be restarted immediately.
2022-04-16cmd/resolver: implement command to fetch and print server environmentShulhan
The "env" command fetch the current server environment and print as ini format to stdout.
2022-04-15cmd/resolver: check for number of answer when processing queryShulhan
If the number of Answer is zero, break the attempt and continue the next query name. This is to fix the loop end when server return OK but with zero answer.
2022-04-15cmd/resolver: replace populateQueries with lib/net ResolvConfShulhan
Since share 9329196125fe, the populateQueries has been moved to package lib/net as a method of ResolvConf.
2022-04-15cmd/resolver: print the Answer ReceivedAt and AccessedAt from nowShulhan
Instead of printing the full date and time, print the ReceivedAt and AccessedAt fields in the perspective of current time. For example, 1m ago, 30s ago.
2022-04-15all: implement sub command to remove caches by domain nameShulhan
The "caches" command accept second sub command "remove" that accept single domain name to be removed from caches. This changes affect the HTTP API for caches delete to return the removed answer on the response data.
2022-04-15cmd/resolver: implement command to search the cachesShulhan
The "caches" command accept sub command "search" with a string argument. Given the following command "caches search bit", the resolver will call HTTP API to rescached server to search for caches that have name contains bit.
2022-04-14cmd/resolver: implement caches commandShulhan
The caches command fetch and print all caches from rescached server.
2022-04-14cmd/resolver: refactor the resolver as client of DNS and rescachedShulhan
Previously, the resolver command only for querying DNS server. In this changes and in the future, the resolver command will be client for DNS and rescached server.