811 Commits

Author SHA1 Message Date
Yegor Sak
4c8ea45922 Update docs/ephemeral_mode.md, README.md 2023-01-21 13:41:36 +07:00
Yegor Sak
056b76d5a8 Update docs/basic_mode.md 2023-01-21 13:41:36 +07:00
Yegor Sak
f9d6223af5 Update README.md
Deleted docs/controld_config.md
2023-01-21 13:41:36 +07:00
Cuong Manh Le
f6371360bc all: satisfy staticcheck 2023-01-21 01:14:03 +07:00
Cuong Manh Le
46965b04b4 internal/resolvconffile: add build tag for test file 2023-01-21 01:14:03 +07:00
Cuong Manh Le
065a391ff4 cmd/ctrld: check elevated privilege for service mode 2023-01-21 01:13:59 +07:00
Cuong Manh Le
d830706692 cmd/ctrld: always process "--cd" in start mode
So if there's any error in fetching configuration, it will be reported
to user and service won't start.
2023-01-21 01:13:54 +07:00
Cuong Manh Le
14ddb1faa0 cmd/ctrld: ensure writing config message is printed on non-Windows 2023-01-21 01:13:49 +07:00
Cuong Manh Le
326d7a43d4 cmd/ctrld: rework reset DNS statically vs DHCP
If the interface was originally configured DNS via DHCP, ctrld should
reset the interface using DHCP, not statically.
2023-01-20 21:43:04 +07:00
Cuong Manh Le
87091f20b0 cmd/ctrld: print writing config file message 2023-01-20 21:43:04 +07:00
Cuong Manh Le
d418e57def cmd/ctrld: workaround ipv6 dns resolver on Windows
On Windows, there's no easy way for disabling/removing IPv6 DNS
resolver, so we check whether we can listen on ::1, then spawn a
listener for receiving DNS requests
2023-01-20 21:43:04 +07:00
Cuong Manh Le
49e9b8b51c cmd/ctrld: do not change DNS for tailscale0
Let user decide which option is prefer.
2023-01-20 21:43:04 +07:00
Cuong Manh Le
dc7d77b22e cmd/ctrld: only add "--iface" if not changed for start/stop aliases 2023-01-20 21:43:04 +07:00
Cuong Manh Le
a9fabd1b79 cmd/ctrld: separate iface variable for start/stop aliases
While at it, also fix a bug in getDNSByResolvectl, which won't return
correct DNS values if there's no "%" symbol in output.
2023-01-20 21:43:04 +07:00
Cuong Manh Le
47c280cf1d cmd/ctrld: use network service on darwin 2023-01-20 21:43:04 +07:00
Cuong Manh Le
05cfb9b661 cmd/ctrld: fix typo in Network name 2023-01-20 21:43:04 +07:00
Cuong Manh Le
99b0cbedc3 cmd/ctrld: include DNS in interface list 2023-01-20 21:43:04 +07:00
Cuong Manh Le
1f2bd90308 cmd/ctrld: fix wrong stop command alias
It's "stopCmd", not "startCmd"
2023-01-20 21:43:04 +07:00
Cuong Manh Le
a318e19e33 Workaround quic-go DoQ server issue
Reported in https://feedback.controld.com/posts/1739
2023-01-20 21:43:04 +07:00
Cuong Manh Le
b00a7c34ee cmd/ctrld: add --iface for setting DNS on specific interface 2023-01-20 21:43:03 +07:00
Cuong Manh Le
d5344aea52 cmd/ctrld: add list interfaces command 2023-01-20 21:37:55 +07:00
Cuong Manh Le
8e164185b9 cmd/ctrld: always pass config file on windows start mode
On windows, the SYSTEM user is used to run ctrld service. This user has
different environment with the user that run the `ctrld` binary via CLI.
That causes the mismatch issue in config file path, log path, or more
generally, everything that involve with home directory.

To circumvent this pain, just always passing the config path and the
original home dir in start mode. So `ctrld run` command can setup things
correctly.
2023-01-20 21:37:50 +07:00
Cuong Manh Le
53306235dc all: uninstall service if got invalid config from API 2023-01-20 21:37:44 +07:00
Cuong Manh Le
3a5c71514c cmd/ctrld: ensure viper is re-new in --cd mode 2023-01-20 21:37:39 +07:00
Cuong Manh Le
279e938b2a cmd/ctrld: make "--cd" always owerwrites the config
While at it, also make the toml encoded config format nicer.
2023-01-20 21:37:34 +07:00
Cuong Manh Le
9f90811567 cmd/ctrld: update config when "--cd" present 2023-01-20 21:37:24 +07:00
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
fa3c3e8a29 Close http3 roundtripper when error occurred
For http3, if the network were down, the quic transport needs to be
closed, so the transport can create new connection when network up.
2023-01-20 21:32:55 +07:00
Cuong Manh Le
a6b3c4a757 Don't set default log level in config file 2023-01-20 21:32:47 +07:00
Cuong Manh Le
b03aa39b83 all: support ipv6 for doh3 upstream bootstrap ip
We did it for doh, but the doh3 transport also needs to be changed.
2023-01-20 21:32:41 +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
Spencer Comfort
1cdce73070 Update ci.yml 2023-01-16 17:23:59 -05:00
Spencer Comfort
5f9ac5889b ci.yml: bump checkout -> 3.3.0 and setup-go-faster -> 1.8.0 2023-01-15 21:56:56 -05:00
Yegor S
924304a13d Merge pull request #6 from Control-D-Inc/bump-version
cmd/ctrld: bump version to v1.0.1
v1.0.1
2022-12-14 13:05:05 -05:00
Cuong Manh Le
0240f7ab15 cmd/ctrld: bump version to v1.0.1 2022-12-15 00:57:16 +07:00
Yegor S
64dff35143 Merge pull request #5 from Control-D-Inc/cuonglm/upstream-failover-rcode
all: implement policy failover rcodes
2022-12-14 12:53:26 -05:00
Cuong Manh Le
d2c47ba523 docs: add documentation for failover rcode 2022-12-15 00:00:05 +07:00