aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlack Coder <slackcoder@server.ky>2019-06-03 14:39:30 +0200
committerSlack Coder <slackcoder@server.ky>2019-06-03 14:39:30 +0200
commit31eeb79a19024e9e1bbcb1681a4e739ddf41254a (patch)
tree7f6f97a65814d0a72285a7ffe381a3dfc9146762
parentd45089ececece70342d0f0b9c357e0715fbe3b80 (diff)
downloadslackware.com-client-31eeb79a19024e9e1bbcb1681a4e739ddf41254a.tar.xz
Add support for onion hosts
-rwxr-xr-xslackware.com11
1 files changed, 10 insertions, 1 deletions
diff --git a/slackware.com b/slackware.com
index 5fced45..4684c6b 100755
--- a/slackware.com
+++ b/slackware.com
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
require "time"
+require "uri"
# TODO: List changelog entries per package
# TODO: List mirrors
@@ -76,6 +77,11 @@ def exitOnError(arg)
exit(1)
end
+# is_onion checks the argument is a TOR host
+def is_onion(host)
+ %r{.onion$}.match(host) != nil
+end
+
def verifySynced(path)
unless File.exists?(path)
exitOnError(SyncRequiredError.new("#{path} not found"))
@@ -285,11 +291,14 @@ class Local
dst = File.join(dst, File.basename(src)) if File.directory?(dst)
File.unlink(dst) if File.exists?(dst)
+ src_uri = URI(src)
command = ["wget",
"-O", dst,
- src
+ src_uri.to_s,
]
command << "--quiet" if QUIET == "true"
+ command.unshift("torsocks") if is_onion(src_uri.host)
+
ok = system(*command)
ok ? nil : DownloadError.new(src)
end