Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
dfc02843
Commit
dfc02843
authored
Feb 21, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
src: Rename and rewrite numeric_hostport as to_numeric_addr and support AF_UNIX path
parent
11c8803b
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
91 additions
and
41 deletions
+91
-41
src/Makefile.am
src/Makefile.am
+1
-1
src/network.h
src/network.h
+61
-0
src/shrpx.cc
src/shrpx.cc
+4
-6
src/shrpx_config.h
src/shrpx_config.h
+1
-13
src/shrpx_memcached_connection.h
src/shrpx_memcached_connection.h
+2
-1
src/shrpx_memcached_dispatcher.h
src/shrpx_memcached_dispatcher.h
+1
-1
src/shrpx_ssl.h
src/shrpx_ssl.h
+2
-1
src/shrpx_worker.cc
src/shrpx_worker.cc
+5
-8
src/util.cc
src/util.cc
+8
-6
src/util.h
src/util.h
+6
-4
No files found.
src/Makefile.am
View file @
dfc02843
...
...
@@ -62,7 +62,7 @@ HELPER_OBJECTS = util.cc \
http2.cc timegm.c app_helper.cc nghttp2_gzip.c
HELPER_HFILES
=
util.h
\
http2.h timegm.h app_helper.h nghttp2_config.h
\
nghttp2_gzip.h
nghttp2_gzip.h
network.h
HTML_PARSER_OBJECTS
=
HTML_PARSER_HFILES
=
HtmlParser.h
...
...
src/network.h
0 → 100644
View file @
dfc02843
/*
* nghttp2 - HTTP/2 C Library
*
* Copyright (c) 2016 Tatsuhiro Tsujikawa
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef NETWORK_H
#define NETWORK_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif // HAVE_CONFIG_H
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif // HAVE_SYS_SOCKET_H
#include <sys/un.h>
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif // HAVE_NETINET_IN_H
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif // HAVE_ARPA_INET_H
namespace
nghttp2
{
union
sockaddr_union
{
sockaddr_storage
storage
;
sockaddr
sa
;
sockaddr_in6
in6
;
sockaddr_in
in
;
sockaddr_un
un
;
};
struct
Address
{
size_t
len
;
union
sockaddr_union
su
;
};
}
// namespace nghttp2
#endif // NETWORK_H
src/shrpx.cc
View file @
dfc02843
...
...
@@ -2201,7 +2201,7 @@ void process_options(
exit
(
EXIT_FAILURE
);
}
LOG
(
NOTICE
)
<<
"Resolved backend address: "
<<
hostport
<<
" -> "
<<
util
::
numeric_hostport
(
&
addr
.
addr
.
su
.
sa
,
addr
.
addr
.
len
);
<<
util
::
to_numeric_addr
(
&
addr
.
addr
);
}
}
...
...
@@ -2214,7 +2214,7 @@ void process_options(
exit
(
EXIT_FAILURE
);
}
LOG
(
NOTICE
)
<<
"Backend HTTP proxy address: "
<<
hostport
<<
" -> "
<<
util
::
numeric_hostport
(
&
proxy
.
addr
.
su
.
sa
,
proxy
.
addr
.
len
);
<<
util
::
to_numeric_addr
(
&
proxy
.
addr
);
}
{
...
...
@@ -2230,8 +2230,7 @@ void process_options(
exit
(
EXIT_FAILURE
);
}
LOG
(
NOTICE
)
<<
"Memcached address for TLS session cache: "
<<
hostport
<<
" -> "
<<
util
::
numeric_hostport
(
&
memcachedconf
.
addr
.
su
.
sa
,
memcachedconf
.
addr
.
len
);
<<
" -> "
<<
util
::
to_numeric_addr
(
&
memcachedconf
.
addr
);
}
}
...
...
@@ -2247,8 +2246,7 @@ void process_options(
exit
(
EXIT_FAILURE
);
}
LOG
(
NOTICE
)
<<
"Memcached address for TLS ticket key: "
<<
hostport
<<
" -> "
<<
util
::
numeric_hostport
(
&
memcachedconf
.
addr
.
su
.
sa
,
memcachedconf
.
addr
.
len
);
<<
" -> "
<<
util
::
to_numeric_addr
(
&
memcachedconf
.
addr
);
}
}
...
...
src/shrpx_config.h
View file @
dfc02843
...
...
@@ -53,6 +53,7 @@
#include "shrpx_router.h"
#include "template.h"
#include "http2.h"
#include "network.h"
using
namespace
nghttp2
;
...
...
@@ -231,19 +232,6 @@ constexpr char SHRPX_OPT_BACKEND_ADDRESS_FAMILY[] = "backend-address-family";
constexpr
size_t
SHRPX_OBFUSCATED_NODE_LENGTH
=
8
;
union
sockaddr_union
{
sockaddr_storage
storage
;
sockaddr
sa
;
sockaddr_in6
in6
;
sockaddr_in
in
;
sockaddr_un
un
;
};
struct
Address
{
size_t
len
;
union
sockaddr_union
su
;
};
enum
shrpx_proto
{
PROTO_HTTP2
,
PROTO_HTTP
};
enum
shrpx_forwarded_param
{
...
...
src/shrpx_memcached_connection.h
View file @
dfc02843
...
...
@@ -35,12 +35,13 @@
#include "shrpx_connection.h"
#include "buffer.h"
#include "network.h"
using
namespace
nghttp2
;
namespace
shrpx
{
struct
MemcachedRequest
;
struct
Address
;
enum
{
MEMCACHED_PARSE_HEADER24
,
...
...
src/shrpx_memcached_dispatcher.h
View file @
dfc02843
...
...
@@ -34,12 +34,12 @@
#include <openssl/ssl.h>
#include "memchunk.h"
#include "network.h"
namespace
shrpx
{
struct
MemcachedRequest
;
class
MemcachedConnection
;
struct
Address
;
class
MemcachedDispatcher
{
public:
...
...
src/shrpx_ssl.h
View file @
dfc02843
...
...
@@ -39,6 +39,8 @@
#include <neverbleed.h>
#endif // HAVE_NEVERBLEED
#include "network.h"
namespace
shrpx
{
class
ClientHandler
;
...
...
@@ -46,7 +48,6 @@ class Worker;
class
DownstreamConnectionPool
;
struct
DownstreamAddr
;
struct
UpstreamAddr
;
struct
Address
;
namespace
ssl
{
...
...
src/shrpx_worker.cc
View file @
dfc02843
...
...
@@ -329,9 +329,8 @@ void Worker::cache_client_tls_session(const Address *addr, SSL_SESSION *session,
if
(
it
==
std
::
end
(
client_tls_session_cache_
))
{
if
(
LOG_ENABLED
(
INFO
))
{
LOG
(
INFO
)
<<
"Create cache entry for SSL_SESSION="
<<
session
<<
", addr="
<<
util
::
numeric_hostport
(
&
addr
->
su
.
sa
,
addr
->
len
)
<<
"("
<<
addr
<<
"), timestamp="
<<
std
::
fixed
<<
std
::
setprecision
(
6
)
<<
t
;
<<
", addr="
<<
util
::
to_numeric_addr
(
addr
)
<<
"("
<<
addr
<<
"), timestamp="
<<
std
::
fixed
<<
std
::
setprecision
(
6
)
<<
t
;
}
client_tls_session_cache_
.
emplace
(
addr
,
SessionCacheEntry
{
serialize_ssl_session
(
session
),
t
});
...
...
@@ -341,8 +340,7 @@ void Worker::cache_client_tls_session(const Address *addr, SSL_SESSION *session,
auto
&
ent
=
(
*
it
).
second
;
if
(
ent
.
last_updated
+
1
_min
>
t
)
{
if
(
LOG_ENABLED
(
INFO
))
{
LOG
(
INFO
)
<<
"Cache for addr="
<<
util
::
numeric_hostport
(
&
addr
->
su
.
sa
,
addr
->
len
)
<<
"("
LOG
(
INFO
)
<<
"Cache for addr="
<<
util
::
to_numeric_addr
(
addr
)
<<
"("
<<
addr
<<
") is still host. Not updating."
;
}
return
;
...
...
@@ -350,9 +348,8 @@ void Worker::cache_client_tls_session(const Address *addr, SSL_SESSION *session,
if
(
LOG_ENABLED
(
INFO
))
{
LOG
(
INFO
)
<<
"Update cache entry for SSL_SESSION="
<<
session
<<
", addr="
<<
util
::
numeric_hostport
(
&
addr
->
su
.
sa
,
addr
->
len
)
<<
"("
<<
addr
<<
"), timestamp="
<<
std
::
fixed
<<
std
::
setprecision
(
6
)
<<
t
;
<<
", addr="
<<
util
::
to_numeric_addr
(
addr
)
<<
"("
<<
addr
<<
"), timestamp="
<<
std
::
fixed
<<
std
::
setprecision
(
6
)
<<
t
;
}
ent
.
session_data
=
serialize_ssl_session
(
session
);
...
...
src/util.cc
View file @
dfc02843
...
...
@@ -650,15 +650,17 @@ std::string numeric_name(const struct sockaddr *sa, socklen_t salen) {
return
host
.
data
();
}
std
::
string
numeric_hostport
(
const
struct
sockaddr
*
sa
,
socklen_t
salen
)
{
if
(
sa
->
sa_family
==
AF_UNIX
)
{
return
"localhost"
;
std
::
string
to_numeric_addr
(
const
Address
*
addr
)
{
auto
family
=
addr
->
su
.
storage
.
ss_family
;
if
(
family
==
AF_UNIX
)
{
return
addr
->
su
.
un
.
sun_path
;
}
std
::
array
<
char
,
NI_MAXHOST
>
host
;
std
::
array
<
char
,
NI_MAXSERV
>
serv
;
auto
rv
=
getnameinfo
(
sa
,
salen
,
host
.
data
(),
host
.
size
(),
serv
.
data
(),
serv
.
size
(),
NI_NUMERICHOST
|
NI_NUMERICSERV
);
auto
rv
=
getnameinfo
(
&
addr
->
su
.
sa
,
addr
->
len
,
host
.
data
(),
host
.
size
(),
serv
.
data
(),
serv
.
size
(),
NI_NUMERICHOST
|
NI_NUMERICSERV
);
if
(
rv
!=
0
)
{
return
"unknown"
;
}
...
...
@@ -668,7 +670,7 @@ std::string numeric_hostport(const struct sockaddr *sa, socklen_t salen) {
std
::
string
s
;
char
*
p
;
if
(
sa
->
sa_
family
==
AF_INET6
)
{
if
(
family
==
AF_INET6
)
{
s
.
resize
(
hostlen
+
servlen
+
2
+
1
);
p
=
&
s
[
0
];
*
p
++
=
'['
;
...
...
src/util.h
View file @
dfc02843
...
...
@@ -50,6 +50,7 @@
#include "http-parser/http_parser.h"
#include "template.h"
#include "network.h"
namespace
nghttp2
{
...
...
@@ -461,10 +462,11 @@ bool numeric_host(const char *hostname, int family);
// failed, "unknown" is returned.
std
::
string
numeric_name
(
const
struct
sockaddr
*
sa
,
socklen_t
salen
);
// Returns string representation of numeric address and port of |addr|
// of length |salen|. The format is like <HOST>:<PORT>. For IPv6
// address, address is enclosed by square brackets ([]).
std
::
string
numeric_hostport
(
const
struct
sockaddr
*
sa
,
socklen_t
salen
);
// Returns string representation of numeric address and port of
// |addr|. If address family is AF_UNIX, this return path to UNIX
// domain socket. Otherwise, the format is like <HOST>:<PORT>. For
// IPv6 address, address is enclosed by square brackets ([]).
std
::
string
to_numeric_addr
(
const
Address
*
addr
);
// Makes internal copy of stderr (and possibly stdout in the future),
// which is then used as pointer to /dev/stderr or /proc/self/fd/2
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment