Dateifügelübertragung

THIS PAGE IS DEPRECATED: READ File transfer

Wie soll ich es benutzen?

Android

Wenn Sie mit jemandem auf Android sprechen, haben Sie die Möglichkeit, ein Bild auf Ihrem Gerät zu senden oder ein Foto mit diesen Tasten zu machen:

Android_file_button

Bemerkung

When you send a file, the other has to accept it. At this moment you will see ‚awaiting peer‘:

Die Kommission hat die Kommission mit der Einführung eines neuen Systems zur Erreichung der Anwendungsmöglichkeiten für die Nutzung von Daten und Daten über die Nutzung von Daten und Daten.

Wie funktioniert das?

Wie funktioniert es?

Einführung

Jami ist eine verteilte Anwendung und muss ohne Internetverbindung funktionieren. Also auch Dateitransfer! Grundsätzlich verwenden wir dieselbe Methode, um Dateitransfer und Anrufe durchzuführen, aber in TCP. Um zusammenzufassen, wie es funktioniert, können wir uns eine Situation vorstellen, in der Alice (A) eine Datei an Bob (B) übertragen möchte.

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.

Jetzt, da der zweiseitige TCP-Link hier ist, wird der nächste Schritt darin bestehen, zwischen Alice und Bob ein TLS 1.3 (in der Regel ein (TLS1.3) - ((DHE-FFDHE8192) - ((RSA-PSS-RSAE-SHA384) - ((AES-256-GCM) zu verhandeln, wenn ich diese Zeilen schreibe)

Der erste Teil wird eine kleine Überschrift sein, die den Inhalt der Datei beschreibt.

Prozess

Eine Datei zu senden

Die folgende Methode wird angewendet:

  1. 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 are DataTransfer, IncomingFileTransfer, OutgoingFileTransfer and SubOutgoingFileTransfer). This method will ask the linked JamiAccount to request a connection. Diagram: DataTransfer class diagram

  2. 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 a ClientConnector (which manage the connection for one device) and launch the process() method.

  3. 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).

  4. 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 the PeerConnection object as an output and the transfer can start.

  5. When the TLS socket is ready, the callback DataTransferFacade::Impl::onConnectionRequestReply is called, and a OutgoingFileTransfer is linked to the PeerConnection as an input. This OutgoingFileTransfer contains a list of SubOutgoingFileTransfer (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).

  6. 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.

  7. 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 the DhtPeerConnector::eventLoop() and the resources will be released.

! TLSsocketEndpoint

Erhalt einer Datei

Die gleiche Struktur wird verwendet, um Dateien zu empfangen, aber die Methode ändert sich ein wenig:

  1. Die JamiAccount-Klasse wird verwendet, um Nachrichten vom DHT zu empfangen, da das erste, was empfangen wird, die DHT-Anfrage ist.

  2. Dann wird diese Nachricht an DhtPeerConnector: onRequestMessage() über den EventLoop übermittelt.

  3. Der DhtPeerConnector::Impl::answerToRequest wird versuchen, sich mit dem TURN-Server zu verbinden (wenn nicht verbunden) und den ICE-Transport zu initialisieren. Diese Methode öffnet 2 Steuerverbindungen zu einem TURN-Server (einer für die Berechtigung von IPv4-Pare, ein anderer für IPv6-Pare, aufgrund von RFC 6156) wenn es noch nicht geöffnet ist und Peer-öffentliche Adressen zur Verbindung erlaubt. Wenn dann die empfangene SDP keine ICE-Kandidaten enthält, wird die TURN verwendet und die SDP-Antwort erstellt, um auf den Peer zu warten. Wenn die SDP ICE-Kandidaten enthält, wird die Methode versuchen, den Link zu verhandeln (oder sich auf die TURN zurückzuziehen) und dann die SDP (mit ICE-Kandidaten oder nicht) zu beantworten.

  4. Sobald die Links wie der Absender fertig sind, wird ein TLS-Link ausgehandelt und der PeerConnection als Eingabe an die IncomingFileTransfer gegeben. Die Header der Datei kommen und der Kunde kann nun die Übertragung akzeptieren oder stornieren.

Wiederforderung einer vorherigen Dateiübertragung

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.

Dazu wird das Gerät einen json mit dem Mime-Typ: application/data-transfer-request+json senden, der conversation (die Konversations-ID), interaction (verwandte Interaktion) enthält, deviceId das Gerät, das die Datei empfängt.

Der Absender überprüft nun, ob das Gerät ein Gerät des angekündigten Peers ist und dass das Gerät ein Mitglied der Konversation ist, und kann die Datei über eine klassische Dateiübertragung senden.

Der Empfänger kann nun die erste eingehende Übertragung akzeptieren, die Datei herunterladen und überprüfen, ob die sha3sum korrekt ist.

Schema

Die Daten sind nicht mehr in der Lage, zu übertragen.

SDP über die DHT gesendet
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).

Mehrfachgeräte

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.

Erster Ansatz

Die erste Ansatz war, eine Anfrage über die DHT an alle Geräte zu senden und die ersten Geräte, die antworten, erhalten die Datei zu übertragen. Dies ist schlecht für Ihren Kontakt, weil sie nicht wissen, welches Gerät die Übertragung erhält.

Aktueller Ansatz

Wir schicken immer noch eine Anfrage an alle Geräte. Der Unterschied ist, dass alle Geräte die Benachrichtigung für den Erhalt einer Datei haben und die Übertragung akzeptieren/ablehnen können. Der größte Teil des Codes für das ist in 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.

In data_transfer.cpp definieren wir die OptimisticMetaOutgoingInfo Klasse, die die optimistische Ansicht darstellen, die dem Client angezeigt wird. Es ist optimistisch, weil wenn ein Kontakt eine Übertragung auf einem Gerät akzeptiert und auf anderen ablehnt, diese Klasse die laufende Dateiübertragung anzeigt. Und es zeigt nur einen Fehler an, wenn alle Geräte die Übertragung ablehnen.

Diese Klasse ist mit SubOutgoingFileTransfer verbunden, die den Zustand einer Übertragung mit einem Gerät darstellen.

Mit einem anderen TURN-Server

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 Benutzer: Passwort -r „Realm“

Then, you can configure the TURN server in the advanced settings of the app.

Bemerkung

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).

Liste der

  1. Use libtorrent?

  2. Anzeigen Sie den Status der Subtransfers für ausgehende Dateien