फ़ाइल स्थानांतरण
THIS PAGE IS DEPRECATED: READ File transfer
इसका इस्तेमाल कैसे करें?
एंड्रॉइड
जब आप एंड्रॉइड पर किसी से बात कर रहे हों, तो आपके पास अपने डिवाइस पर एक तस्वीर भेजने या इन बटनों के साथ एक तस्वीर लेने की संभावना हैः
टिप्पणी
When you send a file, the other has to accept it. At this moment you will see 'awaiting peer':
यह कैसे काम करता है?
यह कैसे काम करता है
परिचय
जेमी एक वितरित एप्लिकेशन है और इसे इंटरनेट कनेक्शन के बिना काम करना है। तो, फ़ाइल ट्रांसफर भी! मूल रूप से, हम फ़ाइल ट्रांसफर और कॉल करने के लिए एक ही विधि का उपयोग करते हैं, लेकिन टीसीपी में। यह कैसे काम करता है इसका सारांश देने के लिए, हम एक ऐसी स्थिति की कल्पना कर सकते हैं जहां एलिस (ए) बॉब (बी) को फ़ाइल स्थानांतरित करना चाहता है।
First, Alice will request a connection to Bob. To do that, Jami is using ICE (RFC 6544), a protocol used to negotiate links between peers. Alice will send, into an encrypted packet via the DHT the IP address of its device. So, when Bob receives the IP addresses of Alice, they will be able to negotiate a transport where Bob will be able to send packets to Alice. The negotiation can be successful, but if it fails, a TURN server will be used (the one configured into the settings) to perform the transfer. If the negotiation succeeds, Bob will send its IP addresses to Alice to perform the negotiation in the other direction. Note that the link is still not secure, so Bob will send the IP addresses through the DHT network in an encrypted message. If the second negotiation fails, the TURN will be used as a fallback.
अब जब दो दिशाओं का टीसीपी लिंक यहाँ है, अगला कदम एलिस और बॉब के बीच एक टीएलएस 1.3 (आमतौर पर एक (टीएलएस 1.3)-(डीएचई-एफएफडीएचई 8192)-(आरएसए-पीएसएस-आरएसएई-एसएचए 384)-(एईएस-256-जीसीएम) पर बातचीत करना होगा, जब मैं इन पंक्तियों को लिखता हूं, तो एलिस फ़ाइल को स्थानांतरित करना शुरू कर देगा।
पहला भाग फ़ाइल की सामग्री का वर्णन करने के लिए एक छोटा हेडर होगा। फिर, जब बॉब स्थानांतरण को स्वीकार कर लेगा, तो पूरी फ़ाइल प्रेषित की जाएगी।
प्रक्रिया
फ़ाइल भेजना
निम्नलिखित विधि का प्रयोग किया जाता हैः
A client will call
DataTransferFacade::sendFile()
.DataTransferFacade
is the class corresponding to the API exposed for the clients. It is used to manage a view of the file transfers (the corresponding classes areDataTransfer
,IncomingFileTransfer
,OutgoingFileTransfer
andSubOutgoingFileTransfer
). This method will ask the linkedJamiAccount
to request a connection.The method
DhtPeerConnector: requestConnection()
is triggered and creates a connection between all connected devices of the peer (found on the DHT).DhtPeerConnector
is used to manage the main event loop which manage connections. When a device is found, the event loop will create aClientConnector
(which manage the connection for one device) and launch theprocess()
method.This method is used to initialize the ICE transport and put a PeerConnectionMsg (which contains the SDP message, see below) on the DHT and waits for a response (
DhtPeerConnector::Impl::onResponseMsg
).Then a response is received from the DHT, which contains public addresses of the peer device. We can now negotiate a TLS link (directly via ICE, or via TURN as a fallback). This
TlsSocketEndpoint
is given to thePeerConnection
object as an output and the transfer can start.When the TLS socket is ready, the callback
DataTransferFacade::Impl::onConnectionRequestReply
is called, and aOutgoingFileTransfer
is linked to thePeerConnection
as an input. ThisOutgoingFileTransfer
contains a list ofSubOutgoingFileTransfer
(one per device) where each sub transfer is a transfer to one device. We do that to be able to furnish the most optimistic view of the transfer (if a contact as 3 devices, where the contact cancel the transfer on one device, but accepted the transfer on the two others, the most advanced transfer will be shown).The
SubOutgoingFileTransfer
will first transfer the header of the file, wait the peer acceptance (A "GO\n" message on the socket) and then will send the file.If a cancel is received from the peer or the client or if the file transfer finish, the connection will be closed via a
CANCEL
message on theDhtPeerConnector::eventLoop()
and the resources will be released.
फ़ाइल प्राप्त करना
फ़ाइलों को प्राप्त करने के लिए एक ही संरचना का उपयोग किया जाता है, लेकिन विधि थोड़ा बदल जाती हैः
JamiAccount
वर्ग का उपयोग DHT से संदेश प्राप्त करने के लिए किया जाता है, क्योंकि पहली चीज प्राप्त DHT अनुरोध होगा।इसके बाद, यह संदेश
DhtPeerConnector: onRequestMessage()
को eventLoop के माध्यम से दिया जाता है।DhtPeerConnector::Impl::answerToRequest
TURN सर्वर से कनेक्ट करने का प्रयास करेगा (यदि कनेक्ट नहीं है) और ICE परिवहन को प्रारंभ करेगा। यह विधि एक TURN सर्वर के लिए 2 नियंत्रण कनेक्शन खोलती है (एक IPv4 समकक्षों को अधिकृत करने के लिए, एक IPv6 समकक्षों के लिए RFC 6156 के कारण) यदि यह पहले से ही खुला नहीं है और कनेक्शन की अनुमति देता है समकक्ष सार्वजनिक पते। फिर, यदि प्राप्त SDP में ICE उम्मीदवार नहीं हैं, तो TURN का उपयोग करेगा और समकक्षों के लिए प्रतीक्षा करने के लिए SDP उत्तर तैयार करेगा। यदि SDP में ICE उम्मीदवार हैं, तो विधि लिंक पर बातचीत करने का प्रयास करेगी (या TURN पर वापस गिरना) और फिर SDP (आईसीई उम्मीदवारों के साथ या नहीं) का जवाब देगा।एक बार लिंक तैयार हो जाने के बाद, जैसे प्रेषक, एक TLS लिंक पर बातचीत की जाती है और
PeerConnection
कोIncomingFileTransfer
को इनपुट के रूप में दिया जाता है। फ़ाइल के हेडर आएंगे और ग्राहक अब स्थानांतरण को स्वीकार या रद्द कर सकता है।
पूर्व फ़ाइल स्थानांतरण के लिए पुनः अनुरोध
As specified in Other mime types, the data-transfer interactions are now synced and stored into conversations. So, a device can easily detects if a file was downloaded or not. If not, it can asks all members in the conversation to transmits the file again.
इसके लिए, डिवाइस एक mime प्रकार के साथ एक json भेजेगाः application/data-transfer-request+json
जिसमें conversation
(वार्ता की पहचान), interaction
(संबंधित बातचीत), deviceId
फ़ाइल प्राप्त करने वाला डिवाइस होता है।
प्रेषक अब जांचता है कि क्या डिवाइस घोषित सहकर्मी से एक डिवाइस है और क्या डिवाइस बातचीत का सदस्य है, और क्लासिक फ़ाइल स्थानांतरण के माध्यम से फ़ाइल भेज सकता है।
प्राप्तकर्ता अब पहले आने वाले हस्तांतरण को स्वीकार कर सकता है, फ़ाइल डाउनलोड कर सकता है और सत्यापित कर सकता है कि sha3sum सही है।
योजना

डीएचटी के माध्यम से एसडीपी भेजा
0d04b932
7c33834e7cf944bf0e367b47
H6e6ca682 1 TCP 2130706431 2607:fad8:4:6:9eb6:d0ff:dead:c0de 50693 typ host tcptype passive
H6e6ca682 1 TCP 2130706431 2607:fad8:4:6:9eb6:d0ff:dead:c0de 9 typ host tcptype active
H42c1b577 1 TCP 2130706431 fe80::9eb6:d0ff:fee7:1412 50693 typ host tcptype passive
H42c1b577 1 TCP 2130706431 fe80::9eb6:d0ff:fee7:1412 9 typ host tcptype active
Hc0a8007e 1 TCP 2130706431 192.168.0.123 42751 typ host tcptype passive
Hc0a8007e 1 TCP 2130706431 192.168.0.123 9 typ host tcptype active
Sc0a8007e 1 TCP 1694498815 X.X.X.X 42751 typ srflx tcptype passive
Z.Z.Z.Z:YYYY
A.A.A.A:YYYY
Where 0d04b932
is the ufrag and 7c33834e7cf944bf0e367b47
the password of the ICE session.
2130706431
and 1694498815
are the priority of the candidates.
192.168.0.126 42751 typ host tcptype passive
is a passive host candidate and 1694498815 X.X.X.X 42751 typ srflx tcptype passive
a passive host reflecting the public IP address (mapped via UPnP for example).
बहुविध उपकरण
A user can link its account to several devices. So, we need to implement the transfer when a user send a file to a contact who have multiple devices linked to this account.
पहला दृष्टिकोण
पहला तरीका DHT के माध्यम से सभी उपकरणों को अनुरोध भेजना था और पहले उत्तर देने वाले डिवाइस फ़ाइल को स्थानांतरित करने के लिए प्राप्त करते हैं। यह आपके संपर्क के लिए बुरा है क्योंकि वे नहीं जानते कि कौन सा डिवाइस प्राप्त करेगा स्थानांतरण प्राप्त करेगा।
वर्तमान दृष्टिकोण
अब, हम अभी भी सभी उपकरणों को एक अनुरोध भेजते हैं। अंतर यह है कि सभी उपकरणों में फ़ाइल प्राप्त करने के लिए सूचना होगी और स्थानांतरण को स्वीकार / अस्वीकार कर सकते हैं। इसके लिए कोड का मुख्य हिस्सा data_transfer.cpp में है।
Now (since https://review.jami.net/c/jami-daemon/+/9327), when a user send a file, it will request a PeerConnection with all peer devices. And for all connections, we attach a new input stream to have the ability to accept/refuse/cancel each transfer separately.
data_transfer.cpp में हम OptimisticMetaOutgoingInfo वर्ग को परिभाषित करते हैं जो क्लाइंट को दिखाने के लिए आशावादी दृश्य का प्रतिनिधित्व करते हैं। यह आशावादी है क्योंकि यदि कोई संपर्क एक डिवाइस पर एक स्थानांतरण स्वीकार करता है और दूसरों पर अस्वीकार करता है, तो यह वर्ग चल रहे फ़ाइल स्थानांतरण को दिखाएगा। और यह केवल त्रुटि दिखाएगा यदि सभी डिवाइस स्थानांतरण को अस्वीकार करते हैं।
यह वर्ग SubOutgoingFileTransfer से जुड़ा हुआ है जो एक डिवाइस के साथ स्थानांतरण की स्थिति का प्रतिनिधित्व करता है। ग्राहकों को बाद में एक उप स्थानांतरण दिखाने की क्षमता होगी (TODO सूची देखें) ।
एक और टर्न सर्वर का उपयोग करना
Actually the default TURN server is turn.jami.net. But you can host your own TURN server. For example by running a coTURN server.
`sudo turnserver -a -v -n -u उपयोगकर्ता: पासवर्ड -r "क्षेत्र"
Then, you can configure the TURN server in the advanced settings of the app.
टिप्पणी
This needs some technical knowledge. Moreover, the TURN server should see the same IP address of your node as the destination node, or the peer connection will fail (because the authorization will be incorrect).
TODO सूची
Use libtorrent?
आउटगोइंग फ़ाइलों के लिए उपप्रसारण स्थिति दिखाएँ