Skip to content

Commit

Permalink
Merge pull request #1 from spider-gazelle/crystal-0.36.0
Browse files Browse the repository at this point in the history
feat: add support for crystal 0.36.0
  • Loading branch information
stakach authored Jan 28, 2021
2 parents c1e5606 + 445884c commit 3df4915
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
3 changes: 2 additions & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
name: connect-proxy
version: 1.0.0
version: 1.0.1
license: MIT
20 changes: 14 additions & 6 deletions src/connect-proxy.cr
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,27 @@ class ConnectProxy
end

def set_proxy(proxy : ConnectProxy? = nil)
socket = @socket
socket = {% if compare_versions(Crystal::VERSION, "0.36.0") < 0 %} @socket {% else %} @io {% end %}
return if socket && !socket.closed?

if !proxy
host, port = ConnectProxy.parse_proxy_url
proxy = ConnectProxy.new(host, port)
end

begin
@socket = proxy.open(@host, @port, @tls, **proxy_connection_options)
rescue IO::Error
@socket = nil
end
{% if compare_versions(Crystal::VERSION, "0.36.0") < 0 %}
begin
@socket = proxy.open(@host, @port, @tls, **proxy_connection_options)
rescue IO::Error
@socket = nil
end
{% else %}
begin
@io = proxy.open(@host, @port, @tls, **proxy_connection_options)
rescue IO::Error
@io = nil
end
{% end %}
end

def proxy_connection_options
Expand Down

0 comments on commit 3df4915

Please sign in to comment.