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
99f7e7e2
Commit
99f7e7e2
authored
Apr 29, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Add mruby env.server_addr and env.tls_used attributes
parent
6c999e6f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
doc/nghttpx.h2r
doc/nghttpx.h2r
+13
-1
src/shrpx_mruby_module_env.cc
src/shrpx_mruby_module_env.cc
+27
-0
No files found.
doc/nghttpx.h2r
View file @
99f7e7e2
...
...
@@ -265,13 +265,25 @@ respectively.
.. rb:attr_reader:: remote_addr
Return IP address of a remote client.
Return IP address of a remote client. If connection is made
via UNIX domain socket, this returns the string "localhost".
.. rb:attr_reader:: server_addr
Return address of server that accepted the connection. This
is a string which specified in :option:`--frontend` option,
excluding port number, and not a resolved IP address. For
UNIX domain socket, this is a path to UNIX domain socket.
.. rb:attr_reader:: server_port
Return port number of the server frontend which accepted the
connection from client.
.. rb:attr_reader:: tls_used
Return true if TLS is used on the connection.
.. rb:class:: Request
Object to represent request from client. The modification to
...
...
src/shrpx_mruby_module_env.cc
View file @
99f7e7e2
...
...
@@ -104,6 +104,29 @@ mrb_value env_get_server_port(mrb_state *mrb, mrb_value self) {
}
}
// namespace
namespace
{
mrb_value
env_get_server_addr
(
mrb_state
*
mrb
,
mrb_value
self
)
{
auto
data
=
static_cast
<
MRubyAssocData
*>
(
mrb
->
ud
);
auto
downstream
=
data
->
downstream
;
auto
upstream
=
downstream
->
get_upstream
();
auto
handler
=
upstream
->
get_client_handler
();
auto
faddr
=
handler
->
get_upstream_addr
();
return
mrb_str_new
(
mrb
,
faddr
->
host
.
c_str
(),
faddr
->
host
.
size
());
}
}
// namespace
namespace
{
mrb_value
env_get_tls_used
(
mrb_state
*
mrb
,
mrb_value
self
)
{
auto
data
=
static_cast
<
MRubyAssocData
*>
(
mrb
->
ud
);
auto
downstream
=
data
->
downstream
;
auto
upstream
=
downstream
->
get_upstream
();
auto
handler
=
upstream
->
get_client_handler
();
return
handler
->
get_ssl
()
?
mrb_true_value
()
:
mrb_false_value
();
}
}
// namespace
void
init_env_class
(
mrb_state
*
mrb
,
RClass
*
module
)
{
auto
env_class
=
mrb_define_class_under
(
mrb
,
module
,
"Env"
,
mrb
->
object_class
);
...
...
@@ -115,8 +138,12 @@ void init_env_class(mrb_state *mrb, RClass *module) {
mrb_define_method
(
mrb
,
env_class
,
"phase"
,
env_get_phase
,
MRB_ARGS_NONE
());
mrb_define_method
(
mrb
,
env_class
,
"remote_addr"
,
env_get_remote_addr
,
MRB_ARGS_NONE
());
mrb_define_method
(
mrb
,
env_class
,
"server_addr"
,
env_get_server_addr
,
MRB_ARGS_NONE
());
mrb_define_method
(
mrb
,
env_class
,
"server_port"
,
env_get_server_port
,
MRB_ARGS_NONE
());
mrb_define_method
(
mrb
,
env_class
,
"tls_used"
,
env_get_tls_used
,
MRB_ARGS_NONE
());
}
}
// namespace mruby
...
...
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