Предавање датотека
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.
Сада када је двосјечна TCP веза овде, следећи корак ће бити да се преговара TLS 1.3 (обично (TLS1.3)-(DHE-FFDHE8192)-(RSA-PSS-RSAE-SHA384)-(AES-256-GCM) када пишем ове реке) између Алисе и Боба, онда ће Алис почети да преноси датоте.
Први део ће бити мали наслов који ће описати садржај датотеке.
Процес
Slanje datoteke
Употребљена је следећа метода:
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
се користи за примање порука од ДХТ-а, јер ће прво нешто добити бити захтев за ДХТ.Затим се ова порука даје
ДhtPeerConnector: onRequestMessage()
кроз eventLoop.ДhtPeerConnector::Impl::answerToRequest
ће покушати да се повеже са TURN сервером (ако није повезан) и инициализира ICE транспорт. Овај метод ће отворити 2 контролне везе са TURN сервером (једно за овлашћење IPv4 вршњака, друго за IPv6 вршњака, због RFC 6156) ако то још није отворено и дозвољава јавно адресе вршњака да се повеже.Kada su veze spremne, kao i pošiljalac, TLS veza se dogovara i daje
PeerConnection
datojIncomingFileTransfer
kao ulaz. Zaglavlja datoteke će doći i klijent je sada u mogućnosti da prihvati ili otkaže transfer.
Поново затражите превод датотеке
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.
За то ће уређај послати json са типам: апликација/пратење преноса података+json
са конверсија
(идентификатор разговора), интеракција
(поврзана интеракција), устройствоId
уређај који прима датотеку.
Излатар сада проверава да ли је уређај уређај од најављеног вршњака и да је уређај члан разговора, и може да пошаље датотеку преко класичног преноса датотека.
Пријемник сада може прихватити први долазак пренос, преузети датотеку и проверити да је sha3sum правилан.
Схема
[Диаграма: главни дијаграм](изображения/файло-предај-главни дијаграм-диаграма.png)
СДП је послао преко ДХТ-а
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).
Уреди за вишеструку употребу
Korisnik može povezati svoj nalog sa nekoliko uređaja. Dakle, moramo da primenimo prenos kada korisnik pošalje datoteku kontaktu koji ima više uređaja povezanih sa ovim nalogom.
Први приступ
Prvi pristup je bio slanje zahteva preko DHT-a na sve uređaje i prvi uređaji koji odgovore dobijaju fajl za prenos. Ovo je loše za vaš kontakt jer neće znati koji uređaj će primiti i dobiti transfer.
Актуелни приступ
Сада, још увек пратимо захтев на све уређаје. Разлика је у томе што ће сви уређаји имати обавештење за пријем датотеке и могу прихватити / одбити пренос.
Sada (pošto https://review.jami.net/c/jami-daemon/+/9327), kada korisnik pošalje datoteku, on će zahtevati PeerConnection sa svim ravnopravnim uređajima. I za sve veze, prilažemo novi ulazni tok da bismo imali mogućnost da prihvatimo/odbijemo/otkažemo svaki transfer posebno.
U data_transfer.cpp definišemo klasu OptimisticMetaOutgoingInfo koja predstavlja optimističan pogled koji se prikazuje klijentu. Optimistično je jer ako kontakt prihvati prenos na jednom uređaju, a odbije na drugom, ova klasa će pokazati tekući prenos datoteka. I prikazaće grešku samo ako svi uređaji odbiju prenos.
Ова класа је повезана са SubOutgoingFileTransfer који представљају стање преноса са једном уређајем. Клијенти ће имати могућност да прикажу суб-трансфер уместо оптимистичне касније (види ТОДО листу).
Користећи други ТУРН сервер
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).
Списак СТОД
Use libtorrent?
Покажите статус субтрансфера за исходяће датотеке