GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — libhttpserver/src/create_webserver.cpp at master · etr/libhttpserver

Expand file tree

/

create_webserver.cpp

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
92 lines (78 loc) · 3.08 KB
/

create_webserver.cpp

Copy path

File metadata and controls

92 lines (78 loc) · 3.08 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
This file is part of libhttpserver
Copyright (C) 2011-2019 Sebastiano Merlino
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
*/
#if defined(_WIN32) && !defined(__CYGWIN__)
#define _WINDOWS
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x600
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#endif
#include <cstring>
#include <memory>
#include <stdexcept>
#include <string>
#include "httpserver/create_webserver.hpp"
namespace httpserver {
// Defined here (not as a default member
// initializer in the header) so the public header carries no
// #ifdef HAVE_BAUTH. The library was compiled with the right
// HAVE_BAUTH state; the consumer TU's HAVE_BAUTH is irrelevant.
bool detail::default_basic_auth_enabled() noexcept {
#ifdef HAVE_BAUTH
return true;
#else
return false;
#endif
}
// Same pattern as default_basic_auth_enabled(). Returns true
// on HAVE_DAUTH-on builds (preserving historical behaviour) and false
// on HAVE_DAUTH-off builds so an unmodified builder doesn't trip the
// feature_unavailable guard in webserver::webserver().
bool detail::default_digest_auth_enabled() noexcept {
#ifdef HAVE_DAUTH
return true;
#else
return false;
#endif
}
create_webserver& create_webserver::bind_address(const std::string& ip) {
_config.bind_address_storage = std::make_shared<struct sockaddr_storage>();
std::memset(_config.bind_address_storage.get(), 0, sizeof(struct sockaddr_storage));
// Try IPv4 first
auto* addr4 = reinterpret_cast<struct sockaddr_in*>(_config.bind_address_storage.get());
if (inet_pton(AF_INET, ip.c_str(), &(addr4->sin_addr)) == 1) {
addr4->sin_family = AF_INET;
addr4->sin_port = htons(_config.port);
_config.bind_address = reinterpret_cast<const struct sockaddr*>(_config.bind_address_storage.get());
return *this;
}
// Try IPv6
auto* addr6 = reinterpret_cast<struct sockaddr_in6*>(_config.bind_address_storage.get());
if (inet_pton(AF_INET6, ip.c_str(), &(addr6->sin6_addr)) == 1) {
addr6->sin6_family = AF_INET6;
addr6->sin6_port = htons(_config.port);
_config.bind_address = reinterpret_cast<const struct sockaddr*>(_config.bind_address_storage.get());
_config.use_ipv6 = true;
return *this;
}
throw std::invalid_argument("bind_address: invalid IP address: " + ip);
}
} // namespace httpserver
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.