Sunshine master
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 {
24 void free_host(ENetHost *host);
25
35 std::uint16_t map_port(int port);
36
44 using peer_t = ENetPeer *;
49
53 enum net_e : int {
56 WAN
57 };
58
62 enum af_e : int {
64 BOTH
65 };
66
73 net_e from_enum_string(const std::string_view &view);
80 std::string_view to_enum_string(net_e net);
81
88 net_e from_address(const std::string_view &view);
89
98 host_t host_create(af_e af, ENetAddress &addr, std::uint16_t port);
99
105 af_e af_from_enum_string(const std::string_view &view);
106
112 std::string_view af_to_any_address_string(af_e af);
113
119 std::string get_bind_address(af_e af);
120
127 boost::asio::ip::address normalize_address(boost::asio::ip::address address);
128
135 std::string addr_to_normalized_string(boost::asio::ip::address address);
136
143 std::string addr_to_url_escaped_string(boost::asio::ip::address address);
144
150 int encryption_mode_for_address(boost::asio::ip::address address);
151
157 std::string mdns_instance_name(const std::string_view &hostname);
158} // namespace net
Unique pointer wrapper with customizable pointer and deleter types.
Definition utility.h:820
std::uint16_t map_port(int port)
Map a specified port based on the base port.
Definition network.cpp:224
void free_host(ENetHost *host)
Destroy an ENet host allocated by host_create().
Definition network.cpp:212
af_e
Enumerates supported af options.
Definition network.h:62
@ IPV4
IPv4 only.
Definition network.h:63
@ BOTH
IPv4 and IPv6.
Definition network.h:64
ENetPeer * peer_t
Raw ENet peer handle owned by an ENet host.
Definition network.h:44
net_e
Enumerates supported net options.
Definition network.h:53
@ PC
PC.
Definition network.h:54
@ WAN
WAN.
Definition network.h:56
@ LAN
LAN.
Definition network.h:55
Declarations for utility functions.