Commit 551ae72f authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Remove spdyd and spdycat

parent 9e9a7fb1
......@@ -979,6 +979,7 @@ int HttpServer::run()
SSL_CTX_set_options(ssl_ctx, SSL_OP_ALL|SSL_OP_NO_SSLv2);
SSL_CTX_set_mode(ssl_ctx, SSL_MODE_AUTO_RETRY);
SSL_CTX_set_mode(ssl_ctx, SSL_MODE_RELEASE_BUFFERS);
SSL_CTX_set_mode(ssl_ctx, SSL_MODE_ENABLE_PARTIAL_WRITE);
if(SSL_CTX_use_PrivateKey_file(ssl_ctx,
config_->private_key_file.c_str(),
SSL_FILETYPE_PEM) != 1) {
......
......@@ -35,11 +35,7 @@ AM_CXXFLAGS = -std=c++11
LDADD = $(top_builddir)/lib/libnghttp2.la
bin_PROGRAMS += spdycat nghttp nghttpd
if ENABLE_SPDYD
bin_PROGRAMS += spdyd
endif # ENABLE_SPDYD
bin_PROGRAMS += nghttp nghttpd
if HAVE_LIBEVENT_OPENSSL
# bin_PROGRAMS += shrpx
......@@ -68,10 +64,6 @@ if HAVE_LIBXML2
HTML_PARSER_OBJECTS += HtmlParser.cc
endif # HAVE_LIBXML2
spdycat_SOURCES = ${HELPER_OBJECTS} ${HELPER_HFILES} spdycat.cc \
${HTML_PARSER_OBJECTS} ${HTML_PARSER_HFILES} \
http-parser/http_parser.c http-parser/http_parser.h
nghttp_SOURCES = ${HELPER_OBJECTS} ${HELPER_HFILES} nghttp.cc \
${HTML_PARSER_OBJECTS} ${HTML_PARSER_HFILES} \
http-parser/http_parser.c http-parser/http_parser.h
......@@ -79,16 +71,6 @@ nghttp_SOURCES = ${HELPER_OBJECTS} ${HELPER_HFILES} nghttp.cc \
nghttpd_SOURCES = ${HELPER_OBJECTS} ${HELPER_HFILES} nghttpd.cc \
HttpServer.cc HttpServer.h
if ENABLE_SPDYD
SPDY_SERVER_OBJECTS = SpdyServer.cc
SPDY_SERVER_HFILES = SpdyServer.h
spdyd_SOURCES = ${HELPER_OBJECTS} ${HELPER_HFILES} \
${EVENT_OBJECTS} ${EVENT_HFILES} \
${SPDY_SERVER_OBJECTS} ${SPDY_SERVER_HFILES} \
spdyd.cc
endif # ENABLE_SPDYD
if HAVE_LIBEVENT_OPENSSL
# SHRPX_SRCS = \
# util.cc util.h timegm.c timegm.h base64.h \
......
This diff is collapsed.
/*
* nghttp2 - HTTP/2.0 C Library
*
* Copyright (c) 2012 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 SPDY_SERVER_H
#define SPDY_SERVER_H
#include "nghttp2_config.h"
#include <stdint.h>
#include <sys/types.h>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <openssl/ssl.h>
#include <nghttp2/nghttp2.h>
namespace nghttp2 {
struct Config {
std::string htdocs;
bool verbose;
bool daemon;
std::string host;
uint16_t port;
std::string private_key_file;
std::string cert_file;
nghttp2_on_request_recv_callback on_request_recv_callback;
void *data_ptr;
bool verify_client;
bool no_tls;
Config();
};
class Sessions;
class EventHandler {
public:
EventHandler(const Config *config);
virtual ~EventHandler() {}
virtual int execute(Sessions *sessions) = 0;
virtual bool want_read() = 0;
virtual bool want_write() = 0;
virtual int fd() const = 0;
virtual bool finish() = 0;
const Config* config() const
{
return config_;
}
bool mark_del()
{
return mark_del_;
}
void mark_del(bool d)
{
mark_del_ = d;
}
private:
const Config *config_;
bool mark_del_;
};
struct Request {
int32_t stream_id;
std::vector<std::pair<std::string, std::string>> headers;
int file;
std::pair<std::string, size_t> response_body;
Request(int32_t stream_id);
~Request();
};
class SpdyEventHandler : public EventHandler {
public:
SpdyEventHandler(const Config* config,
int fd, SSL *ssl,
const nghttp2_session_callbacks *callbacks,
int64_t session_id);
virtual ~SpdyEventHandler();
virtual int execute(Sessions *sessions);
virtual bool want_read();
virtual bool want_write();
virtual int fd() const;
virtual bool finish();
ssize_t send_data(const uint8_t *data, size_t len, int flags);
ssize_t recv_data(uint8_t *data, size_t len, int flags);
bool would_block() const;
int submit_file_response(const std::string& status,
int32_t stream_id,
time_t last_modified,
off_t file_length,
nghttp2_data_provider *data_prd);
int submit_response(const std::string& status,
int32_t stream_id,
nghttp2_data_provider *data_prd);
int submit_response
(const std::string& status,
int32_t stream_id,
const std::vector<std::pair<std::string, std::string>>& headers,
nghttp2_data_provider *data_prd);
void add_stream(int32_t stream_id, Request *req);
void remove_stream(int32_t stream_id);
Request* get_stream(int32_t stream_id);
int64_t session_id() const;
private:
nghttp2_session *session_;
int fd_;
SSL* ssl_;
int64_t session_id_;
uint8_t io_flags_;
std::map<int32_t, Request*> id2req_;
};
class SpdyServer {
public:
SpdyServer(const Config* config);
~SpdyServer();
int listen();
int run();
private:
const Config *config_;
int sfd_[2];
};
void htdocs_on_request_recv_callback
(nghttp2_session *session, int32_t stream_id, void *user_data);
ssize_t file_read_callback
(nghttp2_session *session, int32_t stream_id,
uint8_t *buf, size_t length, int *eof,
nghttp2_data_source *source, void *user_data);
} // namespace nghttp2
#endif // SPDY_SERVER_H
This diff is collapsed.
......@@ -41,55 +41,10 @@ namespace nghttp2 {
extern bool ssl_debug;
class Spdylay {
public:
Spdylay(int fd, SSL *ssl,
const nghttp2_session_callbacks *callbacks,
void *user_data);
~Spdylay();
int recv();
int send();
ssize_t send_data(const uint8_t *data, size_t len, int flags);
ssize_t recv_data(uint8_t *data, size_t len, int flags);
bool want_read();
bool want_write();
bool finish();
int fd() const;
int submit_request(const std::string& scheme,
const std::string& hostport, const std::string& path,
const std::map<std::string,std::string>& headers,
int32_t pri,
const nghttp2_data_provider *data_prd,
int64_t data_length,
void *stream_user_data);
int submit_settings(nghttp2_settings_entry *iv, size_t niv);
bool would_block();
void* user_data();
private:
int fd_;
SSL *ssl_;
nghttp2_session *session_;
void *user_data_;
uint8_t io_flags_;
bool debug_;
};
int connect_to(const std::string& host, uint16_t port);
int nonblock_connect_to(const std::string& host, uint16_t port, int timeout);
int make_listen_socket(const std::string& host, uint16_t port, int family);
int make_non_block(int fd);
int set_tcp_nodelay(int fd);
ssize_t send_callback(nghttp2_session *session,
const uint8_t *data, size_t len, int flags,
void *user_data);
ssize_t recv_callback(nghttp2_session *session,
uint8_t *data, size_t len, int flags, void *user_data);
int select_next_proto_cb(SSL* ssl,
unsigned char **out, unsigned char *outlen,
const unsigned char *in, unsigned int inlen,
void *arg);
void print_nv(char **nv);
......@@ -126,19 +81,6 @@ void on_data_send_callback
(nghttp2_session *session, uint16_t length, uint8_t flags, int32_t stream_id,
void *user_data);
void ctl_poll(pollfd *pollfd, Spdylay *sc);
int select_next_proto_cb(SSL* ssl,
unsigned char **out, unsigned char *outlen,
const unsigned char *in, unsigned int inlen,
void *arg);
void setup_ssl_ctx(SSL_CTX *ssl_ctx, void *next_proto_select_cb_arg);
int ssl_handshake(SSL *ssl, int fd);
int ssl_nonblock_handshake(SSL *ssl, int fd, int& timeout);
// Returns difference between |a| and |b| in milliseconds, assuming
// |a| is more recent than |b|.
int64_t time_delta(const timeval& a, const timeval& b);
......@@ -151,13 +93,6 @@ int get_time(timeval *tv);
void print_timer();
enum {
WANT_READ = 1,
WANT_WRITE = 1 << 1
};
uint8_t get_ssl_io_demand(SSL *ssl, ssize_t r);
// Setting true will print characters with ANSI color escape codes
// when printing SPDY frames. This function changes a static variable.
void set_color_output(bool f);
......
This diff is collapsed.
/*
* nghttp2 - HTTP/2.0 C Library
*
* Copyright (c) 2012 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.
*/
#include <unistd.h>
#include <signal.h>
#include <getopt.h>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <iostream>
#include <string>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <nghttp2/nghttp2.h>
#include "nghttp2_ssl.h"
#include "SpdyServer.h"
namespace nghttp2 {
extern bool ssl_debug;
namespace {
void print_usage(std::ostream& out)
{
out << "Usage: spdyd [-DVhv] [-d <PATH>] [--no-tls] <PORT> [<PRIVATE_KEY> <CERT>]"
<< std::endl;
}
} // namespace
namespace {
void print_help(std::ostream& out)
{
print_usage(out);
out << "\n"
<< "OPTIONS:\n"
<< " -D, --daemon Run in a background. If -D is used, the\n"
<< " current working directory is changed to '/'.\n"
<< " Therefore if this option is used, -d option\n"
<< " must be specified.\n"
<< " -V, --verify-client\n"
<< " The server sends a client certificate\n"
<< " request. If the client did not return a\n"
<< " certificate, the handshake is terminated.\n"
<< " Currently, this option just requests a\n"
<< " client certificate and does not verify it.\n"
<< " -d, --htdocs=<PATH>\n"
<< " Specify document root. If this option is\n"
<< " not specified, the document root is the\n"
<< " current working directory.\n"
<< " -v, --verbose Print debug information such as reception/\n"
<< " transmission of frames and name/value pairs.\n"
<< " --no-tls Disable SSL/TLS.\n"
<< " -h, --help Print this help.\n"
<< std::endl;
}
} // namespace
int main(int argc, char **argv)
{
Config config;
while(1) {
int flag;
static option long_options[] = {
{"daemon", no_argument, 0, 'D' },
{"htdocs", required_argument, 0, 'd' },
{"help", no_argument, 0, 'h' },
{"verbose", no_argument, 0, 'v' },
{"verify-client", no_argument, 0, 'V' },
{"no-tls", no_argument, &flag, 1 },
{0, 0, 0, 0 }
};
int option_index = 0;
int c = getopt_long(argc, argv, "DVd:hv", long_options, &option_index);
if(c == -1) {
break;
}
switch(c) {
case 'D':
config.daemon = true;
break;
case 'V':
config.verify_client = true;
break;
case 'd':
config.htdocs = optarg;
break;
case 'h':
print_help(std::cout);
exit(EXIT_SUCCESS);
case 'v':
config.verbose = true;
break;
case '?':
exit(EXIT_FAILURE);
case 0:
switch(flag) {
case 1:
// no-tls option
config.no_tls = true;
break;
}
break;
default:
break;
}
}
if(argc - optind < (config.no_tls ? 1 : 3)) {
print_usage(std::cerr);
std::cerr << "Too few arguments" << std::endl;
exit(EXIT_FAILURE);
}
config.port = strtol(argv[optind++], 0, 10);
if(!config.no_tls) {
config.private_key_file = argv[optind++];
config.cert_file = argv[optind++];
}
if(config.daemon) {
if(config.htdocs.empty()) {
print_usage(std::cerr);
std::cerr << "-d option must be specified when -D is used." << std::endl;
exit(EXIT_FAILURE);
}
if(daemon(0, 0) == -1) {
perror("daemon");
exit(EXIT_FAILURE);
}
}
if(config.htdocs.empty()) {
config.htdocs = "./";
}
set_color_output(isatty(fileno(stdout)));
struct sigaction act;
memset(&act, 0, sizeof(struct sigaction));
act.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &act, 0);
OpenSSL_add_all_algorithms();
SSL_load_error_strings();
SSL_library_init();
reset_timer();
config.on_request_recv_callback = htdocs_on_request_recv_callback;
ssl_debug = config.verbose;
SpdyServer server(&config);
if(server.listen() == 0) {
server.run();
}
return 0;
}
} // namespace nghttp2
int main(int argc, char **argv)
{
return nghttp2::main(argc, argv);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment