proxied_ftp 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/proxied_ftp.rb +52 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0a2142bbf61ba575fec941a7a93b5e4e9af53e39
4
+ data.tar.gz: e052a6715c4f0db466aeca00d1a874390f0d1a49
5
+ SHA512:
6
+ metadata.gz: d84551796322ba9dc0e2f18d369966ca5c4b5c533fe7c740ffe8de17486c3ec561266f3fc5b26d215217cfcece4b5eee6c988602ec6eec6b5415baffcce6f8d2
7
+ data.tar.gz: cbe19f189d2f69bfaebb554403516eb151f8b29e2abc6f463acee3da45fcb88290ff8d2e911f0b55e2340cd39da113d7fc8ac2b3a2ceeaae8a923da5ac6eb667
@@ -0,0 +1,52 @@
1
+ require 'net/ftp'
2
+ require 'base64'
3
+
4
+ class ProxiedFtp < Net::FTP
5
+ attr_reader :p_host, :p_port
6
+
7
+ def self.open(p_host, p_port, host, user = nil, passwd = nil, acct = nil)
8
+ if block_given?
9
+ ftp = new(p_host, p_port, host, user, passwd, acct)
10
+ begin
11
+ yield ftp
12
+ ensure
13
+ ftp.close
14
+ end
15
+ else
16
+ new(p_host, p_port, host, user, passwd, acct)
17
+ end
18
+ end
19
+
20
+ def initialize(p_host, p_port, host = nil, user = nil, passwd = nil, acct = nil)
21
+ @p_host = p_host
22
+ @p_port = p_port
23
+ super(host, user, passwd, acct)
24
+ end
25
+
26
+ private
27
+
28
+ def open_socket(host, port)
29
+ return Timeout.timeout(@open_timeout, Net::OpenTimeout) do
30
+ if defined? SOCKSSocket and ENV["SOCKS_SERVER"]
31
+ @passive = true
32
+ sock = SOCKSSocket.open(host, port)
33
+ else
34
+ # Every connection to the ftp server goes through our proxy server
35
+ proxy = TCPSocket.open(p_host, p_port)
36
+ proxy.write("CONNECT #{host}:#{port} HTTP/1.1")
37
+ proxy.write(CRLF)
38
+ proxy.write(CRLF)
39
+
40
+ sock = proxy
41
+ end
42
+ io = BufferedSocket.new(sock)
43
+ io.read_timeout = @read_timeout
44
+ # The following two lines of code is used for escaping unneccessary
45
+ # information from the stream ("HTTP/1.1 200 Connection established" and
46
+ # ""(empty line))
47
+ io.gets
48
+ io.gets
49
+ io
50
+ end
51
+ end
52
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: proxied_ftp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Pavel
8
+ - Balashov
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-07-16 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Provide proxied ftp client
15
+ email: ba1ashpash@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/proxied_ftp.rb
21
+ homepage: http://rubygems.org/gems/proxied_ftp
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.5.1
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Proxied ftp client
45
+ test_files: []