Sunshine latest
Self-hosted game stream host for Moonlight.
network.h
Go to the documentation of this file.
1
5#pragma once
6
7// standard includes
8#include <tuple>
9#include <utility>
10
11// lib includes
12#include <boost/asio.hpp>
13#include <enet/enet.h>
14
15// local includes
16#include "utility.h"
17
18namespace net {
19 void free_host(ENetHost *host);
20
30 std::uint16_t map_port(int port);
31
33 using peer_t = ENetPeer *;
35
36 enum net_e : int {
39 WAN
40 };
41
42 enum af_e : int {
44 BOTH
45 };
46
47 net_e from_enum_string(const std::string_view &view);
48 std::string_view to_enum_string(net_e net);
49
50 net_e from_address(const std::string_view &view);
51
52 host_t host_create(af_e af, ENetAddress &addr, std::uint16_t port);
53
59 af_e af_from_enum_string(const std::string_view &view);
60
66 std::string_view af_to_any_address_string(af_e af);
67
74 boost::asio::ip::address normalize_address(boost::asio::ip::address address);
75
82 std::string addr_to_normalized_string(boost::asio::ip::address address);
83
90 std::string addr_to_url_escaped_string(boost::asio::ip::address address);
91
97 int encryption_mode_for_address(boost::asio::ip::address address);
98
104 std::string mdns_instance_name(const std::string_view &hostname);
105} // namespace net
Definition utility.h:530
std::uint16_t map_port(int port)
Map a specified port based on the base port.
Definition network.cpp:187
af_e
Definition network.h:42
@ IPV4
IPv4 only.
Definition network.h:43
@ BOTH
IPv4 and IPv6.
Definition network.h:44
net_e
Definition network.h:36
@ PC
PC.
Definition network.h:37
@ WAN
WAN.
Definition network.h:39
@ LAN
LAN.
Definition network.h:38
Declarations for utility functions.