ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
tailscale.h 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.h.

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 66 of file tailscale.c.

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

References is_valid_ipv4(), and is_valid_ipv6().