Commit Graph

18 Commits

Author SHA1 Message Date
Cuong Manh Le
6edd42629e cmd/ctrld: correct write default config condition when start
!76 was merged without rebasing on latest master, so it missed the
condition of "--cd" when checking for writing default config.
2023-01-20 21:37:10 +07:00
Cuong Manh Le
8e91123dbf cmd/ctrld: write default config to home dir when start
This piece was missing in last resolving conflicts.
2023-01-20 21:37:04 +07:00
Cuong Manh Le
3014556f2d cmd/ctrld,internal/controld: do not set bootstrap IP 2023-01-20 21:36:56 +07:00
Cuong Manh Le
b021833ed6 cmd/ctrld: correct the write default config condition
When "--cd" is supplied, we don't want to write default config. This
happens due to faulty in resolving conflicts in !70.
2023-01-20 21:36:52 +07:00
Cuong Manh Le
7b13fd862d cmd/ctrld: fix mis-handling of start alias
For "ctrld start", os.Args length is just 2, so we we could not shorten
it from 3.
2023-01-20 21:36:45 +07:00
Cuong Manh Le
114ef9aad6 all: add starting service with Control D config 2023-01-20 21:33:38 +07:00
Cuong Manh Le
ec72af1916 cmd/ctrld: add commands to control ctrld as a system service
Supported actions:

 - start: install and start ctrld as a system service
 - stop: stop the ctrld service
 - restart: restart ctrld service
 - status: show status of ctrld service
 - uninstall: remove ctrld from system service
2023-01-20 21:33:31 +07:00
Cuong Manh Le
9e7578fb29 cmd/ctrld: use better approach for checking IPv6 available
Some operating systems may throw a confirmation dialog when attempting
to listen on any interface other than loopback. A better approach is
checking for any interface which is up and can be routed IP traffic.
2023-01-20 21:33:25 +07:00
Cuong Manh Le
e331a4113a Rework os resolver
Currently, os resolver not only handle A and AAAA records, but also does
it wrongly, since when it packs AAAA record to a dns.A record.

This commit reworks os resolver to make it works with all supported
record types.
2023-01-20 21:33:17 +07:00
Cuong Manh Le
e6d77e2586 cmd/ctrld: add default value and CLI flag for cache size 2023-01-20 21:33:11 +07:00
Cuong Manh Le
b93970ccfd all: add CLI flags for no config start
This commit adds the ability to start `ctrld` without config file. All
necessary information can be provided via command line flags, either in
base64 encoded config or launch arguments.
2023-01-20 21:33:05 +07:00
Cuong Manh Le
30fefe7ab9 all: add local caching
This commit adds config params to enable local DNS response caching and
control its behavior, allow tweaking the cache size, ttl override and
serving stale response.
2023-01-20 21:33:01 +07:00
Cuong Manh Le
837d3195ca cmd/ctrld: rework "verbose" flag
This commit changes "verbose" flag from boolean to count flag, so we can
specify the flag multiple times to indicate different logging output:

 - No "-v": no query logging except startup/listeners
 - "-v"   : query logging enabled
 - "-vv"  : debug level logging enabled
2023-01-20 21:32:33 +07:00
Cuong Manh Le
a7ae6c9853 all: support ipv6 for upstream bootstrap ip 2023-01-20 21:32:26 +07:00
Cuong Manh Le
ebcc545547 all: improving DoH query performance
Previously, for each DoH query, we use the net/http default transport
with DialContext function re-assigned. This has some problems:

 - The first query to server will be slow.
 - Using the default transport for all upstreams can have race condition
   in case of multiple queries to multiple DoH upstreams

This commit fixes those issues, by initializing a separate transport for
each DoH upstream, the warming up the transport by doing a test query.
Later queries can take the advantage and re-use the connection.
2023-01-20 21:32:14 +07:00
Cuong Manh Le
0240f7ab15 cmd/ctrld: bump version to v1.0.1 2022-12-15 00:57:16 +07:00
Cuong Manh Le
ccada70e31 all: implement policy failover rcodes
While at it, ensure that config is validated, and fixing a bug related
to reuse ctx between multiple upstreams resolving.
2022-12-14 23:34:24 +07:00
Cuong Manh Le
91d60d2a64 Import code, preparing for release 2022-12-13 01:27:48 +07:00