2020-11-09 05:23:58 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2015-05-18 17:10:07 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
2018-01-11 00:39:12 +01:00
|
|
|
#include <stdio.h>
|
2015-05-18 17:10:07 +02:00
|
|
|
|
|
|
|
#include "macro.h"
|
2020-12-10 11:10:54 +01:00
|
|
|
#include "strv.h"
|
2015-05-18 17:10:07 +02:00
|
|
|
|
|
|
|
char* gethostname_malloc(void);
|
2020-05-07 16:16:19 +02:00
|
|
|
char* gethostname_short_malloc(void);
|
2016-02-21 14:14:08 +01:00
|
|
|
int gethostname_strict(char **ret);
|
2015-05-18 17:10:07 +02:00
|
|
|
|
2018-12-05 12:26:29 +01:00
|
|
|
bool valid_ldh_char(char c) _const_;
|
2015-05-18 17:10:07 +02:00
|
|
|
|
2020-12-11 16:40:45 +01:00
|
|
|
typedef enum ValidHostnameFlags {
|
|
|
|
VALID_HOSTNAME_TRAILING_DOT = 1 << 0, /* Accept trailing dot on multi-label names */
|
|
|
|
VALID_HOSTNAME_DOT_HOST = 1 << 1, /* Accept ".host" as valid hostname */
|
|
|
|
} ValidHostnameFlags;
|
|
|
|
|
|
|
|
bool hostname_is_valid(const char *s, ValidHostnameFlags flags) _pure_;
|
|
|
|
char* hostname_cleanup(char *s);
|
2015-08-23 14:30:52 +02:00
|
|
|
|
2015-05-18 17:10:07 +02:00
|
|
|
bool is_localhost(const char *hostname);
|
2020-12-10 11:10:54 +01:00
|
|
|
|
|
|
|
static inline bool is_gateway_hostname(const char *hostname) {
|
|
|
|
/* This tries to identify the valid syntaxes for the our synthetic "gateway" host. */
|
|
|
|
return STRCASE_IN_SET(hostname, "_gateway", "_gateway.");
|
|
|
|
}
|