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
a053d108
Commit
a053d108
authored
Jan 18, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Move option handling code to separate function
parent
16549bb2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
734 additions
and
726 deletions
+734
-726
src/shrpx.cc
src/shrpx.cc
+734
-726
No files found.
src/shrpx.cc
View file @
a053d108
...
...
@@ -1723,707 +1723,113 @@ Misc:
}
}
// namespace
int
main
(
int
argc
,
char
**
argv
)
{
nghttp2
::
ssl
::
libssl_init
();
namespace
{
void
process_options
(
int
argc
,
char
**
argv
,
std
::
vector
<
std
::
pair
<
const
char
*
,
const
char
*>>
&
cmdcfgs
)
{
if
(
conf_exists
(
get_config
()
->
conf_path
.
get
()))
{
std
::
set
<
std
::
string
>
include_set
;
if
(
load_config
(
get_config
()
->
conf_path
.
get
(),
include_set
)
==
-
1
)
{
LOG
(
FATAL
)
<<
"Failed to load configuration from "
<<
get_config
()
->
conf_path
.
get
();
exit
(
EXIT_FAILURE
);
}
assert
(
include_set
.
empty
());
}
#ifndef NOTHREADS
nghttp2
::
ssl
::
LibsslGlobalLock
lock
;
#endif // NOTHREADS
if
(
argc
-
optind
>=
2
)
{
cmdcfgs
.
emplace_back
(
SHRPX_OPT_PRIVATE_KEY_FILE
,
argv
[
optind
++
]);
cmdcfgs
.
emplace_back
(
SHRPX_OPT_CERTIFICATE_FILE
,
argv
[
optind
++
]);
}
Log
::
set_severity_level
(
NOTICE
);
create_config
();
fill_default_config
();
// Reopen log files using configurations in file
reopen_log_files
();
// make copy of stderr
util
::
store_original_fds
()
;
{
std
::
set
<
std
::
string
>
include_set
;
// First open log files with default configuration, so that we can
// log errors/warnings while reading configuration files.
reopen_log_files
();
for
(
size_t
i
=
0
,
len
=
cmdcfgs
.
size
();
i
<
len
;
++
i
)
{
if
(
parse_config
(
cmdcfgs
[
i
].
first
,
cmdcfgs
[
i
].
second
,
include_set
)
==
-
1
)
{
LOG
(
FATAL
)
<<
"Failed to parse command-line argument."
;
exit
(
EXIT_FAILURE
);
}
}
mod_config
()
->
original_argv
=
argv
;
assert
(
include_set
.
empty
());
}
// We have to copy argv, since getopt_long may change its content.
mod_config
()
->
argc
=
argc
;
mod_config
()
->
argv
=
new
char
*
[
argc
];
if
(
get_config
()
->
accesslog_syslog
||
get_config
()
->
errorlog_syslog
)
{
openlog
(
"nghttpx"
,
LOG_NDELAY
|
LOG_NOWAIT
|
LOG_PID
,
get_config
()
->
syslog_facility
);
}
for
(
int
i
=
0
;
i
<
argc
;
++
i
)
{
mod_config
()
->
argv
[
i
]
=
strdup
(
argv
[
i
]);
if
(
mod_config
()
->
argv
[
i
]
==
nullptr
)
{
auto
error
=
errno
;
LOG
(
FATAL
)
<<
"failed to copy argv: "
<<
strerror
(
error
);
if
(
reopen_log_files
()
!=
0
)
{
LOG
(
FATAL
)
<<
"Failed to open log file"
;
exit
(
EXIT_FAILURE
);
}
redirect_stderr_to_errorlog
();
if
(
get_config
()
->
uid
!=
0
)
{
if
(
log_config
()
->
accesslog_fd
!=
-
1
&&
fchown
(
log_config
()
->
accesslog_fd
,
get_config
()
->
uid
,
get_config
()
->
gid
)
==
-
1
)
{
auto
error
=
errno
;
LOG
(
WARN
)
<<
"Changing owner of access log file failed: "
<<
strerror
(
error
);
}
if
(
log_config
()
->
errorlog_fd
!=
-
1
&&
fchown
(
log_config
()
->
errorlog_fd
,
get_config
()
->
uid
,
get_config
()
->
gid
)
==
-
1
)
{
auto
error
=
errno
;
LOG
(
WARN
)
<<
"Changing owner of error log file failed: "
<<
strerror
(
error
);
}
}
mod_config
()
->
cwd
=
getcwd
(
nullptr
,
0
);
if
(
mod_config
()
->
cwd
==
nullptr
)
{
auto
&
http2conf
=
mod_config
()
->
http2
;
{
auto
&
dumpconf
=
http2conf
.
upstream
.
debug
.
dump
;
if
(
dumpconf
.
request_header_file
)
{
auto
path
=
dumpconf
.
request_header_file
.
get
();
auto
f
=
open_file_for_write
(
path
);
if
(
f
==
nullptr
)
{
LOG
(
FATAL
)
<<
"Failed to open http2 upstream request header file: "
<<
path
;
exit
(
EXIT_FAILURE
);
}
dumpconf
.
request_header
=
f
;
if
(
get_config
()
->
uid
!=
0
)
{
if
(
chown_to_running_user
(
path
)
==
-
1
)
{
auto
error
=
errno
;
LOG
(
FATAL
)
<<
"failed to get current working directory: errno="
<<
error
;
LOG
(
WARN
)
<<
"Changing owner of http2 upstream request header file "
<<
path
<<
" failed: "
<<
strerror
(
error
);
}
}
}
if
(
dumpconf
.
response_header_file
)
{
auto
path
=
dumpconf
.
response_header_file
.
get
();
auto
f
=
open_file_for_write
(
path
);
if
(
f
==
nullptr
)
{
LOG
(
FATAL
)
<<
"Failed to open http2 upstream response header file: "
<<
path
;
exit
(
EXIT_FAILURE
);
}
std
::
vector
<
std
::
pair
<
const
char
*
,
const
char
*>>
cmdcfgs
;
while
(
1
)
{
static
int
flag
=
0
;
static
option
long_options
[]
=
{
{
SHRPX_OPT_DAEMON
,
no_argument
,
nullptr
,
'D'
},
{
SHRPX_OPT_LOG_LEVEL
,
required_argument
,
nullptr
,
'L'
},
{
SHRPX_OPT_BACKEND
,
required_argument
,
nullptr
,
'b'
},
{
SHRPX_OPT_HTTP2_MAX_CONCURRENT_STREAMS
,
required_argument
,
nullptr
,
'c'
},
{
SHRPX_OPT_FRONTEND
,
required_argument
,
nullptr
,
'f'
},
{
"help"
,
no_argument
,
nullptr
,
'h'
},
{
SHRPX_OPT_INSECURE
,
no_argument
,
nullptr
,
'k'
},
{
SHRPX_OPT_WORKERS
,
required_argument
,
nullptr
,
'n'
},
{
SHRPX_OPT_CLIENT_PROXY
,
no_argument
,
nullptr
,
'p'
},
{
SHRPX_OPT_HTTP2_PROXY
,
no_argument
,
nullptr
,
's'
},
{
"version"
,
no_argument
,
nullptr
,
'v'
},
{
SHRPX_OPT_FRONTEND_FRAME_DEBUG
,
no_argument
,
nullptr
,
'o'
},
{
SHRPX_OPT_ADD_X_FORWARDED_FOR
,
no_argument
,
&
flag
,
1
},
{
SHRPX_OPT_FRONTEND_HTTP2_READ_TIMEOUT
,
required_argument
,
&
flag
,
2
},
{
SHRPX_OPT_FRONTEND_READ_TIMEOUT
,
required_argument
,
&
flag
,
3
},
{
SHRPX_OPT_FRONTEND_WRITE_TIMEOUT
,
required_argument
,
&
flag
,
4
},
{
SHRPX_OPT_BACKEND_READ_TIMEOUT
,
required_argument
,
&
flag
,
5
},
{
SHRPX_OPT_BACKEND_WRITE_TIMEOUT
,
required_argument
,
&
flag
,
6
},
{
SHRPX_OPT_ACCESSLOG_FILE
,
required_argument
,
&
flag
,
7
},
{
SHRPX_OPT_BACKEND_KEEP_ALIVE_TIMEOUT
,
required_argument
,
&
flag
,
8
},
{
SHRPX_OPT_FRONTEND_HTTP2_WINDOW_BITS
,
required_argument
,
&
flag
,
9
},
{
SHRPX_OPT_PID_FILE
,
required_argument
,
&
flag
,
10
},
{
SHRPX_OPT_USER
,
required_argument
,
&
flag
,
11
},
{
"conf"
,
required_argument
,
&
flag
,
12
},
{
SHRPX_OPT_SYSLOG_FACILITY
,
required_argument
,
&
flag
,
14
},
{
SHRPX_OPT_BACKLOG
,
required_argument
,
&
flag
,
15
},
{
SHRPX_OPT_CIPHERS
,
required_argument
,
&
flag
,
16
},
{
SHRPX_OPT_CLIENT
,
no_argument
,
&
flag
,
17
},
{
SHRPX_OPT_BACKEND_HTTP2_WINDOW_BITS
,
required_argument
,
&
flag
,
18
},
{
SHRPX_OPT_CACERT
,
required_argument
,
&
flag
,
19
},
{
SHRPX_OPT_BACKEND_IPV4
,
no_argument
,
&
flag
,
20
},
{
SHRPX_OPT_BACKEND_IPV6
,
no_argument
,
&
flag
,
21
},
{
SHRPX_OPT_PRIVATE_KEY_PASSWD_FILE
,
required_argument
,
&
flag
,
22
},
{
SHRPX_OPT_NO_VIA
,
no_argument
,
&
flag
,
23
},
{
SHRPX_OPT_SUBCERT
,
required_argument
,
&
flag
,
24
},
{
SHRPX_OPT_HTTP2_BRIDGE
,
no_argument
,
&
flag
,
25
},
{
SHRPX_OPT_BACKEND_HTTP_PROXY_URI
,
required_argument
,
&
flag
,
26
},
{
SHRPX_OPT_BACKEND_NO_TLS
,
no_argument
,
&
flag
,
27
},
{
SHRPX_OPT_FRONTEND_NO_TLS
,
no_argument
,
&
flag
,
29
},
{
SHRPX_OPT_BACKEND_TLS_SNI_FIELD
,
required_argument
,
&
flag
,
31
},
{
SHRPX_OPT_DH_PARAM_FILE
,
required_argument
,
&
flag
,
33
},
{
SHRPX_OPT_READ_RATE
,
required_argument
,
&
flag
,
34
},
{
SHRPX_OPT_READ_BURST
,
required_argument
,
&
flag
,
35
},
{
SHRPX_OPT_WRITE_RATE
,
required_argument
,
&
flag
,
36
},
{
SHRPX_OPT_WRITE_BURST
,
required_argument
,
&
flag
,
37
},
{
SHRPX_OPT_NPN_LIST
,
required_argument
,
&
flag
,
38
},
{
SHRPX_OPT_VERIFY_CLIENT
,
no_argument
,
&
flag
,
39
},
{
SHRPX_OPT_VERIFY_CLIENT_CACERT
,
required_argument
,
&
flag
,
40
},
{
SHRPX_OPT_CLIENT_PRIVATE_KEY_FILE
,
required_argument
,
&
flag
,
41
},
{
SHRPX_OPT_CLIENT_CERT_FILE
,
required_argument
,
&
flag
,
42
},
{
SHRPX_OPT_FRONTEND_HTTP2_DUMP_REQUEST_HEADER
,
required_argument
,
&
flag
,
43
},
{
SHRPX_OPT_FRONTEND_HTTP2_DUMP_RESPONSE_HEADER
,
required_argument
,
&
flag
,
44
},
{
SHRPX_OPT_HTTP2_NO_COOKIE_CRUMBLING
,
no_argument
,
&
flag
,
45
},
{
SHRPX_OPT_FRONTEND_HTTP2_CONNECTION_WINDOW_BITS
,
required_argument
,
&
flag
,
46
},
{
SHRPX_OPT_BACKEND_HTTP2_CONNECTION_WINDOW_BITS
,
required_argument
,
&
flag
,
47
},
{
SHRPX_OPT_TLS_PROTO_LIST
,
required_argument
,
&
flag
,
48
},
{
SHRPX_OPT_PADDING
,
required_argument
,
&
flag
,
49
},
{
SHRPX_OPT_WORKER_READ_RATE
,
required_argument
,
&
flag
,
50
},
{
SHRPX_OPT_WORKER_READ_BURST
,
required_argument
,
&
flag
,
51
},
{
SHRPX_OPT_WORKER_WRITE_RATE
,
required_argument
,
&
flag
,
52
},
{
SHRPX_OPT_WORKER_WRITE_BURST
,
required_argument
,
&
flag
,
53
},
{
SHRPX_OPT_ALTSVC
,
required_argument
,
&
flag
,
54
},
{
SHRPX_OPT_ADD_RESPONSE_HEADER
,
required_argument
,
&
flag
,
55
},
{
SHRPX_OPT_WORKER_FRONTEND_CONNECTIONS
,
required_argument
,
&
flag
,
56
},
{
SHRPX_OPT_ACCESSLOG_SYSLOG
,
no_argument
,
&
flag
,
57
},
{
SHRPX_OPT_ERRORLOG_FILE
,
required_argument
,
&
flag
,
58
},
{
SHRPX_OPT_ERRORLOG_SYSLOG
,
no_argument
,
&
flag
,
59
},
{
SHRPX_OPT_STREAM_READ_TIMEOUT
,
required_argument
,
&
flag
,
60
},
{
SHRPX_OPT_STREAM_WRITE_TIMEOUT
,
required_argument
,
&
flag
,
61
},
{
SHRPX_OPT_NO_LOCATION_REWRITE
,
no_argument
,
&
flag
,
62
},
{
SHRPX_OPT_BACKEND_HTTP1_CONNECTIONS_PER_HOST
,
required_argument
,
&
flag
,
63
},
{
SHRPX_OPT_LISTENER_DISABLE_TIMEOUT
,
required_argument
,
&
flag
,
64
},
{
SHRPX_OPT_STRIP_INCOMING_X_FORWARDED_FOR
,
no_argument
,
&
flag
,
65
},
{
SHRPX_OPT_ACCESSLOG_FORMAT
,
required_argument
,
&
flag
,
66
},
{
SHRPX_OPT_BACKEND_HTTP1_CONNECTIONS_PER_FRONTEND
,
required_argument
,
&
flag
,
67
},
{
SHRPX_OPT_TLS_TICKET_KEY_FILE
,
required_argument
,
&
flag
,
68
},
{
SHRPX_OPT_RLIMIT_NOFILE
,
required_argument
,
&
flag
,
69
},
{
SHRPX_OPT_BACKEND_RESPONSE_BUFFER
,
required_argument
,
&
flag
,
71
},
{
SHRPX_OPT_BACKEND_REQUEST_BUFFER
,
required_argument
,
&
flag
,
72
},
{
SHRPX_OPT_NO_HOST_REWRITE
,
no_argument
,
&
flag
,
73
},
{
SHRPX_OPT_NO_SERVER_PUSH
,
no_argument
,
&
flag
,
74
},
{
SHRPX_OPT_BACKEND_HTTP2_CONNECTIONS_PER_WORKER
,
required_argument
,
&
flag
,
76
},
{
SHRPX_OPT_FETCH_OCSP_RESPONSE_FILE
,
required_argument
,
&
flag
,
77
},
{
SHRPX_OPT_OCSP_UPDATE_INTERVAL
,
required_argument
,
&
flag
,
78
},
{
SHRPX_OPT_NO_OCSP
,
no_argument
,
&
flag
,
79
},
{
SHRPX_OPT_HEADER_FIELD_BUFFER
,
required_argument
,
&
flag
,
80
},
{
SHRPX_OPT_MAX_HEADER_FIELDS
,
required_argument
,
&
flag
,
81
},
{
SHRPX_OPT_ADD_REQUEST_HEADER
,
required_argument
,
&
flag
,
82
},
{
SHRPX_OPT_INCLUDE
,
required_argument
,
&
flag
,
83
},
{
SHRPX_OPT_TLS_TICKET_KEY_CIPHER
,
required_argument
,
&
flag
,
84
},
{
SHRPX_OPT_HOST_REWRITE
,
no_argument
,
&
flag
,
85
},
{
SHRPX_OPT_TLS_SESSION_CACHE_MEMCACHED
,
required_argument
,
&
flag
,
86
},
{
SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED
,
required_argument
,
&
flag
,
87
},
{
SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED_INTERVAL
,
required_argument
,
&
flag
,
88
},
{
SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED_MAX_RETRY
,
required_argument
,
&
flag
,
89
},
{
SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED_MAX_FAIL
,
required_argument
,
&
flag
,
90
},
{
SHRPX_OPT_MRUBY_FILE
,
required_argument
,
&
flag
,
91
},
{
SHRPX_OPT_ACCEPT_PROXY_PROTOCOL
,
no_argument
,
&
flag
,
93
},
{
SHRPX_OPT_FASTOPEN
,
required_argument
,
&
flag
,
94
},
{
SHRPX_OPT_TLS_DYN_REC_WARMUP_THRESHOLD
,
required_argument
,
&
flag
,
95
},
{
SHRPX_OPT_TLS_DYN_REC_IDLE_TIMEOUT
,
required_argument
,
&
flag
,
96
},
{
SHRPX_OPT_ADD_FORWARDED
,
required_argument
,
&
flag
,
97
},
{
SHRPX_OPT_STRIP_INCOMING_FORWARDED
,
no_argument
,
&
flag
,
98
},
{
SHRPX_OPT_FORWARDED_BY
,
required_argument
,
&
flag
,
99
},
{
SHRPX_OPT_FORWARDED_FOR
,
required_argument
,
&
flag
,
100
},
{
nullptr
,
0
,
nullptr
,
0
}};
dumpconf
.
response_header
=
f
;
int
option_index
=
0
;
int
c
=
getopt_long
(
argc
,
argv
,
"DL:b:c:f:hkn:opsv"
,
long_options
,
&
option_index
);
if
(
c
==
-
1
)
{
break
;
}
switch
(
c
)
{
case
'D'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_DAEMON
,
"yes"
);
break
;
case
'L'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_LOG_LEVEL
,
optarg
);
break
;
case
'b'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND
,
optarg
);
break
;
case
'c'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_HTTP2_MAX_CONCURRENT_STREAMS
,
optarg
);
break
;
case
'f'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND
,
optarg
);
break
;
case
'h'
:
print_help
(
std
::
cout
);
exit
(
EXIT_SUCCESS
);
case
'k'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_INSECURE
,
"yes"
);
break
;
case
'n'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_WORKERS
,
optarg
);
break
;
case
'o'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND_FRAME_DEBUG
,
"yes"
);
break
;
case
'p'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_CLIENT_PROXY
,
"yes"
);
break
;
case
's'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_HTTP2_PROXY
,
"yes"
);
break
;
case
'v'
:
print_version
(
std
::
cout
);
exit
(
EXIT_SUCCESS
);
case
'?'
:
util
::
show_candidates
(
argv
[
optind
-
1
],
long_options
);
exit
(
EXIT_FAILURE
);
case
0
:
switch
(
flag
)
{
case
1
:
// --add-x-forwarded-for
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ADD_X_FORWARDED_FOR
,
"yes"
);
break
;
case
2
:
// --frontend-http2-read-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND_HTTP2_READ_TIMEOUT
,
optarg
);
break
;
case
3
:
// --frontend-read-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND_READ_TIMEOUT
,
optarg
);
break
;
case
4
:
// --frontend-write-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND_WRITE_TIMEOUT
,
optarg
);
break
;
case
5
:
// --backend-read-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_READ_TIMEOUT
,
optarg
);
break
;
case
6
:
// --backend-write-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_WRITE_TIMEOUT
,
optarg
);
break
;
case
7
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ACCESSLOG_FILE
,
optarg
);
break
;
case
8
:
// --backend-keep-alive-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_KEEP_ALIVE_TIMEOUT
,
optarg
);
break
;
case
9
:
// --frontend-http2-window-bits
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND_HTTP2_WINDOW_BITS
,
optarg
);
break
;
case
10
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_PID_FILE
,
optarg
);
break
;
case
11
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_USER
,
optarg
);
break
;
case
12
:
// --conf
mod_config
()
->
conf_path
=
strcopy
(
optarg
);
break
;
case
14
:
// --syslog-facility
cmdcfgs
.
emplace_back
(
SHRPX_OPT_SYSLOG_FACILITY
,
optarg
);
break
;
case
15
:
// --backlog
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKLOG
,
optarg
);
break
;
case
16
:
// --ciphers
cmdcfgs
.
emplace_back
(
SHRPX_OPT_CIPHERS
,
optarg
);
break
;
case
17
:
// --client
cmdcfgs
.
emplace_back
(
SHRPX_OPT_CLIENT
,
"yes"
);
break
;
case
18
:
// --backend-http2-window-bits
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_HTTP2_WINDOW_BITS
,
optarg
);
break
;
case
19
:
// --cacert
cmdcfgs
.
emplace_back
(
SHRPX_OPT_CACERT
,
optarg
);
break
;
case
20
:
// --backend-ipv4
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_IPV4
,
"yes"
);
break
;
case
21
:
// --backend-ipv6
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_IPV6
,
"yes"
);
break
;
case
22
:
// --private-key-passwd-file
cmdcfgs
.
emplace_back
(
SHRPX_OPT_PRIVATE_KEY_PASSWD_FILE
,
optarg
);
break
;
case
23
:
// --no-via
cmdcfgs
.
emplace_back
(
SHRPX_OPT_NO_VIA
,
"yes"
);
break
;
case
24
:
// --subcert
cmdcfgs
.
emplace_back
(
SHRPX_OPT_SUBCERT
,
optarg
);
break
;
case
25
:
// --http2-bridge
cmdcfgs
.
emplace_back
(
SHRPX_OPT_HTTP2_BRIDGE
,
"yes"
);
break
;
case
26
:
// --backend-http-proxy-uri
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_HTTP_PROXY_URI
,
optarg
);
break
;
case
27
:
// --backend-no-tls
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_NO_TLS
,
"yes"
);
break
;
case
29
:
// --frontend-no-tls
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND_NO_TLS
,
"yes"
);
break
;
case
31
:
// --backend-tls-sni-field
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_TLS_SNI_FIELD
,
optarg
);
break
;
case
33
:
// --dh-param-file
cmdcfgs
.
emplace_back
(
SHRPX_OPT_DH_PARAM_FILE
,
optarg
);
break
;
case
34
:
// --read-rate
cmdcfgs
.
emplace_back
(
SHRPX_OPT_READ_RATE
,
optarg
);
break
;
case
35
:
// --read-burst
cmdcfgs
.
emplace_back
(
SHRPX_OPT_READ_BURST
,
optarg
);
break
;
case
36
:
// --write-rate
cmdcfgs
.
emplace_back
(
SHRPX_OPT_WRITE_RATE
,
optarg
);
break
;
case
37
:
// --write-burst
cmdcfgs
.
emplace_back
(
SHRPX_OPT_WRITE_BURST
,
optarg
);
break
;
case
38
:
// --npn-list
cmdcfgs
.
emplace_back
(
SHRPX_OPT_NPN_LIST
,
optarg
);
break
;
case
39
:
// --verify-client
cmdcfgs
.
emplace_back
(
SHRPX_OPT_VERIFY_CLIENT
,
"yes"
);
break
;
case
40
:
// --verify-client-cacert
cmdcfgs
.
emplace_back
(
SHRPX_OPT_VERIFY_CLIENT_CACERT
,
optarg
);
break
;
case
41
:
// --client-private-key-file
cmdcfgs
.
emplace_back
(
SHRPX_OPT_CLIENT_PRIVATE_KEY_FILE
,
optarg
);
break
;
case
42
:
// --client-cert-file
cmdcfgs
.
emplace_back
(
SHRPX_OPT_CLIENT_CERT_FILE
,
optarg
);
break
;
case
43
:
// --frontend-http2-dump-request-header
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND_HTTP2_DUMP_REQUEST_HEADER
,
optarg
);
break
;
case
44
:
// --frontend-http2-dump-response-header
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND_HTTP2_DUMP_RESPONSE_HEADER
,
optarg
);
break
;
case
45
:
// --http2-no-cookie-crumbling
cmdcfgs
.
emplace_back
(
SHRPX_OPT_HTTP2_NO_COOKIE_CRUMBLING
,
"yes"
);
break
;
case
46
:
// --frontend-http2-connection-window-bits
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND_HTTP2_CONNECTION_WINDOW_BITS
,
optarg
);
break
;
case
47
:
// --backend-http2-connection-window-bits
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_HTTP2_CONNECTION_WINDOW_BITS
,
optarg
);
break
;
case
48
:
// --tls-proto-list
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_PROTO_LIST
,
optarg
);
break
;
case
49
:
// --padding
cmdcfgs
.
emplace_back
(
SHRPX_OPT_PADDING
,
optarg
);
break
;
case
50
:
// --worker-read-rate
cmdcfgs
.
emplace_back
(
SHRPX_OPT_WORKER_READ_RATE
,
optarg
);
break
;
case
51
:
// --worker-read-burst
cmdcfgs
.
emplace_back
(
SHRPX_OPT_WORKER_READ_BURST
,
optarg
);
break
;
case
52
:
// --worker-write-rate
cmdcfgs
.
emplace_back
(
SHRPX_OPT_WORKER_WRITE_RATE
,
optarg
);
break
;
case
53
:
// --worker-write-burst
cmdcfgs
.
emplace_back
(
SHRPX_OPT_WORKER_WRITE_BURST
,
optarg
);
break
;
case
54
:
// --altsvc
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ALTSVC
,
optarg
);
break
;
case
55
:
// --add-response-header
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ADD_RESPONSE_HEADER
,
optarg
);
break
;
case
56
:
// --worker-frontend-connections
cmdcfgs
.
emplace_back
(
SHRPX_OPT_WORKER_FRONTEND_CONNECTIONS
,
optarg
);
break
;
case
57
:
// --accesslog-syslog
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ACCESSLOG_SYSLOG
,
"yes"
);
break
;
case
58
:
// --errorlog-file
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ERRORLOG_FILE
,
optarg
);
break
;
case
59
:
// --errorlog-syslog
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ERRORLOG_SYSLOG
,
"yes"
);
break
;
case
60
:
// --stream-read-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_STREAM_READ_TIMEOUT
,
optarg
);
break
;
case
61
:
// --stream-write-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_STREAM_WRITE_TIMEOUT
,
optarg
);
break
;
case
62
:
// --no-location-rewrite
cmdcfgs
.
emplace_back
(
SHRPX_OPT_NO_LOCATION_REWRITE
,
"yes"
);
break
;
case
63
:
// --backend-http1-connections-per-host
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_HTTP1_CONNECTIONS_PER_HOST
,
optarg
);
break
;
case
64
:
// --listener-disable-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_LISTENER_DISABLE_TIMEOUT
,
optarg
);
break
;
case
65
:
// --strip-incoming-x-forwarded-for
cmdcfgs
.
emplace_back
(
SHRPX_OPT_STRIP_INCOMING_X_FORWARDED_FOR
,
"yes"
);
break
;
case
66
:
// --accesslog-format
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ACCESSLOG_FORMAT
,
optarg
);
break
;
case
67
:
// --backend-http1-connections-per-frontend
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_HTTP1_CONNECTIONS_PER_FRONTEND
,
optarg
);
break
;
case
68
:
// --tls-ticket-key-file
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_TICKET_KEY_FILE
,
optarg
);
break
;
case
69
:
// --rlimit-nofile
cmdcfgs
.
emplace_back
(
SHRPX_OPT_RLIMIT_NOFILE
,
optarg
);
break
;
case
71
:
// --backend-response-buffer
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_RESPONSE_BUFFER
,
optarg
);
break
;
case
72
:
// --backend-request-buffer
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_REQUEST_BUFFER
,
optarg
);
break
;
case
73
:
// --no-host-rewrite
cmdcfgs
.
emplace_back
(
SHRPX_OPT_NO_HOST_REWRITE
,
"yes"
);
break
;
case
74
:
// --no-server-push
cmdcfgs
.
emplace_back
(
SHRPX_OPT_NO_SERVER_PUSH
,
"yes"
);
break
;
case
76
:
// --backend-http2-connections-per-worker
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_HTTP2_CONNECTIONS_PER_WORKER
,
optarg
);
break
;
case
77
:
// --fetch-ocsp-response-file
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FETCH_OCSP_RESPONSE_FILE
,
optarg
);
break
;
case
78
:
// --ocsp-update-interval
cmdcfgs
.
emplace_back
(
SHRPX_OPT_OCSP_UPDATE_INTERVAL
,
optarg
);
break
;
case
79
:
// --no-ocsp
cmdcfgs
.
emplace_back
(
SHRPX_OPT_NO_OCSP
,
"yes"
);
break
;
case
80
:
// --header-field-buffer
cmdcfgs
.
emplace_back
(
SHRPX_OPT_HEADER_FIELD_BUFFER
,
optarg
);
break
;
case
81
:
// --max-header-fields
cmdcfgs
.
emplace_back
(
SHRPX_OPT_MAX_HEADER_FIELDS
,
optarg
);
break
;
case
82
:
// --add-request-header
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ADD_REQUEST_HEADER
,
optarg
);
break
;
case
83
:
// --include
cmdcfgs
.
emplace_back
(
SHRPX_OPT_INCLUDE
,
optarg
);
break
;
case
84
:
// --tls-ticket-key-cipher
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_TICKET_KEY_CIPHER
,
optarg
);
break
;
case
85
:
// --host-rewrite
cmdcfgs
.
emplace_back
(
SHRPX_OPT_HOST_REWRITE
,
"yes"
);
break
;
case
86
:
// --tls-session-cache-memcached
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_SESSION_CACHE_MEMCACHED
,
optarg
);
break
;
case
87
:
// --tls-ticket-key-memcached
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED
,
optarg
);
break
;
case
88
:
// --tls-ticket-key-memcached-interval
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED_INTERVAL
,
optarg
);
break
;
case
89
:
// --tls-ticket-key-memcached-max-retry
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED_MAX_RETRY
,
optarg
);
break
;
case
90
:
// --tls-ticket-key-memcached-max-fail
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED_MAX_FAIL
,
optarg
);
break
;
case
91
:
// --mruby-file
cmdcfgs
.
emplace_back
(
SHRPX_OPT_MRUBY_FILE
,
optarg
);
break
;
case
93
:
// --accept-proxy-protocol
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ACCEPT_PROXY_PROTOCOL
,
"yes"
);
break
;
case
94
:
// --fastopen
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FASTOPEN
,
optarg
);
break
;
case
95
:
// --tls-dyn-rec-warmup-threshold
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_DYN_REC_WARMUP_THRESHOLD
,
optarg
);
break
;
case
96
:
// --tls-dyn-rec-idle-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_DYN_REC_IDLE_TIMEOUT
,
optarg
);
break
;
case
97
:
// --add-forwarded
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ADD_FORWARDED
,
optarg
);
break
;
case
98
:
// --strip-incoming-forwarded
cmdcfgs
.
emplace_back
(
SHRPX_OPT_STRIP_INCOMING_FORWARDED
,
"yes"
);
break
;
case
99
:
// --forwarded-by
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FORWARDED_BY
,
optarg
);
break
;
case
100
:
// --forwarded-for
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FORWARDED_FOR
,
optarg
);
break
;
default:
break
;
}
break
;
default:
break
;
}
}
if
(
conf_exists
(
get_config
()
->
conf_path
.
get
()))
{
std
::
set
<
std
::
string
>
include_set
;
if
(
load_config
(
get_config
()
->
conf_path
.
get
(),
include_set
)
==
-
1
)
{
LOG
(
FATAL
)
<<
"Failed to load configuration from "
<<
get_config
()
->
conf_path
.
get
();
exit
(
EXIT_FAILURE
);
}
assert
(
include_set
.
empty
());
}
if
(
argc
-
optind
>=
2
)
{
cmdcfgs
.
emplace_back
(
SHRPX_OPT_PRIVATE_KEY_FILE
,
argv
[
optind
++
]);
cmdcfgs
.
emplace_back
(
SHRPX_OPT_CERTIFICATE_FILE
,
argv
[
optind
++
]);
}
// Reopen log files using configurations in file
reopen_log_files
();
{
std
::
set
<
std
::
string
>
include_set
;
for
(
size_t
i
=
0
,
len
=
cmdcfgs
.
size
();
i
<
len
;
++
i
)
{
if
(
parse_config
(
cmdcfgs
[
i
].
first
,
cmdcfgs
[
i
].
second
,
include_set
)
==
-
1
)
{
LOG
(
FATAL
)
<<
"Failed to parse command-line argument."
;
exit
(
EXIT_FAILURE
);
}
}
assert
(
include_set
.
empty
());
}
if
(
get_config
()
->
accesslog_syslog
||
get_config
()
->
errorlog_syslog
)
{
openlog
(
"nghttpx"
,
LOG_NDELAY
|
LOG_NOWAIT
|
LOG_PID
,
get_config
()
->
syslog_facility
);
}
if
(
reopen_log_files
()
!=
0
)
{
LOG
(
FATAL
)
<<
"Failed to open log file"
;
exit
(
EXIT_FAILURE
);
}
redirect_stderr_to_errorlog
();
if
(
get_config
()
->
uid
!=
0
)
{
if
(
log_config
()
->
accesslog_fd
!=
-
1
&&
fchown
(
log_config
()
->
accesslog_fd
,
get_config
()
->
uid
,
get_config
()
->
gid
)
==
-
1
)
{
auto
error
=
errno
;
LOG
(
WARN
)
<<
"Changing owner of access log file failed: "
<<
strerror
(
error
);
}
if
(
log_config
()
->
errorlog_fd
!=
-
1
&&
fchown
(
log_config
()
->
errorlog_fd
,
get_config
()
->
uid
,
get_config
()
->
gid
)
==
-
1
)
{
auto
error
=
errno
;
LOG
(
WARN
)
<<
"Changing owner of error log file failed: "
<<
strerror
(
error
);
}
}
auto
&
http2conf
=
mod_config
()
->
http2
;
{
auto
&
dumpconf
=
http2conf
.
upstream
.
debug
.
dump
;
if
(
dumpconf
.
request_header_file
)
{
auto
path
=
dumpconf
.
request_header_file
.
get
();
auto
f
=
open_file_for_write
(
path
);
if
(
f
==
nullptr
)
{
LOG
(
FATAL
)
<<
"Failed to open http2 upstream request header file: "
<<
path
;
exit
(
EXIT_FAILURE
);
}
dumpconf
.
request_header
=
f
;
if
(
get_config
()
->
uid
!=
0
)
{
if
(
chown_to_running_user
(
path
)
==
-
1
)
{
auto
error
=
errno
;
LOG
(
WARN
)
<<
"Changing owner of http2 upstream request header file "
<<
path
<<
" failed: "
<<
strerror
(
error
);
}
}
}
if
(
dumpconf
.
response_header_file
)
{
auto
path
=
dumpconf
.
response_header_file
.
get
();
auto
f
=
open_file_for_write
(
path
);
if
(
f
==
nullptr
)
{
LOG
(
FATAL
)
<<
"Failed to open http2 upstream response header file: "
<<
path
;
exit
(
EXIT_FAILURE
);
}
dumpconf
.
response_header
=
f
;
if
(
get_config
()
->
uid
!=
0
)
{
if
(
chown_to_running_user
(
path
)
==
-
1
)
{
auto
error
=
errno
;
LOG
(
WARN
)
<<
"Changing owner of http2 upstream response header file"
<<
" "
<<
path
<<
" failed: "
<<
strerror
(
error
);
if
(
get_config
()
->
uid
!=
0
)
{
if
(
chown_to_running_user
(
path
)
==
-
1
)
{
auto
error
=
errno
;
LOG
(
WARN
)
<<
"Changing owner of http2 upstream response header file"
<<
" "
<<
path
<<
" failed: "
<<
strerror
(
error
);
}
}
}
...
...
@@ -2601,58 +2007,660 @@ int main(int argc, char **argv) {
}
}
{
auto
&
memcachedconf
=
tlsconf
.
session_cache
.
memcached
;
if
(
memcachedconf
.
host
)
{
if
(
resolve_hostname
(
&
memcachedconf
.
addr
,
memcachedconf
.
host
.
get
(),
memcachedconf
.
port
,
AF_UNSPEC
)
==
-
1
)
{
exit
(
EXIT_FAILURE
);
}
}
{
auto
&
memcachedconf
=
tlsconf
.
session_cache
.
memcached
;
if
(
memcachedconf
.
host
)
{
if
(
resolve_hostname
(
&
memcachedconf
.
addr
,
memcachedconf
.
host
.
get
(),
memcachedconf
.
port
,
AF_UNSPEC
)
==
-
1
)
{
exit
(
EXIT_FAILURE
);
}
}
}
{
auto
&
memcachedconf
=
tlsconf
.
ticket
.
memcached
;
if
(
memcachedconf
.
host
)
{
if
(
resolve_hostname
(
&
memcachedconf
.
addr
,
memcachedconf
.
host
.
get
(),
memcachedconf
.
port
,
AF_UNSPEC
)
==
-
1
)
{
exit
(
EXIT_FAILURE
);
}
}
}
if
(
get_config
()
->
rlimit_nofile
)
{
struct
rlimit
lim
=
{
static_cast
<
rlim_t
>
(
get_config
()
->
rlimit_nofile
),
static_cast
<
rlim_t
>
(
get_config
()
->
rlimit_nofile
)};
if
(
setrlimit
(
RLIMIT_NOFILE
,
&
lim
)
!=
0
)
{
auto
error
=
errno
;
LOG
(
WARN
)
<<
"Setting rlimit-nofile failed: "
<<
strerror
(
error
);
}
}
auto
&
fwdconf
=
mod_config
()
->
http
.
forwarded
;
if
(
fwdconf
.
by_node_type
==
FORWARDED_NODE_OBFUSCATED
&&
fwdconf
.
by_obfuscated
.
empty
())
{
std
::
random_device
rd
;
std
::
mt19937
gen
(
rd
());
auto
&
dst
=
fwdconf
.
by_obfuscated
;
dst
=
"_"
;
dst
+=
util
::
random_alpha_digit
(
gen
,
SHRPX_OBFUSCATED_NODE_LENGTH
);
}
if
(
get_config
()
->
http2
.
upstream
.
debug
.
frame_debug
)
{
// To make it sync to logging
set_output
(
stderr
);
if
(
isatty
(
fileno
(
stdout
)))
{
set_color_output
(
true
);
}
reset_timer
();
}
mod_config
()
->
http2
.
upstream
.
callbacks
=
create_http2_upstream_callbacks
();
mod_config
()
->
http2
.
downstream
.
callbacks
=
create_http2_downstream_callbacks
();
}
}
// namespace
int
main
(
int
argc
,
char
**
argv
)
{
nghttp2
::
ssl
::
libssl_init
();
#ifndef NOTHREADS
nghttp2
::
ssl
::
LibsslGlobalLock
lock
;
#endif // NOTHREADS
Log
::
set_severity_level
(
NOTICE
);
create_config
();
fill_default_config
();
// make copy of stderr
util
::
store_original_fds
();
// First open log files with default configuration, so that we can
// log errors/warnings while reading configuration files.
reopen_log_files
();
mod_config
()
->
original_argv
=
argv
;
// We have to copy argv, since getopt_long may change its content.
mod_config
()
->
argc
=
argc
;
mod_config
()
->
argv
=
new
char
*
[
argc
];
for
(
int
i
=
0
;
i
<
argc
;
++
i
)
{
mod_config
()
->
argv
[
i
]
=
strdup
(
argv
[
i
]);
if
(
mod_config
()
->
argv
[
i
]
==
nullptr
)
{
auto
error
=
errno
;
LOG
(
FATAL
)
<<
"failed to copy argv: "
<<
strerror
(
error
);
exit
(
EXIT_FAILURE
);
}
}
mod_config
()
->
cwd
=
getcwd
(
nullptr
,
0
);
if
(
mod_config
()
->
cwd
==
nullptr
)
{
auto
error
=
errno
;
LOG
(
FATAL
)
<<
"failed to get current working directory: errno="
<<
error
;
exit
(
EXIT_FAILURE
);
}
std
::
vector
<
std
::
pair
<
const
char
*
,
const
char
*>>
cmdcfgs
;
while
(
1
)
{
static
int
flag
=
0
;
static
option
long_options
[]
=
{
{
SHRPX_OPT_DAEMON
,
no_argument
,
nullptr
,
'D'
},
{
SHRPX_OPT_LOG_LEVEL
,
required_argument
,
nullptr
,
'L'
},
{
SHRPX_OPT_BACKEND
,
required_argument
,
nullptr
,
'b'
},
{
SHRPX_OPT_HTTP2_MAX_CONCURRENT_STREAMS
,
required_argument
,
nullptr
,
'c'
},
{
SHRPX_OPT_FRONTEND
,
required_argument
,
nullptr
,
'f'
},
{
"help"
,
no_argument
,
nullptr
,
'h'
},
{
SHRPX_OPT_INSECURE
,
no_argument
,
nullptr
,
'k'
},
{
SHRPX_OPT_WORKERS
,
required_argument
,
nullptr
,
'n'
},
{
SHRPX_OPT_CLIENT_PROXY
,
no_argument
,
nullptr
,
'p'
},
{
SHRPX_OPT_HTTP2_PROXY
,
no_argument
,
nullptr
,
's'
},
{
"version"
,
no_argument
,
nullptr
,
'v'
},
{
SHRPX_OPT_FRONTEND_FRAME_DEBUG
,
no_argument
,
nullptr
,
'o'
},
{
SHRPX_OPT_ADD_X_FORWARDED_FOR
,
no_argument
,
&
flag
,
1
},
{
SHRPX_OPT_FRONTEND_HTTP2_READ_TIMEOUT
,
required_argument
,
&
flag
,
2
},
{
SHRPX_OPT_FRONTEND_READ_TIMEOUT
,
required_argument
,
&
flag
,
3
},
{
SHRPX_OPT_FRONTEND_WRITE_TIMEOUT
,
required_argument
,
&
flag
,
4
},
{
SHRPX_OPT_BACKEND_READ_TIMEOUT
,
required_argument
,
&
flag
,
5
},
{
SHRPX_OPT_BACKEND_WRITE_TIMEOUT
,
required_argument
,
&
flag
,
6
},
{
SHRPX_OPT_ACCESSLOG_FILE
,
required_argument
,
&
flag
,
7
},
{
SHRPX_OPT_BACKEND_KEEP_ALIVE_TIMEOUT
,
required_argument
,
&
flag
,
8
},
{
SHRPX_OPT_FRONTEND_HTTP2_WINDOW_BITS
,
required_argument
,
&
flag
,
9
},
{
SHRPX_OPT_PID_FILE
,
required_argument
,
&
flag
,
10
},
{
SHRPX_OPT_USER
,
required_argument
,
&
flag
,
11
},
{
"conf"
,
required_argument
,
&
flag
,
12
},
{
SHRPX_OPT_SYSLOG_FACILITY
,
required_argument
,
&
flag
,
14
},
{
SHRPX_OPT_BACKLOG
,
required_argument
,
&
flag
,
15
},
{
SHRPX_OPT_CIPHERS
,
required_argument
,
&
flag
,
16
},
{
SHRPX_OPT_CLIENT
,
no_argument
,
&
flag
,
17
},
{
SHRPX_OPT_BACKEND_HTTP2_WINDOW_BITS
,
required_argument
,
&
flag
,
18
},
{
SHRPX_OPT_CACERT
,
required_argument
,
&
flag
,
19
},
{
SHRPX_OPT_BACKEND_IPV4
,
no_argument
,
&
flag
,
20
},
{
SHRPX_OPT_BACKEND_IPV6
,
no_argument
,
&
flag
,
21
},
{
SHRPX_OPT_PRIVATE_KEY_PASSWD_FILE
,
required_argument
,
&
flag
,
22
},
{
SHRPX_OPT_NO_VIA
,
no_argument
,
&
flag
,
23
},
{
SHRPX_OPT_SUBCERT
,
required_argument
,
&
flag
,
24
},
{
SHRPX_OPT_HTTP2_BRIDGE
,
no_argument
,
&
flag
,
25
},
{
SHRPX_OPT_BACKEND_HTTP_PROXY_URI
,
required_argument
,
&
flag
,
26
},
{
SHRPX_OPT_BACKEND_NO_TLS
,
no_argument
,
&
flag
,
27
},
{
SHRPX_OPT_FRONTEND_NO_TLS
,
no_argument
,
&
flag
,
29
},
{
SHRPX_OPT_BACKEND_TLS_SNI_FIELD
,
required_argument
,
&
flag
,
31
},
{
SHRPX_OPT_DH_PARAM_FILE
,
required_argument
,
&
flag
,
33
},
{
SHRPX_OPT_READ_RATE
,
required_argument
,
&
flag
,
34
},
{
SHRPX_OPT_READ_BURST
,
required_argument
,
&
flag
,
35
},
{
SHRPX_OPT_WRITE_RATE
,
required_argument
,
&
flag
,
36
},
{
SHRPX_OPT_WRITE_BURST
,
required_argument
,
&
flag
,
37
},
{
SHRPX_OPT_NPN_LIST
,
required_argument
,
&
flag
,
38
},
{
SHRPX_OPT_VERIFY_CLIENT
,
no_argument
,
&
flag
,
39
},
{
SHRPX_OPT_VERIFY_CLIENT_CACERT
,
required_argument
,
&
flag
,
40
},
{
SHRPX_OPT_CLIENT_PRIVATE_KEY_FILE
,
required_argument
,
&
flag
,
41
},
{
SHRPX_OPT_CLIENT_CERT_FILE
,
required_argument
,
&
flag
,
42
},
{
SHRPX_OPT_FRONTEND_HTTP2_DUMP_REQUEST_HEADER
,
required_argument
,
&
flag
,
43
},
{
SHRPX_OPT_FRONTEND_HTTP2_DUMP_RESPONSE_HEADER
,
required_argument
,
&
flag
,
44
},
{
SHRPX_OPT_HTTP2_NO_COOKIE_CRUMBLING
,
no_argument
,
&
flag
,
45
},
{
SHRPX_OPT_FRONTEND_HTTP2_CONNECTION_WINDOW_BITS
,
required_argument
,
&
flag
,
46
},
{
SHRPX_OPT_BACKEND_HTTP2_CONNECTION_WINDOW_BITS
,
required_argument
,
&
flag
,
47
},
{
SHRPX_OPT_TLS_PROTO_LIST
,
required_argument
,
&
flag
,
48
},
{
SHRPX_OPT_PADDING
,
required_argument
,
&
flag
,
49
},
{
SHRPX_OPT_WORKER_READ_RATE
,
required_argument
,
&
flag
,
50
},
{
SHRPX_OPT_WORKER_READ_BURST
,
required_argument
,
&
flag
,
51
},
{
SHRPX_OPT_WORKER_WRITE_RATE
,
required_argument
,
&
flag
,
52
},
{
SHRPX_OPT_WORKER_WRITE_BURST
,
required_argument
,
&
flag
,
53
},
{
SHRPX_OPT_ALTSVC
,
required_argument
,
&
flag
,
54
},
{
SHRPX_OPT_ADD_RESPONSE_HEADER
,
required_argument
,
&
flag
,
55
},
{
SHRPX_OPT_WORKER_FRONTEND_CONNECTIONS
,
required_argument
,
&
flag
,
56
},
{
SHRPX_OPT_ACCESSLOG_SYSLOG
,
no_argument
,
&
flag
,
57
},
{
SHRPX_OPT_ERRORLOG_FILE
,
required_argument
,
&
flag
,
58
},
{
SHRPX_OPT_ERRORLOG_SYSLOG
,
no_argument
,
&
flag
,
59
},
{
SHRPX_OPT_STREAM_READ_TIMEOUT
,
required_argument
,
&
flag
,
60
},
{
SHRPX_OPT_STREAM_WRITE_TIMEOUT
,
required_argument
,
&
flag
,
61
},
{
SHRPX_OPT_NO_LOCATION_REWRITE
,
no_argument
,
&
flag
,
62
},
{
SHRPX_OPT_BACKEND_HTTP1_CONNECTIONS_PER_HOST
,
required_argument
,
&
flag
,
63
},
{
SHRPX_OPT_LISTENER_DISABLE_TIMEOUT
,
required_argument
,
&
flag
,
64
},
{
SHRPX_OPT_STRIP_INCOMING_X_FORWARDED_FOR
,
no_argument
,
&
flag
,
65
},
{
SHRPX_OPT_ACCESSLOG_FORMAT
,
required_argument
,
&
flag
,
66
},
{
SHRPX_OPT_BACKEND_HTTP1_CONNECTIONS_PER_FRONTEND
,
required_argument
,
&
flag
,
67
},
{
SHRPX_OPT_TLS_TICKET_KEY_FILE
,
required_argument
,
&
flag
,
68
},
{
SHRPX_OPT_RLIMIT_NOFILE
,
required_argument
,
&
flag
,
69
},
{
SHRPX_OPT_BACKEND_RESPONSE_BUFFER
,
required_argument
,
&
flag
,
71
},
{
SHRPX_OPT_BACKEND_REQUEST_BUFFER
,
required_argument
,
&
flag
,
72
},
{
SHRPX_OPT_NO_HOST_REWRITE
,
no_argument
,
&
flag
,
73
},
{
SHRPX_OPT_NO_SERVER_PUSH
,
no_argument
,
&
flag
,
74
},
{
SHRPX_OPT_BACKEND_HTTP2_CONNECTIONS_PER_WORKER
,
required_argument
,
&
flag
,
76
},
{
SHRPX_OPT_FETCH_OCSP_RESPONSE_FILE
,
required_argument
,
&
flag
,
77
},
{
SHRPX_OPT_OCSP_UPDATE_INTERVAL
,
required_argument
,
&
flag
,
78
},
{
SHRPX_OPT_NO_OCSP
,
no_argument
,
&
flag
,
79
},
{
SHRPX_OPT_HEADER_FIELD_BUFFER
,
required_argument
,
&
flag
,
80
},
{
SHRPX_OPT_MAX_HEADER_FIELDS
,
required_argument
,
&
flag
,
81
},
{
SHRPX_OPT_ADD_REQUEST_HEADER
,
required_argument
,
&
flag
,
82
},
{
SHRPX_OPT_INCLUDE
,
required_argument
,
&
flag
,
83
},
{
SHRPX_OPT_TLS_TICKET_KEY_CIPHER
,
required_argument
,
&
flag
,
84
},
{
SHRPX_OPT_HOST_REWRITE
,
no_argument
,
&
flag
,
85
},
{
SHRPX_OPT_TLS_SESSION_CACHE_MEMCACHED
,
required_argument
,
&
flag
,
86
},
{
SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED
,
required_argument
,
&
flag
,
87
},
{
SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED_INTERVAL
,
required_argument
,
&
flag
,
88
},
{
SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED_MAX_RETRY
,
required_argument
,
&
flag
,
89
},
{
SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED_MAX_FAIL
,
required_argument
,
&
flag
,
90
},
{
SHRPX_OPT_MRUBY_FILE
,
required_argument
,
&
flag
,
91
},
{
SHRPX_OPT_ACCEPT_PROXY_PROTOCOL
,
no_argument
,
&
flag
,
93
},
{
SHRPX_OPT_FASTOPEN
,
required_argument
,
&
flag
,
94
},
{
SHRPX_OPT_TLS_DYN_REC_WARMUP_THRESHOLD
,
required_argument
,
&
flag
,
95
},
{
SHRPX_OPT_TLS_DYN_REC_IDLE_TIMEOUT
,
required_argument
,
&
flag
,
96
},
{
SHRPX_OPT_ADD_FORWARDED
,
required_argument
,
&
flag
,
97
},
{
SHRPX_OPT_STRIP_INCOMING_FORWARDED
,
no_argument
,
&
flag
,
98
},
{
SHRPX_OPT_FORWARDED_BY
,
required_argument
,
&
flag
,
99
},
{
SHRPX_OPT_FORWARDED_FOR
,
required_argument
,
&
flag
,
100
},
{
nullptr
,
0
,
nullptr
,
0
}};
int
option_index
=
0
;
int
c
=
getopt_long
(
argc
,
argv
,
"DL:b:c:f:hkn:opsv"
,
long_options
,
&
option_index
);
if
(
c
==
-
1
)
{
break
;
}
{
auto
&
memcachedconf
=
tlsconf
.
ticket
.
memcached
;
if
(
memcachedconf
.
host
)
{
if
(
resolve_hostname
(
&
memcachedconf
.
addr
,
memcachedconf
.
host
.
get
(),
memcachedconf
.
port
,
AF_UNSPEC
)
==
-
1
)
{
switch
(
c
)
{
case
'D'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_DAEMON
,
"yes"
);
break
;
case
'L'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_LOG_LEVEL
,
optarg
);
break
;
case
'b'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND
,
optarg
);
break
;
case
'c'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_HTTP2_MAX_CONCURRENT_STREAMS
,
optarg
);
break
;
case
'f'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND
,
optarg
);
break
;
case
'h'
:
print_help
(
std
::
cout
);
exit
(
EXIT_SUCCESS
);
case
'k'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_INSECURE
,
"yes"
);
break
;
case
'n'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_WORKERS
,
optarg
);
break
;
case
'o'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND_FRAME_DEBUG
,
"yes"
);
break
;
case
'p'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_CLIENT_PROXY
,
"yes"
);
break
;
case
's'
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_HTTP2_PROXY
,
"yes"
);
break
;
case
'v'
:
print_version
(
std
::
cout
);
exit
(
EXIT_SUCCESS
);
case
'?'
:
util
::
show_candidates
(
argv
[
optind
-
1
],
long_options
);
exit
(
EXIT_FAILURE
);
case
0
:
switch
(
flag
)
{
case
1
:
// --add-x-forwarded-for
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ADD_X_FORWARDED_FOR
,
"yes"
);
break
;
case
2
:
// --frontend-http2-read-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND_HTTP2_READ_TIMEOUT
,
optarg
);
break
;
case
3
:
// --frontend-read-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND_READ_TIMEOUT
,
optarg
);
break
;
case
4
:
// --frontend-write-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND_WRITE_TIMEOUT
,
optarg
);
break
;
case
5
:
// --backend-read-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_READ_TIMEOUT
,
optarg
);
break
;
case
6
:
// --backend-write-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_WRITE_TIMEOUT
,
optarg
);
break
;
case
7
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ACCESSLOG_FILE
,
optarg
);
break
;
case
8
:
// --backend-keep-alive-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_KEEP_ALIVE_TIMEOUT
,
optarg
);
break
;
case
9
:
// --frontend-http2-window-bits
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND_HTTP2_WINDOW_BITS
,
optarg
);
break
;
case
10
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_PID_FILE
,
optarg
);
break
;
case
11
:
cmdcfgs
.
emplace_back
(
SHRPX_OPT_USER
,
optarg
);
break
;
case
12
:
// --conf
mod_config
()
->
conf_path
=
strcopy
(
optarg
);
break
;
case
14
:
// --syslog-facility
cmdcfgs
.
emplace_back
(
SHRPX_OPT_SYSLOG_FACILITY
,
optarg
);
break
;
case
15
:
// --backlog
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKLOG
,
optarg
);
break
;
case
16
:
// --ciphers
cmdcfgs
.
emplace_back
(
SHRPX_OPT_CIPHERS
,
optarg
);
break
;
case
17
:
// --client
cmdcfgs
.
emplace_back
(
SHRPX_OPT_CLIENT
,
"yes"
);
break
;
case
18
:
// --backend-http2-window-bits
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_HTTP2_WINDOW_BITS
,
optarg
);
break
;
case
19
:
// --cacert
cmdcfgs
.
emplace_back
(
SHRPX_OPT_CACERT
,
optarg
);
break
;
case
20
:
// --backend-ipv4
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_IPV4
,
"yes"
);
break
;
case
21
:
// --backend-ipv6
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_IPV6
,
"yes"
);
break
;
case
22
:
// --private-key-passwd-file
cmdcfgs
.
emplace_back
(
SHRPX_OPT_PRIVATE_KEY_PASSWD_FILE
,
optarg
);
break
;
case
23
:
// --no-via
cmdcfgs
.
emplace_back
(
SHRPX_OPT_NO_VIA
,
"yes"
);
break
;
case
24
:
// --subcert
cmdcfgs
.
emplace_back
(
SHRPX_OPT_SUBCERT
,
optarg
);
break
;
case
25
:
// --http2-bridge
cmdcfgs
.
emplace_back
(
SHRPX_OPT_HTTP2_BRIDGE
,
"yes"
);
break
;
case
26
:
// --backend-http-proxy-uri
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_HTTP_PROXY_URI
,
optarg
);
break
;
case
27
:
// --backend-no-tls
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_NO_TLS
,
"yes"
);
break
;
case
29
:
// --frontend-no-tls
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND_NO_TLS
,
"yes"
);
break
;
case
31
:
// --backend-tls-sni-field
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_TLS_SNI_FIELD
,
optarg
);
break
;
case
33
:
// --dh-param-file
cmdcfgs
.
emplace_back
(
SHRPX_OPT_DH_PARAM_FILE
,
optarg
);
break
;
case
34
:
// --read-rate
cmdcfgs
.
emplace_back
(
SHRPX_OPT_READ_RATE
,
optarg
);
break
;
case
35
:
// --read-burst
cmdcfgs
.
emplace_back
(
SHRPX_OPT_READ_BURST
,
optarg
);
break
;
case
36
:
// --write-rate
cmdcfgs
.
emplace_back
(
SHRPX_OPT_WRITE_RATE
,
optarg
);
break
;
case
37
:
// --write-burst
cmdcfgs
.
emplace_back
(
SHRPX_OPT_WRITE_BURST
,
optarg
);
break
;
case
38
:
// --npn-list
cmdcfgs
.
emplace_back
(
SHRPX_OPT_NPN_LIST
,
optarg
);
break
;
case
39
:
// --verify-client
cmdcfgs
.
emplace_back
(
SHRPX_OPT_VERIFY_CLIENT
,
"yes"
);
break
;
case
40
:
// --verify-client-cacert
cmdcfgs
.
emplace_back
(
SHRPX_OPT_VERIFY_CLIENT_CACERT
,
optarg
);
break
;
case
41
:
// --client-private-key-file
cmdcfgs
.
emplace_back
(
SHRPX_OPT_CLIENT_PRIVATE_KEY_FILE
,
optarg
);
break
;
case
42
:
// --client-cert-file
cmdcfgs
.
emplace_back
(
SHRPX_OPT_CLIENT_CERT_FILE
,
optarg
);
break
;
case
43
:
// --frontend-http2-dump-request-header
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND_HTTP2_DUMP_REQUEST_HEADER
,
optarg
);
break
;
case
44
:
// --frontend-http2-dump-response-header
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND_HTTP2_DUMP_RESPONSE_HEADER
,
optarg
);
break
;
case
45
:
// --http2-no-cookie-crumbling
cmdcfgs
.
emplace_back
(
SHRPX_OPT_HTTP2_NO_COOKIE_CRUMBLING
,
"yes"
);
break
;
case
46
:
// --frontend-http2-connection-window-bits
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FRONTEND_HTTP2_CONNECTION_WINDOW_BITS
,
optarg
);
break
;
case
47
:
// --backend-http2-connection-window-bits
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_HTTP2_CONNECTION_WINDOW_BITS
,
optarg
);
break
;
case
48
:
// --tls-proto-list
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_PROTO_LIST
,
optarg
);
break
;
case
49
:
// --padding
cmdcfgs
.
emplace_back
(
SHRPX_OPT_PADDING
,
optarg
);
break
;
case
50
:
// --worker-read-rate
cmdcfgs
.
emplace_back
(
SHRPX_OPT_WORKER_READ_RATE
,
optarg
);
break
;
case
51
:
// --worker-read-burst
cmdcfgs
.
emplace_back
(
SHRPX_OPT_WORKER_READ_BURST
,
optarg
);
break
;
case
52
:
// --worker-write-rate
cmdcfgs
.
emplace_back
(
SHRPX_OPT_WORKER_WRITE_RATE
,
optarg
);
break
;
case
53
:
// --worker-write-burst
cmdcfgs
.
emplace_back
(
SHRPX_OPT_WORKER_WRITE_BURST
,
optarg
);
break
;
case
54
:
// --altsvc
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ALTSVC
,
optarg
);
break
;
case
55
:
// --add-response-header
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ADD_RESPONSE_HEADER
,
optarg
);
break
;
case
56
:
// --worker-frontend-connections
cmdcfgs
.
emplace_back
(
SHRPX_OPT_WORKER_FRONTEND_CONNECTIONS
,
optarg
);
break
;
case
57
:
// --accesslog-syslog
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ACCESSLOG_SYSLOG
,
"yes"
);
break
;
case
58
:
// --errorlog-file
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ERRORLOG_FILE
,
optarg
);
break
;
case
59
:
// --errorlog-syslog
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ERRORLOG_SYSLOG
,
"yes"
);
break
;
case
60
:
// --stream-read-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_STREAM_READ_TIMEOUT
,
optarg
);
break
;
case
61
:
// --stream-write-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_STREAM_WRITE_TIMEOUT
,
optarg
);
break
;
case
62
:
// --no-location-rewrite
cmdcfgs
.
emplace_back
(
SHRPX_OPT_NO_LOCATION_REWRITE
,
"yes"
);
break
;
case
63
:
// --backend-http1-connections-per-host
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_HTTP1_CONNECTIONS_PER_HOST
,
optarg
);
break
;
case
64
:
// --listener-disable-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_LISTENER_DISABLE_TIMEOUT
,
optarg
);
break
;
case
65
:
// --strip-incoming-x-forwarded-for
cmdcfgs
.
emplace_back
(
SHRPX_OPT_STRIP_INCOMING_X_FORWARDED_FOR
,
"yes"
);
break
;
case
66
:
// --accesslog-format
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ACCESSLOG_FORMAT
,
optarg
);
break
;
case
67
:
// --backend-http1-connections-per-frontend
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_HTTP1_CONNECTIONS_PER_FRONTEND
,
optarg
);
break
;
case
68
:
// --tls-ticket-key-file
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_TICKET_KEY_FILE
,
optarg
);
break
;
case
69
:
// --rlimit-nofile
cmdcfgs
.
emplace_back
(
SHRPX_OPT_RLIMIT_NOFILE
,
optarg
);
break
;
case
71
:
// --backend-response-buffer
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_RESPONSE_BUFFER
,
optarg
);
break
;
case
72
:
// --backend-request-buffer
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_REQUEST_BUFFER
,
optarg
);
break
;
case
73
:
// --no-host-rewrite
cmdcfgs
.
emplace_back
(
SHRPX_OPT_NO_HOST_REWRITE
,
"yes"
);
break
;
case
74
:
// --no-server-push
cmdcfgs
.
emplace_back
(
SHRPX_OPT_NO_SERVER_PUSH
,
"yes"
);
break
;
case
76
:
// --backend-http2-connections-per-worker
cmdcfgs
.
emplace_back
(
SHRPX_OPT_BACKEND_HTTP2_CONNECTIONS_PER_WORKER
,
optarg
);
break
;
case
77
:
// --fetch-ocsp-response-file
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FETCH_OCSP_RESPONSE_FILE
,
optarg
);
break
;
case
78
:
// --ocsp-update-interval
cmdcfgs
.
emplace_back
(
SHRPX_OPT_OCSP_UPDATE_INTERVAL
,
optarg
);
break
;
case
79
:
// --no-ocsp
cmdcfgs
.
emplace_back
(
SHRPX_OPT_NO_OCSP
,
"yes"
);
break
;
case
80
:
// --header-field-buffer
cmdcfgs
.
emplace_back
(
SHRPX_OPT_HEADER_FIELD_BUFFER
,
optarg
);
break
;
case
81
:
// --max-header-fields
cmdcfgs
.
emplace_back
(
SHRPX_OPT_MAX_HEADER_FIELDS
,
optarg
);
break
;
case
82
:
// --add-request-header
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ADD_REQUEST_HEADER
,
optarg
);
break
;
case
83
:
// --include
cmdcfgs
.
emplace_back
(
SHRPX_OPT_INCLUDE
,
optarg
);
break
;
case
84
:
// --tls-ticket-key-cipher
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_TICKET_KEY_CIPHER
,
optarg
);
break
;
case
85
:
// --host-rewrite
cmdcfgs
.
emplace_back
(
SHRPX_OPT_HOST_REWRITE
,
"yes"
);
break
;
case
86
:
// --tls-session-cache-memcached
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_SESSION_CACHE_MEMCACHED
,
optarg
);
break
;
case
87
:
// --tls-ticket-key-memcached
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED
,
optarg
);
break
;
case
88
:
// --tls-ticket-key-memcached-interval
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED_INTERVAL
,
optarg
);
break
;
case
89
:
// --tls-ticket-key-memcached-max-retry
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED_MAX_RETRY
,
optarg
);
break
;
case
90
:
// --tls-ticket-key-memcached-max-fail
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED_MAX_FAIL
,
optarg
);
break
;
case
91
:
// --mruby-file
cmdcfgs
.
emplace_back
(
SHRPX_OPT_MRUBY_FILE
,
optarg
);
break
;
case
93
:
// --accept-proxy-protocol
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ACCEPT_PROXY_PROTOCOL
,
"yes"
);
break
;
case
94
:
// --fastopen
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FASTOPEN
,
optarg
);
break
;
case
95
:
// --tls-dyn-rec-warmup-threshold
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_DYN_REC_WARMUP_THRESHOLD
,
optarg
);
break
;
case
96
:
// --tls-dyn-rec-idle-timeout
cmdcfgs
.
emplace_back
(
SHRPX_OPT_TLS_DYN_REC_IDLE_TIMEOUT
,
optarg
);
break
;
case
97
:
// --add-forwarded
cmdcfgs
.
emplace_back
(
SHRPX_OPT_ADD_FORWARDED
,
optarg
);
break
;
case
98
:
// --strip-incoming-forwarded
cmdcfgs
.
emplace_back
(
SHRPX_OPT_STRIP_INCOMING_FORWARDED
,
"yes"
);
break
;
case
99
:
// --forwarded-by
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FORWARDED_BY
,
optarg
);
break
;
case
100
:
// --forwarded-for
cmdcfgs
.
emplace_back
(
SHRPX_OPT_FORWARDED_FOR
,
optarg
);
break
;
default:
break
;
}
break
;
default:
break
;
}
}
if
(
get_config
()
->
rlimit_nofile
)
{
struct
rlimit
lim
=
{
static_cast
<
rlim_t
>
(
get_config
()
->
rlimit_nofile
),
static_cast
<
rlim_t
>
(
get_config
()
->
rlimit_nofile
)};
if
(
setrlimit
(
RLIMIT_NOFILE
,
&
lim
)
!=
0
)
{
auto
error
=
errno
;
LOG
(
WARN
)
<<
"Setting rlimit-nofile failed: "
<<
strerror
(
error
);
}
}
auto
&
fwdconf
=
mod_config
()
->
http
.
forwarded
;
if
(
fwdconf
.
by_node_type
==
FORWARDED_NODE_OBFUSCATED
&&
fwdconf
.
by_obfuscated
.
empty
())
{
std
::
random_device
rd
;
std
::
mt19937
gen
(
rd
());
auto
&
dst
=
fwdconf
.
by_obfuscated
;
dst
=
"_"
;
dst
+=
util
::
random_alpha_digit
(
gen
,
SHRPX_OBFUSCATED_NODE_LENGTH
);
}
if
(
get_config
()
->
http2
.
upstream
.
debug
.
frame_debug
)
{
// To make it sync to logging
set_output
(
stderr
);
if
(
isatty
(
fileno
(
stdout
)))
{
set_color_output
(
true
);
}
reset_timer
();
}
mod_config
()
->
http2
.
upstream
.
callbacks
=
create_http2_upstream_callbacks
();
mod_config
()
->
http2
.
downstream
.
callbacks
=
create_http2_downstream_callbacks
();
process_options
(
argc
,
argv
,
cmdcfgs
);
if
(
event_loop
()
!=
0
)
{
return
-
1
;
...
...
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