<table><tr><td style="">jeanv updated this revision to Diff 16937.<br />jeanv edited the summary of this revision. <a href="https://phabricator.kde.org/transactions/detail/PHID-XACT-DREV-itggaevj4hhl6vl/" rel="noreferrer">(Show Details)</a><br />jeanv edited the test plan for this revision. <a href="https://phabricator.kde.org/transactions/detail/PHID-XACT-DREV-zd5qfwymb6i6nzc/" rel="noreferrer">(Show Details)</a><br />jeanv set the repository for this revision to R224 KDE Connect.<br />jeanv added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D6730" rel="noreferrer">View Revision</a></tr></table><br /><div><div><p>This seems to work for me. The correct IP address is stored and reused.</p>

<p>When a connection is started with a device, <tt style="background: #ebebeb; font-size: 13px;">LanDeviceLink::reset</tt> is called. In it we can get the IP address from the SslSocket and store it as a member in the parent class <tt style="background: #ebebeb; font-size: 13px;">DeviceLink</tt>. From there, the sftp plugin can get the device link from its <tt style="background: #ebebeb; font-size: 13px;">deviceId</tt> member then the address from this link.</p>

<p>Two things to note, and can perhaps be improved:</p>

<ul class="remarkup-list">
<li class="remarkup-list-item">mHostAddress is stored in <tt style="background: #ebebeb; font-size: 13px;">DeviceLink</tt> even though it should be a member of <tt style="background: #ebebeb; font-size: 13px;">LanDeviceLink</tt>. Unfortunately, the sftp plugin only has access to <tt style="background: #ebebeb; font-size: 13px;">DeviceLink</tt>, not its children.</li>
<li class="remarkup-list-item">I had to create a public accessor to get a <tt style="background: #ebebeb; font-size: 13px;">DeviceLink</tt> from its id.</li>
</ul></div></div><br /><div><strong>CHANGES TO REVISION SUMMARY</strong><div><div style="white-space: pre-wrap; color: #74777D;"><span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">When trying to remotely browse the device filesystem, if the device transmits all IP addresses (see https://phabricator.kde.org/D6757), in that case the desktop application needs to test and determine which one to use.<br />
<br />
We try to open a TCP connection on the addresses, one by one, using the transmitted port. When one succeeds, we break out of the loop and use this address to start sshfs</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">There is currently an issue where the device doesn't send the correct IP address for sshfs when a VPN is present</span>.<br />
<br />
<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">This revision can probably be refined</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">Instead of asking the device to find and send its address</span>, <span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">but I wanted to present</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">we can store it from when the device link is created</span> the<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);"> idea</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">n reuse it</span>.</div></div></div><br /><div><strong>CHANGES TO TEST PLAN</strong><div><div style="white-space: pre-wrap; color: #74777D;"><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">All unit tests pass.<br />
<br />
In these different situations:<br />
  - without a VPN<br />
  - with a VPN running<br />
  - with a VPN started then stopped (the tun interface might still be there)<br />
Try to remotely browse the device. It should work in all cases.<br />
<br />
<br />
</span></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R224 KDE Connect</div></div></div><br /><div><strong>CHANGES SINCE LAST UPDATE</strong><div><a href="https://phabricator.kde.org/D6730?vs=16903&id=16937" rel="noreferrer">https://phabricator.kde.org/D6730?vs=16903&id=16937</a></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D6730" rel="noreferrer">https://phabricator.kde.org/D6730</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>core/backends/devicelink.h<br />
core/backends/lan/landevicelink.cpp<br />
core/device.cpp<br />
core/device.h<br />
plugins/sftp/mounter.cpp</div></div></div><br /><div><strong>To: </strong>jeanv, KDE Connect<br /><strong>Cc: </strong>apol, nicolasfella, sredman, tfella, aboudhar, seebauer, progwolff, MayeulC, menasshock, ach, hkaelberer<br /></div>