From 20c3f80e7dfd9e453d757199beb2137c09a9f536 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Fri, 13 May 2022 21:14:29 +0700 Subject: cmd/resolver: implement command to delete record on hosts file The command has the following signature, resolver hosts.d rr delete Given the hosts name "hosts" and domain "my.hosts" it will delete all records that have domain name "my.hosts" inside the file. --- cmd/resolver/main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'cmd/resolver/main.go') diff --git a/cmd/resolver/main.go b/cmd/resolver/main.go index 2c40b90..fac894c 100644 --- a/cmd/resolver/main.go +++ b/cmd/resolver/main.go @@ -206,6 +206,10 @@ hosts.d rr add If the domain name already exists, the new record will be appended instead of replaced. +hosts.d rr delete + + Delete record from hosts file "name" by domain name. + == Examples @@ -293,6 +297,17 @@ Get the content of hosts file named "myhosts" inside the hosts.d directory, Add new record "127.0.0.1 my.hosts" to hosts file named "hosts", $ resolver hosts.d rr add hosts my.hosts 127.0.0.1 + { + "Value": "127.0.0.1", + "Name": "my.hosts", + "Type": 1, + "Class": 1, + "TTL": 604800 + } + +Delete record "my.hosts" from hosts file "hosts", + + $ resolver hosts.d rr delete hosts my.hosts { "Value": "127.0.0.1", "Name": "my.hosts", -- cgit v1.3