ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
tailscale.c File Reference

Tailscale host identity helpers. More...

Go to the source code of this file.

Functions

bool is_tailscale_host (const char *address)
 Determine whether an address belongs to the local Tailscale tailnet.
 

Detailed Description

Tailscale host identity helpers.

Definition in file tailscale.c.

Function Documentation

◆ is_tailscale_host()

bool is_tailscale_host ( const char *  address)

Determine whether an address belongs to the local Tailscale tailnet.

A fully-qualified .ts.net name is accepted directly. Literal IP addresses are reverse-resolved, while short hostnames are forward-resolved and then reverse-checked. The resolved name must end in .ts.net.

Definition at line 63 of file tailscale.c.

63 {
64 if (!address || !address[0]) {
65 return false;
66 }
67 if (is_tailscale_hostname(address)) {
68 return true;
69 }
70
71 bool is_numeric = is_valid_ipv4(address) || is_valid_ipv6(address);
72 bool is_short_hostname = !is_numeric && strchr(address, '.') == NULL;
73 return (is_numeric || is_short_hostname) && address_resolves_to_tailscale(address, is_numeric);
74}
int is_valid_ipv4(const char *ip)
Check if a string is a valid IPv4 address.
Definition ip.c:58
int is_valid_ipv6(const char *ip)
Check if a string is a valid IPv6 address.
Definition ip.c:105

References is_valid_ipv4(), and is_valid_ipv6().