Comments (5)
Hi James,
I believe that using ports 139 / 445, even if it means running in privileged mode, is the most viable option to get started when using the library on those platforms with limited access to those ports.
If there is indeed a situation where you prefer using other ports (> 1023) and utilize port forwarding, it seems too specific and you should make your own changes to the code, it's not common enough for the library IMO.
from smblibrary.
Hi Tal,
Thanks for the thoughtful reply. I spent some more time looking at this today and realized that it's really only viable to do port forwarding for Direct TCP mode, since NetBIOS mode requires root permissions for packets sent from the server, which can't easily be forwarded.
The solution I ended up with was just to change DirectTCPPort from a const int to a virtual property. This allows inheriting from the SMBServer class and setting the port very easily, without adding any obfuscation. For what it's worth, I also looked at adding another method in my inherited class to start the server which listens on a different port, but all the fields on SMBServer are private, so that would have been a much more disruptive change.
I'll send a PR, in case you decide that a one line change is acceptable -- feel free to delete it if you like. I'm happy to fork the project if need be, but I'm not sure it's worth it for a one line diff, and this makes it much easier to work with on Unixy systems (eg: my IDE won't load when I launch it as root).
Thanks for such an awesome library! :)
from smblibrary.
Thanks James,
As the one who provide support for the library, I really want to avoid confusion about the SMB protocol.
I locked down the port selection in the first place because I saw too much evidence that programmers are not familiar with the capabilities and limitations of the SMB protocol (which are not easily understandable).
I do see the value in your change, it's practical and useful, but from an educational point of view it works against me.
It seems odd to me that your IDE won't load when launched as root, you should definitely send a PR to them :)
Seriously though, many programs require elevation to perform various functions, and IDEs (including MonoDevelop) generally can run and debug as superuser under Linux.
from smblibrary.
Starting in Linux 4.11 you can use sysfs (/proc/sys/net/ipv4/ip_unprivileged_port_start
) to override the privileged port range.
from smblibrary.
Hi James,
Thanks again for your valuable feedback, you can now use reflection to override the default port:
System.Reflection.FieldInfo directTCPPortFieldInfo = typeof(SMBLibrary.Server.SMBServer).GetField("DirectTCPPort");
directTCPPortFieldInfo.SetValue(null, 8445);
from smblibrary.
Related Issues (20)
- SMBServer.exe HOT 1
- NullReferenceExceptions in OnClientSocketReceive and unhandeled SocketExceptions in async process HOT 15
- how can I use SMB2 upload larger file in 'ResumeFromBreakPoint' mode? HOT 4
- Copying a file while having an STATUS_SHARING_VIOLATION HOT 1
- UnobservedTaskException after Client.Disconnect() HOT 5
- SMBServer.exe HOT 1
- IsLoggedIn Getter HOT 1
- Exception thrown by .net Framework. HOT 7
- How to Access a File With in the Sub Folders Using SMB2Client
- [Question] FileSystemWatcher-like support HOT 1
- tree connect returning null HOT 1
- SMB3 client on samba server HOT 4
- Unable to access file in subdirectory HOT 1
- SMB1Client Connect method not timing out HOT 4
- UnobservedTaskException's caused by Smb2Client.Disconnect method HOT 9
- NullReferenceException crashes the application HOT 3
- STATUS_LOGON_FAILURE HOT 12
- SMBLibrary may crash the entire process HOT 9
- Please make it possible to connect using SMBClients providing custom ports. HOT 3
- LargeMTU unavailable HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smblibrary.