Skip to content

Commit

Permalink
metanorma/metanorma#202 add socksify dependency and support SOCKS_PRO…
Browse files Browse the repository at this point in the history
…XY env var
  • Loading branch information
CAMOBAP committed Jul 15, 2021
1 parent 142ac87 commit 71c7215
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion exe/metanorma
Expand Up @@ -17,4 +17,18 @@ end

# start up the CLI
require "metanorma/cli"
Metanorma::Cli.start(ARGV)
metanorma_cli = proc { Metanorma::Cli.start(ARGV) }
if ENV["SOCKS_PROXY"]
require "socksify"
require "uri"
begin
proxy = URI.parse(ENV["SOCKS_PROXY"])
Socksify::proxy(proxy.host, proxy.port, &metanorma_cli)
rescue URI::InvalidURIError
warn "Value of ENV.SOCKS_PROXY=#{ENV['SOCKS_PROXY']} is invalid! Droping it"
ENV.delete("SOCKS_PROXY")
metanorma_cli.call
end
else
metanorma_cli.call
end
2 changes: 2 additions & 0 deletions metanorma-cli.gemspec
Expand Up @@ -58,4 +58,6 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "metanorma-ogc", "~> 1.3.0"
spec.add_runtime_dependency "metanorma-un", "~> 0.6.0"
spec.add_runtime_dependency "relaton-cli", ">= 0.8.2"

spec.add_runtime_dependency "socksify"
end

0 comments on commit 71c7215

Please sign in to comment.