Homebrew Homebrew app [Release] ftpsrv - A small ftp server

@TotalJustice

In the latest version, you added support for per-app and per-sys configuration options. I’d like to enable mount_devices in [Nx-App] but disable it in [Nx-Sys]. The configuration I tried (shown below) isn’t working. Could you please show me the correct way to set this up?

Code:
##########
# ftpsrv #
##########

[Login]
anon = 0
user = "User1"
pass = "Pass1"

[Network]
port = 5000

[Misc]
use_localtime = 14400

[Log]
log = 0

# options specific to Nintendo Switch
[Nx]
led = 1

# options specific to Nintendo Switch App
[Nx-App]
mount_devices = 1
save_writable = 1
mount_bis = 1
timeout = 0

# options specific to Nintendo Switch Sysmodule
[Nx-Sys]
mount_devices = 0
save_writable = 0
timeout = 20
Your [Nx] don't have it and I suppose that means =0. I am guessing that is the master swtich
 
@TotalJustice

In the latest version, you added support for per-app and per-sys configuration options. I’d like to enable mount_devices in [Nx-App] but disable it in [Nx-Sys]. The configuration I tried (shown below) isn’t working. Could you please show me the correct way to set this up?

Code:
##########
# ftpsrv #
##########

[Login]
anon = 0
user = "User1"
pass = "Pass1"

[Network]
port = 5000

[Misc]
use_localtime = 14400

[Log]
log = 0

# options specific to Nintendo Switch
[Nx]
led = 1

# options specific to Nintendo Switch App
[Nx-App]
mount_devices = 1
save_writable = 1
mount_bis = 1
timeout = 0

# options specific to Nintendo Switch Sysmodule
[Nx-Sys]
mount_devices = 0
save_writable = 0
timeout = 20
maybe you forgot to rename the file?
 
your [Nx] don't have it and I suppose that means =0

@TomSwitch and @TotalJustice,

I got your note saying that if [Nx] doesn’t have mount_devices, you assume it defaults to =0. However, my goal is to enable mount_devices in [Nx-App] and disable it in [Nx-Sys].

There are three sections to consider:
  1. [Nx-App] for Nintendo Switch App
  2. [Nx-Sys] for Nintendo Switch Sysmodule
  3. [Nx] for general Nintendo Switch settings
My questions are:
  1. What about [Nx]? Do I need to put all the settings there as well?
  2. Is [Nx] the same as [Nx-Sys] or [Nx-App]?
I’d appreciate any insight on how to correctly separate the settings and whether [Nx] needs additional options to make [Nx-App] and [Nx-Sys] work as intended. Thank you!
 
@TomSwitch and @TotalJustice,

I got your note saying that if [Nx] doesn’t have mount_devices, you assume it defaults to =0. However, my goal is to enable mount_devices in [Nx-App] and disable it in [Nx-Sys].

There are three sections to consider:
  1. [Nx-App] for Nintendo Switch App
  2. [Nx-Sys] for Nintendo Switch Sysmodule
  3. [Nx] for general Nintendo Switch settings
My questions are:
  1. What about [Nx]? Do I need to put all the settings there as well?
  2. Is [Nx] the same as [Nx-Sys] or [Nx-App]?
I’d appreciate any insight on how to correctly separate the settings and whether [Nx] needs additional options to make [Nx-App] and [Nx-Sys] work as intended. Thank you!
What is in [Nx] becomes the default for the other two when not present.
 
@TomSwitch and @TotalJustice,

I got your note saying that if [Nx] doesn’t have mount_devices, you assume it defaults to =0. However, my goal is to enable mount_devices in [Nx-App] and disable it in [Nx-Sys].

There are three sections to consider:
  1. [Nx-App] for Nintendo Switch App
  2. [Nx-Sys] for Nintendo Switch Sysmodule
  3. [Nx] for general Nintendo Switch settings
My questions are:
  1. What about [Nx]? Do I need to put all the settings there as well?
  2. Is [Nx] the same as [Nx-Sys] or [Nx-App]?
I’d appreciate any insight on how to correctly separate the settings and whether [Nx] needs additional options to make [Nx-App] and [Nx-Sys] work as intended. Thank you!
Did you miss my original reply?
 
That should work. Are you sure you're using the latest release? Have you restarted the sysmodule or restarted your switch?

The code for loading overrides is very simple, it loads the value here https://github.com/ITotalJustice/ft...c4912c4d003/src/platform/nx/main_sysmod.c#L44 and then loads the override here https://github.com/ITotalJustice/ft...c4912c4d003/src/platform/nx/main_sysmod.c#L58

Edit: why is the use_localtime set to 14400? It should be either 0 or 1 as it's a true or false value. You either either use local time or gmtime
I made the following changes to config.ini and I am using the latest release

Code:
##########
# ftpsrv #
##########


#######################################################################
# Rename config.ini.template to config.ini for changes to take effect.#
#######################################################################


[Login]
# disabled by default, do not enable if using ldn_mitm as
# it's a security risk - you have been warned!
anon = 0


# if anon is disabled, then user and pass must be set.
user = "User1"
pass = "Pass1"


[Network]
# port 21 is the default port for an ftp server, some platforms may not
# support using privileged ports, change if needed.
port = 5000


# timeout in seconds until a session is closed.
# if 0, then no timeout is set.
# it is recommended to set this to an actual value, eg 20.
timeout = 20


[Misc]
# use local time zone over gm (UTC) time zone.
use_localtime = 1


[Log]
# enables log output to /config/ftpsrv/log.txt
log = 0


# options specific to Nintendo Switch App
[Nx-App]
mount_devices = 1
save_writable = 1
mount_bis = 1
led = 1


# options specific to Nintendo Switch Sysmodule
[Nx-Sys]
mount_devices = 0
save_writable = 0
led = 1

However, the [Nx-Sys] settings still seem to take effect when I run the app, instead of using the [Nx-App] settings. Why is [Nx-App] not overriding [Nx-Sys]
 
@TotalJustice & @TomSwitch, Thanks both for the reply.

https://github.com/ITotalJustice/ft...c4912c4d003/src/platform/nx/main_sysmod.c#L44 https://github.com/ITotalJustice/ft...c4912c4d003/src/platform/nx/main_sysmod.c#L58

I’m not a developer, so I might have misunderstood something, but it looks like there’s no code to read [Nx-App]. As a result, the app always uses [Nx], then [Nx-Sys] overrides it. Since [Nx-Sys] is read unconditionally after [Nx], it always takes precedence.

Let me know if I’m missing anything. Thank you!
 
Last edited by AlM2023,
@TotalJustice, Thank for the reply.

https://github.com/ITotalJustice/ft...c4912c4d003/src/platform/nx/main_sysmod.c#L44 https://github.com/ITotalJustice/ft...c4912c4d003/src/platform/nx/main_sysmod.c#L58

I went through the source code and noticed there’s no code to read [Nx-App]. As a result, the app always uses [Nx], then [Nx-Sys] overrides it. It also seems that [Nx-Sys] is always taking precedence because it’s unconditionally read after [Nx]!
Well that's because I linked the sysmodule code. Yes nx-sys settings will override nx settings, it wouldn't make sense if it didn't.

The app version is here https://github.com/ITotalJustice/ft...e93f32c4912c4d003/src/platform/nx/main.c#L167.
 
I have a feeling that when you launch the app you're not actually connecting to the app but instead to the sysmodule. As both share the same port.

To use both simultaneously, you must either close the sysmodule first before launching the app or specify a port for each config.

You will know if you're connected to the app as it will log all connections to the screen.
 
I have a feeling that when you launch the app you're not actually connecting to the app but instead to the sysmodule. As both share the same port.

To use both simultaneously, you must either close the sysmodule first before launching the app or specify a port for each config.

You will know if you're connected to the app as it will log all connections to the screen.
You’re correct—thanks for the advice! I managed to get everything working with separate ports. Here’s my updated config file:

Code:
##########
# ftpsrv #
##########


#######################################################################
# Rename config.ini.template to config.ini for changes to take effect.#
#######################################################################


[Login]
# disabled by default, do not enable if using ldn_mitm as
# it's a security risk - you have been warned!
anon = 0


# if anon is disabled, then user and pass must be set.
user = "User1"
pass = "Pass1"


[Network]
# port 21 is the default port for an ftp server, some platforms may not
# support using privileged ports, change if needed.
port = 5000


# timeout in seconds until a session is closed.
# if 0, then no timeout is set.
# it is recommended to set this to an actual value, eg 20.
timeout = 0


[Misc]
# use local time zone over gm (UTC) time zone.
use_localtime = 0


[Log]
# enables log output to /config/ftpsrv/log.txt
log = 0


# options specific to Nintendo Switch
[Nx]
# enables showing all available mount points at root "/"
# for example, SdCard is as at "/sdmc:"
mount_devices = 0


# allows save data to be writable, needs mount_devices = 1
save_writable = 0


# allows for bis partitions to be mounted, needs mount_devices = 1
# WARNING: modifying bis files can soft brick your switch!
mount_bis = 0


# enables led on the controller to light flash
led = 0


# options specific to Nintendo Switch App
[Nx-App]
anon = 0
user = "User1"
pass = "Pass1"
port = 4000
timeout = 0
log = 0
use_localtime = 1
mount_devices = 1
save_writable = 1
mount_bis = 1
led = 1


# options specific to Nintendo Switch Sysmodule
[Nx-Sys]
anon = 0
user = "User1"
pass = "Pass1"
port = 5000
timeout = 0
log = 0
use_localtime = 1
mount_devices = 0
save_writable = 0
mount_bis = 0
led = 1

Now, the ftpsrv sysmodule [Nx-Sys] (accessible on port 5000) stays at the root without mounting anything. Once I run the ftpsrv app [Nx-App] (accessible on port 4000), it mounts everything and allows save data to be writable. The best part is that the sysmodule remains active while the ftpsrv app is running, so both work together seamlessly.
 
You’re correct—thanks for the advice! I managed to get everything working with separate ports. Here’s my updated config file:

Code:
##########
# ftpsrv #
##########


#######################################################################
# Rename config.ini.template to config.ini for changes to take effect.#
#######################################################################


[Login]
# disabled by default, do not enable if using ldn_mitm as
# it's a security risk - you have been warned!
anon = 0


# if anon is disabled, then user and pass must be set.
user = "User1"
pass = "Pass1"


[Network]
# port 21 is the default port for an ftp server, some platforms may not
# support using privileged ports, change if needed.
port = 5000


# timeout in seconds until a session is closed.
# if 0, then no timeout is set.
# it is recommended to set this to an actual value, eg 20.
timeout = 0


[Misc]
# use local time zone over gm (UTC) time zone.
use_localtime = 0


[Log]
# enables log output to /config/ftpsrv/log.txt
log = 0


# options specific to Nintendo Switch
[Nx]
# enables showing all available mount points at root "/"
# for example, SdCard is as at "/sdmc:"
mount_devices = 0


# allows save data to be writable, needs mount_devices = 1
save_writable = 0


# allows for bis partitions to be mounted, needs mount_devices = 1
# WARNING: modifying bis files can soft brick your switch!
mount_bis = 0


# enables led on the controller to light flash
led = 0


# options specific to Nintendo Switch App
[Nx-App]
anon = 0
user = "User1"
pass = "Pass1"
port = 4000
timeout = 0
log = 0
use_localtime = 1
mount_devices = 1
save_writable = 1
mount_bis = 1
led = 1


# options specific to Nintendo Switch Sysmodule
[Nx-Sys]
anon = 0
user = "User1"
pass = "Pass1"
port = 5000
timeout = 0
log = 0
use_localtime = 1
mount_devices = 0
save_writable = 0
mount_bis = 0
led = 1

Now, the ftpsrv sysmodule [Nx-Sys] (accessible on port 5000) stays at the root without mounting anything. Once I run the ftpsrv app [Nx-App] (accessible on port 4000), it mounts everything and allows save data to be writable. The best part is that the sysmodule remains active while the ftpsrv app is running, so both work together seamlessly.
Great! I should probably mention the separate ports thing somewhere, maybe in the config itself.
 
  • Like
Reactions: AlM2023
What a wonderful job, congratulations to the developer for the effort.
I would like to know which is the best FTP to use? application and sys-module.
Edit:
I placed the ftpsrv folder inside the config folder and when activating FTP on the sphaira it works fine with port 21.
Would this be the best 3rd method?
 
Last edited by johw,
  • Love
Reactions: impeeza
The config doesn’t work. I set the stuff (will change password after photo) but it refuses to acknowledge it
 

Attachments

  • IMG_0617.jpeg
    IMG_0617.jpeg
    3.6 MB · Views: 45

Site & Scene News

Popular threads in this forum