Sunshine v2025.118.151840
Self-hosted game stream host for Moonlight.
network.h
Go to the documentation of this file.
1
5#pragma once
6
7#include <tuple>
8#include <utility>
9
10#include <boost/asio.hpp>
11
12#include <enet/enet.h>
13
14#include "utility.h"
15
16namespace net {
17 void
18 free_host(ENetHost *host);
19
29 std::uint16_t
30 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
48 from_enum_string(const std::string_view &view);
49 std::string_view
50 to_enum_string(net_e net);
51
52 net_e
53 from_address(const std::string_view &view);
54
55 host_t
56 host_create(af_e af, ENetAddress &addr, std::uint16_t port);
57
63 af_e
64 af_from_enum_string(const std::string_view &view);
65
71 std::string_view
72 af_to_any_address_string(af_e af);
73
80 boost::asio::ip::address
81 normalize_address(boost::asio::ip::address address);
82
89 std::string
90 addr_to_normalized_string(boost::asio::ip::address address);
91
98 std::string
99 addr_to_url_escaped_string(boost::asio::ip::address address);
100
106 int
107 encryption_mode_for_address(boost::asio::ip::address address);
108
114 std::string
115 mdns_instance_name(const std::string_view &hostname);
116} // namespace net
Definition utility.h:496
std::uint16_t map_port(int port)
Map a specified port based on the base port.
Definition network.cpp:199
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.