| Age | Commit message (Collapse) | Author |
|
Fix the code as recommended by linters, for example using context for
HTTP client request, using 0600 for file permission, using string
concatenation instead of fmt, using "%w" for error, and reorder defer.
|
|
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".
|
|
|
|
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
|
|
While at it, use "_" for unused parameter on methods.
|
|
Previously those fields exported because web client need it to initialize
the content for /hosts.d and /zone.d pages.
Since we now have HTTP API for that, web client can call get request
to the respective API without depends on the environment.
|
|
When calling API for zone.d record delete, client send the fully
qualified domain name on record to be deleted, but caches store only
the subdomains internally.
This cause the delete action fail, because no internal record match
with request.
|
|
This is to provide an HTTP API to fetch list of hosts.d files on the
server.
|
|
There are two issues when updating environment.
One is on the front, where debug value is send as string.
Another one is the back, where new environment overwrite all of options
where it should only update only DNS server options and Debug fields.
|
|
In the commit 0b92dbb8463d, we changes the field HostsBlocks in
Environment to HostBlockd, but we forgot to changes the code in
the web.
This changes fix this issue.
|
|
This changes affect the dns Server where all caches related methods has
been moved to field Caches.
|
|
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
|
|
Given the following request,
GET /api/block.d
It will return list of hosts in block.d as JSON format:
{
"data": {
"<name>": <Blockd>
...
}
}
|
|
In the Environment, we have a field HostsBlocks that reference
an unexported type hostsFile.
In order for any package to be able to use this field, we need to
export this type.
While at it, we rename the type from hostsBlock to Blockd to make it
simple and consistent with name.
|
|
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.
|
|
Some zone APIs use "name" and some use "zone" for passing the zone
name.
This changes made all zone APIs to use "name" as parameter name.
|
|
Sending the following request to HTTP server:
GET /api/zone.d/rr?zone=<string>
where zone parameter is the zone name, it will return list of records
in that zone.
|
|
|
|
The HTTP API has the following format,
GET /api/zone.d
On success, it will return HTTP status code 200 with all zone formatted
as JSON in the body.
|
|
|
|
Previously, the HTTP API for deleting a record is by passing the
parameters as JSON in the body.
This may cause issue if HTTP client does not support sending body
in DELETE method.
This changes the method to pass the parameters in the query,
DELETE /zone.d/rr?zone=<string>&type=<string>&record=<base64 json>
Parameters,
- zone: the zone name,
- type: the record type,
- record: the content of record with its domain name and value.
|
|
Previously, the request for adding new record on zone file is by passing
the zone name and type inside the path,
/zone.d/:name/rr/:type
This commit changes it to pass all parameters inside the request body
as JSON,
{
"zone": <string>,
"kind": <string>,
"record": <base64 string|base64 JSON>
}
For example, to add A record for subdomain "www" to zone file "my.zone",
the request format would be,
{
"zone": "my.zone",
"kind": "A",
"record": "eyJOYW1lIjoid3d3IiwiVmFsdWUiOiIxMjcuMC4wLjEifQ=="
}
Where "record" value is equal to `{"Name":"www","Value":"127.0.0.1"}`.
On the response, we changes it to return only the new record instead of
all record in the zone.
|
|
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>
|
|
Previously, the the HTTP API for creating and deleting zone file is
by passing the zone file name in path of URL.
This changes move the parameter name to POST body when creating new
zone file and in the DELETE query when deleting zone file.
|
|
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.
|
|
There are two APIs to manage hosts.d RR: create and delete.
Previously, the create API pass the hosts name inside and values inside
the path,
POST /hosts.d/<name>/rr?domain=&value=
This commit changes the request type to form, so all parameters move
to body,
POST /hosts.d/rr
Content-Type: application/x-www-form-urlencoded
name=&domain=&value=
On delete API, we changes the name parameter to be send on query
parameter along with domain to be deleted.
Previously, the delete API was
DELETE /hosts.d/<name>/rr?domain=
now it become
DELETE /hosts.d/rr?name=&domain=
|
|
Instead of returning empty data, return the affected hosts file when
creating a new one or when deleting existing one.
|
|
Using dynamic value in the URL path is not a good practice, so we
move the API for hosts.d to create, delete, and get to form and query
parameters.
|
|
Instead of passing whole block.d object with single field Name set,
send the request using urlencoded form.
|
|
The URL /api/block.d/enable activate the hosts in block.d, while
The URL /api/block.d/disable deactivate the hosts in block.d.
Both of this API accept single parameter "name" in the body as
application/x-www-form-urlencoded.
|
|
The API receive the block.d name and if it valid, the server will
fetch latest hosts file from the block provider based on the registered
URL.
|
|
This is to make all terminology to be consistent, from configuration to
page URL, and API.
|
|
Previously, running an instance of rescached assume that all
configurations and cache are located in /etc/rescached and
/var/cache/rescached.
It possible that we may want to use different base directory (or $PREFIX,
in the auto tools terms), for example "/opt/rescached" or as showed
in the "dev" task in the Makefile, we use "_test" as base directory
for running test instance.
This changes also fix an error when loading hosts file from non-existant
hosts.d directory.
|
|
This changes add new directory called "block.d" under rescached.
This directory contains hosts file fetched from URL defined in hosts
block configuration.
In this way, we did not mixed between user created hosts file and
external hosts file.
In the configuration file, we changes the hosts block format from
single line
hosts_block = <URL>
into subsection with dynamic name,
[block.d "<name>"]
name = <name>
url = <URL>
|
|
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.
|
|
List of changes,
* Remove unused constants keyIsEnabled, keyIsSystem, and keyLastUpdated.
* Use the method String on instance of Duration instead of fmt.Sprintf.
* Replace any usage of io/ioutil package with its replacement.
* Check for error from calling Environment.init and Zone.Add.
* Prefix all returned error on hostsBlock.update method.
* Add "lint" task as part of default target, build.
|
|
On the HTTP side, if the query parameter "name" for "DELETE /api/caches"
is "all" it will remove all caches.
On the resolver side, if the parameter for "caches remove" is "all"
it will remove all caches.
This changes require latest lib/dns on share module.
|
|
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.
|
|
Both types are similar, since the lib/http already imported we replace
the internal response to minimize duplicate and confusion later.
While at it, use consistent variable naming and declaration using var
in all methods.
|
|
See https://kilabit.info/journal/2022/gpl/ for more information.
|
|
Previously, the options for HTTP server initialized internally, which
make it uneasy to changes the default rescached instance when running
in development mode.
This commit move the HTTP server initialization inside the Environment
init method. If its nil, the init will set the default HTTP server
options along with the Memfs.
|
|
Previously, we initialize the rescached Server by passing the
path to configuration file and initialize the environment inside the
server.
This commit changes it to pass the instance of Environment. The idea
is to allow creating and running rescached Server without creating
configuration file first.
|
|
This changes update the code based on refactoring on lib/dns package
on share module.
|
|
Changes affected by update,
* lib/http: changes on Endpoint.Call function signature
* lib/http: changes on CORS configuration
* lib/test: changes on the Assert function signature
|
|
When user open the rescached web interface, the front page will
render and refresh the list of non-local caches per 10 seconds.
|
|
|
|
This changes affect how the memfs.New and GoGenenerate called, does not
affect the user.
|
|
* Add function to search and remove non-local caches
* Refactoring no how to create and remove record from hosts file
|
|
* Trim dot "." suffix on RR.Name before creating new one
* Decrease the notification from default (5 seconds) to 3 seconds
* Use the phrase "zone file" instead of "master file"
* Update the SOA fields information to be less technical.
|
|
Previously, the fields to create new record is name, type, and value.
This commit move the type field to the top so when the type changes,
the fields below it also changes according to its type.
This is to simplify the field format for PTR record.
|