tcpfiletransfer 0.0.1 → 0.0.3
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.
- checksums.yaml +4 -4
- data/bin/sendfile +6 -5
- data/lib/filetransfer/httpserver.rb +9 -1
- data/lib/filetransfer/notifier.rb +20 -3
- data/lib/filetransfer.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 100f377c1c4e71b9b9fcd6ca3f236077c78e036770f99c003f6d8d35e220b84b
|
4
|
+
data.tar.gz: c8ce3c868a83dec7c853579cda99c1733f43f5c33ab1d80c25a23b50e15aabcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdeaca3253f4325db1140e6602ff295690b7d87bd1373c4c013376748f190cb63ac5e01d26b023dbb8550dae120e243ee92bb1c363592facb094fd6f6d62cd74
|
7
|
+
data.tar.gz: c0f28980e0bdb5596db428462cf3da10306c9473f990f4d0dd5eae87d3d8272b9f94a8b60475c2716d1d519c74a40b67751235de9619c4791a82bc1793929870
|
data/bin/sendfile
CHANGED
@@ -2,17 +2,18 @@
|
|
2
2
|
require "filetransfer"
|
3
3
|
require "socket"
|
4
4
|
|
5
|
-
|
6
|
-
name = ARGV[0].split("/").last.gsub(" ", "_")
|
5
|
+
originalpath = ARGV[0] || `zenity --file-selection --title='Send File'`.chomp
|
7
6
|
|
8
|
-
|
9
|
-
|
7
|
+
path = originalpath.gsub(" ", "`")
|
8
|
+
name = originalpath.split("/").last.gsub(" ", "_")
|
9
|
+
|
10
|
+
recipient = ARGV[1] || `zenity --text='Recipient' --entry --title='Send File'`.chomp
|
10
11
|
|
11
12
|
server = TCPSocket.new("127.0.0.1", 8021)
|
12
13
|
server.puts "FTSUBMIT #{name} #{path}"
|
13
14
|
fileid = server.gets
|
14
15
|
|
15
|
-
file_size = '%.2f' % (File.size(
|
16
|
+
file_size = '%.2f' % (File.size(originalpath).to_f / 2**20)
|
16
17
|
|
17
18
|
server = TCPSocket.new(recipient, 8021)
|
18
19
|
server.puts "FTSEND #{name.gsub(" ", "_")} #{file_size}MB #{fileid}"
|
@@ -1,7 +1,15 @@
|
|
1
1
|
module FileTransfer
|
2
2
|
module HTTPserver
|
3
3
|
def self.handle_client(initdata, client)
|
4
|
-
path = initdata[1]
|
4
|
+
path = initdata[1].split("/")
|
5
|
+
decline = (path[2] == "decline")
|
6
|
+
path = ?/ + path[1]
|
7
|
+
if decline
|
8
|
+
$active_transfers.delete(path)
|
9
|
+
client.puts "HTTP/1.0 200\r\nContent-Type: text/plain\r\n\r\nTransfer declined"
|
10
|
+
client.close
|
11
|
+
return
|
12
|
+
end
|
5
13
|
file = $active_transfers[path]
|
6
14
|
|
7
15
|
read = true
|
@@ -3,10 +3,27 @@ module FileTransfer
|
|
3
3
|
def self.file_transfer_notification(filename:, source:, filesize:, accept_link:)
|
4
4
|
notification_title = "Incoming file transfer from #{source}"
|
5
5
|
fileinfo = "Name: #{filename}\nSize: #{filesize}"
|
6
|
-
|
7
|
-
notification_body = "#{fileinfo}\n#{links}"
|
6
|
+
notification_body = "#{fileinfo}\nWould you like to accept?"
|
8
7
|
notification_command = "notify-send '#{notification_title}' \"#{notification_body}\""
|
9
|
-
system(notification_command)
|
8
|
+
#system(notification_command)
|
9
|
+
|
10
|
+
x=system("zenity --question --no-wrap --text=\"#{notification_body}\" --title='#{notification_title}'")
|
11
|
+
if x
|
12
|
+
file_location = `zenity --file-selection --save --filename=#{filename}`
|
13
|
+
if file_location == ""
|
14
|
+
f=open(accept_link + "/decline")
|
15
|
+
f.read
|
16
|
+
return
|
17
|
+
end
|
18
|
+
open(accept_link) do |f|
|
19
|
+
File.open(file_location, "wb") do |file|
|
20
|
+
file.write(f.read)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
else
|
24
|
+
f=open(accept_link + "/decline")
|
25
|
+
f.read
|
26
|
+
end
|
10
27
|
end
|
11
28
|
end
|
12
29
|
end
|
data/lib/filetransfer.rb
CHANGED
@@ -5,7 +5,7 @@ module FileTransfer
|
|
5
5
|
@@files = ['server.rb', 'notifier.rb', 'httpserver.rb', 'ftserver.rb']
|
6
6
|
|
7
7
|
def self.version
|
8
|
-
"0.0.
|
8
|
+
"0.0.3"
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.file_paths(relative:false)
|
@@ -22,6 +22,7 @@ module FileTransfer
|
|
22
22
|
end
|
23
23
|
|
24
24
|
require "socket"
|
25
|
+
require "open-uri"
|
25
26
|
FileTransfer.file_paths(relative:true).each do |f|
|
26
27
|
require_relative f
|
27
28
|
end
|