-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap #bind_ssl in
unless flag?(:without_openssl)
- Loading branch information
1 parent
b3d8a98
commit f042096
Showing
1 changed file
with
35 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,40 +182,42 @@ class HTTP::Server | |
server.local_address | ||
end | ||
|
||
# Creates a `OpenSSL::SSL::Server` and adds it as a socket. | ||
# | ||
# The SSL server wraps a `TCPServer` listenting on `host:port`. | ||
# | ||
# ``` | ||
# server = HTTP::Server.new { } | ||
# context = OpenSSL::SSL::Context::Server.new | ||
# context.certificate_chain = "openssl.crt" | ||
# context.private_key = "openssl.key" | ||
# server.bind_ssl "127.0.0.1", 8080, context | ||
# ``` | ||
def bind_ssl(host : String, port : Int32, context : OpenSSL::SSL::Context::Server = OpenSSL::SSL::Context::Server.new, reuse_port : Bool = false) : Socket::IPAddress | ||
tcp_server = TCPServer.new(host, port, reuse_port) | ||
server = OpenSSL::SSL::Server.new(tcp_server, context) | ||
|
||
bind(server) | ||
|
||
tcp_server.local_address | ||
end | ||
{% unless flag?(:without_openssl) %} | ||
# Creates a `OpenSSL::SSL::Server` and adds it as a socket. | ||
# | ||
# The SSL server wraps a `TCPServer` listenting on `host:port`. | ||
# | ||
# ``` | ||
# server = HTTP::Server.new { } | ||
# context = OpenSSL::SSL::Context::Server.new | ||
# context.certificate_chain = "openssl.crt" | ||
# context.private_key = "openssl.key" | ||
# server.bind_ssl "127.0.0.1", 8080, context | ||
# ``` | ||
def bind_ssl(host : String, port : Int32, context : OpenSSL::SSL::Context::Server = OpenSSL::SSL::Context::Server.new, reuse_port : Bool = false) : Socket::IPAddress | ||
tcp_server = TCPServer.new(host, port, reuse_port) | ||
server = OpenSSL::SSL::Server.new(tcp_server, context) | ||
|
||
bind(server) | ||
|
||
tcp_server.local_address | ||
end | ||
|
||
# Creates a `OpenSSL::SSL::Server` and adds it as a socket. | ||
# | ||
# The SSL server wraps a `TCPServer` listenting on an unused port on *host*. | ||
# | ||
# ``` | ||
# server = HTTP::Server.new { } | ||
# context = OpenSSL::SSL::Context::Server.new | ||
# context.certificate_chain = "openssl.crt" | ||
# context.private_key = "openssl.key" | ||
# address = server.bind_ssl "127.0.0.1", context | ||
# ``` | ||
def bind_ssl(host : String, context : OpenSSL::SSL::Context::Server = OpenSSL::SSL::Context::Server.new) : Socket::IPAddress | ||
bind_ssl(host, 0, context) | ||
end | ||
# Creates a `OpenSSL::SSL::Server` and adds it as a socket. | ||
# | ||
# The SSL server wraps a `TCPServer` listenting on an unused port on *host*. | ||
# | ||
# ``` | ||
# server = HTTP::Server.new { } | ||
# context = OpenSSL::SSL::Context::Server.new | ||
# context.certificate_chain = "openssl.crt" | ||
# context.private_key = "openssl.key" | ||
# address = server.bind_ssl "127.0.0.1", context | ||
# ``` | ||
def bind_ssl(host : String, context : OpenSSL::SSL::Context::Server = OpenSSL::SSL::Context::Server.new) : Socket::IPAddress | ||
bind_ssl(host, 0, context) | ||
end | ||
{% endunless %} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
straight-shoota
Author
Member
|
||
|
||
# Adds a `Socket::Server` *socket* to this server. | ||
def bind(socket : Socket::Server) : Nil | ||
|
{% end %}