You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.5 KiB
38 lines
1.5 KiB
/* Подбор кандидатов для прямого транспорта. PUBLIC в конфиге — политика, |
|
* OPEN/CONTACT — измеренные свойства endpoint. Совместимость разрешает пробу; |
|
* только аутентифицированный handshake подтверждает связь с нужным узлом. */ |
|
#ifndef SOCK_MATCH_H |
|
#define SOCK_MATCH_H |
|
|
|
#include <stdint.h> |
|
#include "address_profile.h" |
|
|
|
struct UTUN_INSTANCE; |
|
struct ETCP_SOCKET; |
|
|
|
#define SOCK_ROLE_DIRECT 0 |
|
#define SOCK_ROLE_OUTGOING 1 |
|
#define SOCK_ROLE_LOCAL 2 |
|
|
|
#define SOCK_TC_PUB 0 |
|
#define SOCK_TC_PRIV 1 |
|
#define SOCK_TC_UNREACH 2 |
|
#define SOCK_TC_CONTACT 3 |
|
#define SOCK_TC_PROBE 4 |
|
|
|
struct sock_view { |
|
struct ETCP_SOCKET *sock; |
|
uint8_t role, has_inet, has_priv, family, is_tcp; |
|
uint32_t local_ip4, public_ip4; |
|
uint64_t now_us; |
|
struct address_profile address_profile; |
|
}; |
|
|
|
/* public_address — классификация IP в соответствующем семействе, не доказательство входа. */ |
|
uint8_t sock_target_class(uint8_t address_type, uint8_t config_type, const struct address_profile *profile, |
|
int public_address, uint64_t now_us); |
|
int sock_match(const struct sock_view *view, uint8_t address_type, uint8_t config_type, |
|
const struct address_profile *profile, uint32_t target_ip4); |
|
int sock_collect_views(struct UTUN_INSTANCE *instance, struct sock_view *out, int max); |
|
|
|
#endif
|
|
|