Prism-File-Explorer icon indicating copy to clipboard operation
Prism-File-Explorer copied to clipboard

Implement basic SMB 1.0, 2.0, 3.0+ Network navigation: connect to hosts, list shares, navigate folders, create folders and files

Open tiirwaa opened this issue 3 months ago • 18 comments

This PR adds initial support for SMB network drives. Users can now:

  • Discover SMB/Windows file-sharing devices on the local network using predefined SMB ports.
  • Connect to a host via SMB (with authentication or anonymously).
  • List available shares on the host.
  • Navigate inside shares and browse folders.
  • Create new folders and files within shares.
  • Reuse SMB sessions to improve performance and reduce connection overhead.

SMB Version Support:

  • Supported: SMB 1 (CIFS) through jcifs-ng
  • Supported: SMB 2.0, 2.1, 3.0, 3.02, 3.1.1 through SMBJ

Note: SMBJ and jcifs-ng automatically negotiates the highest supported SMB version between the client and server.

Additional Info:

The LAN discovery currently scans the network using known SMB ports (139, 445, 4450). This could be improved in future updates for more comprehensive network detection.

This is the foundation for full SMB integration; future updates will include file operations and improved error handling.

https://github.com/user-attachments/assets/f3b8ea3f-dafd-4ef1-aacb-bafd88b9930b

tiirwaa avatar Sep 06 '25 17:09 tiirwaa

Related to #39

tiirwaa avatar Sep 06 '25 18:09 tiirwaa

This is looking so promising! I wanted to test the feature but I couldn't connect to a server, I'm not sure how the port is determined, because there is no input field for it in the dialog, this might be the reason why I couldn't connect.

Regarding the integration in the home screen, to make it easier to implement other types of cloud storages and servers, I would suggest the following:

1- In the home screen, there should be a '+' icon button in the same row of the "Storage" label, and when clicked, a drop-down menu (or a dialog) shows with all types of storages to add (for now it will just show SMB, but in the future, there will be FTP, Local Storage, etc). amd from there the dialog of adding new SMB will show.

2- The added storages should show under "Storage" section, so I'd suggest removing the separate section for the SMB from home screen to make it cleaner.

3- the storages that are added should be saved (so that we don't need to rewrite all the credentials every time the app is opened), you can make a data class for SMB storage with all the required credentials (and other information like name, type, etc), and saved it as a set to the datastore in PreferencesManager. Then those will be retrieved and displayed in storage section as discussed in second point.

4- The design of the "add new SMB dialog" must follow the style of the other dialogs in the app. See "Jump to path" dialog for reference.

Regarding the SMB implementation, I'm not familiar with the libraries used, so I need to test the app and see if any further improvements required.

Huge thanks for your contribution, and I'm looking forward to test the app after fixing the bug regarding connecting to a server.

Raival-e avatar Sep 07 '25 06:09 Raival-e

[f739cfc](/Raival-e/Prism-File-Explorer/pull/213/commits/f739cfcbcf6fe34e1cdfcf9aaa4078fa111f2cc8)

Fixed the design of the 'Add New SMB' dialog to match the style of other dialogs. f739cfc

tiirwaa avatar Sep 07 '25 12:09 tiirwaa

Now when pressing "Show more", a field to enter the port is displayed.

sdsdfsdfsfsd

tiirwaa avatar Sep 07 '25 14:09 tiirwaa

I couldn't make it work, it keep showing this error message. What am I missing? I used Mixplorer to create the server, and I tested it using Amaze File Explorer.

Screenshot_20250907_195449_Prism File Explorer

Raival-e avatar Sep 07 '25 16:09 Raival-e

I couldn't make it work, it keep showing this error message. What am I missing? I used Mixplorer to create the server, and I tested it using Amaze File Explorer.

Possible cause: SMB 1.0

Mixplorer likely uses SMB 1.0 (CIFS) for its server feature, which is not supported by SMBJ. SMBJ supports only SMB 2.0, 2.1, 3.0, 3.02, and 3.1.1.

To properly test your setup, try sharing a folder using:

  • Samba on Linux (with SMB 2.0 or newer enabled), or

  • Windows file sharing, or

  • Any other server that supports SMB 2.0 or above.

tiirwaa avatar Sep 07 '25 17:09 tiirwaa

Mixplorer likely uses SMB 1.0

okay, that's probably why it didn't connect. I thought this is straightforward like FTP, I couldn't find an app that has SMB2 or higher. Anyways, I'll try from Windows.

Raival-e avatar Sep 07 '25 19:09 Raival-e

Initial support for SMB 1.0 added on commit 79ed7e6 using jcifs-ng. Added a dropdown in the SMB connection dialog to select the SMB version.

asdasdasdascd

tiirwaa avatar Sep 07 '25 21:09 tiirwaa

Thanks, it does connect now, however, using the same setup as before (using mixplorer to make the server), no files are shown, even though when opening the same server on MT Manager, for example, there are shared files.

Prism (no shared files shown): https://github.com/user-attachments/assets/9408bd70-4f82-4d64-8fbc-c6bbab812b92

MT Manager: https://github.com/user-attachments/assets/5f22790d-acf0-4a5c-b447-66eb0b85f77c

Raival-e avatar Sep 08 '25 10:09 Raival-e

I tested it on my phone with MiXplorer, and it works. However, I noticed that if I enter the wrong port, username, or password, the same thing you showed in the video happens — it doesn’t detect the error, but this only happens with SMB1. I’m going to check that. Still, I can list the shares, view the contents, and create folders and files correctly, both in SMB1 using JCIFS and in SMB2 (Windows and Linux) using SMBJ.

tiirwaa avatar Sep 08 '25 12:09 tiirwaa

I know for a fact that the username, password and port are correct. In my tests, the username and password are both 123 for test purposes. The port is 4450 (the default value Mixplorer sets). What should I put in the domain?

Raival-e avatar Sep 08 '25 12:09 Raival-e

I know for a fact that the username, password and port are correct. In my tests, the username and password are both 123 for test purposes. The port is 4450 (the default value Mixplorer sets). What should I put in the domain?

Please click on the "More" button and enter the port manually. The domain is optional. I have already fixed the issue that made SMB1 appear to authenticate correctly without listing the shares. I’ve tested it in Mixplorer and on Linux using SMB2. 539ede6

tiirwaa avatar Sep 08 '25 22:09 tiirwaa

I'm still getting the same error despite all credentials being correct (including the port). I'm busy rn, I will try to use Windows when I get a chance.

I also tested the anonymous connection, it did connect, but the one folder shown doesn't open (video below).

https://github.com/user-attachments/assets/7d643a01-b3cd-4084-b5ae-fc70a3fc44c7

Raival-e avatar Sep 09 '25 19:09 Raival-e

New LAN discovery feature! Scan your local network for SMB/Windows file-sharing devices and quickly connect to them. Currently, the scan uses predefined SMB ports, but this can be improved in the future.

https://github.com/user-attachments/assets/f3b8ea3f-dafd-4ef1-aacb-bafd88b9930b

tiirwaa avatar Sep 10 '25 22:09 tiirwaa

I'm really sorry for keeping this pull request hanging like this, but I couldn't make this SMB feature to work in my device, I'm not sure if it's my phone or the network, I need to investigate more. I've tested FTP in this app before and it was much straightforward than this. I obviously can't merge this pull request without properly testing it. I guess I'll keep this until I got enough time to look into the connection issue, no changes (at least major ones) will be made to the app, so you won't have to resolve any major conflicts.

Thanks.

Raival-e avatar Sep 19 '25 10:09 Raival-e

I’ve also been very busy with my work lately and didn’t have much time to work on the project these last few days. Please don’t make a pull request until the SMB feature is fully implemented (opening files, etc.).

I still have pending the following three things you requested in your previous comments:

  1. On the home screen, there should be a "+" icon button in the same row as the "Storage" label, and when clicked, a drop-down menu (or dialog) should show with all types of storages to add (for now it will just show SMB, but in the future there will be FTP, Local Storage, etc). From there, the dialog for adding a new SMB will show.
  1. The added storages should show under the "Storage" section, so I’d suggest removing the separate SMB section from the home screen to make it cleaner.
  1. The storages that are added should be saved (so that we don’t need to re-enter all the credentials every time the app is opened). You can create a data class for SMB storage with all the required credentials (and other information like name, type, etc.), and save it as a set to the datastore in PreferencesManager. Then those will be retrieved and displayed in the storage section as discussed in the second point.

Also, I still need to run more tests on my side to identify the issue that might be causing problems for you.

Thanks.

tiirwaa avatar Sep 19 '25 12:09 tiirwaa

@Raival-e Hey buddy, don't be too hard on yourself.

HanzoDev1375 avatar Oct 04 '25 10:10 HanzoDev1375

@Raival-e Hey buddy, don't be too hard on yourself.

There are a lot of file managers. His accuracy makes this app to point out.

Jds548 avatar Oct 04 '25 16:10 Jds548