Skip to content

Conversation

@logicog
Copy link
Owner

@logicog logicog commented Oct 31, 2025

This is some initial code for system settings and configuration management so that the concept can be discussed

With the current code the IP settings of the device can be changed with the new System tab and the initial idea for how to manage writing the configuration into Flash is started in code.

The idea for persisting the configuration to flash is as follows:

  • The System page downloads the current configuration file (config.txt) from the device flash as a plain file (code is there for the simulator)
  • The file is parsed into a configuration structure (partially implemented)
  • The current configuration according to the web-session, which is stored by all the tabs into a client-side JS SessionStore, is modified by the configuration structure, taking in particular account of removing obsolete or overwritten configurations, i.e.
    • mirrorr off overwrites a mirror config command and nothing is stored in persistent configuration because no mirror is the default state
  • The configuration structure is marshalled into a new configuration text-file, which gets uploaded (possibly after displaying it?) to the flash configuration area, reusing the code for the firmware image upload

This means, that when e.g. the VLAN is configured, the tab will create/update all the VLAN settings in the SessionStore client-side storage in addition to sending the relevant commands to the device. The session store will therefore reflect all the currently un-applied but active settings on the device which can be commonly edited by all setting tabs in the web-client. That structure is then persisted in the System tab after it is applied on top of the current configuration file of the device.

The SessionStore will store a JSON structure of the settings.
The SessionStore JSON will have the same format as the temporary parsed data from the current configuration file.
The JSON will be an ordered list/array of entries for a configuration that should make it easy to verify whether a new command/setting obsoletes or modifies a current one.

There is currently a hard limit of about 2.2kB on the size of a single file served by the device (e.g. a .js file). It should be possible to implement chunking of these files (not the dynamic ones, i.e. the .json!) in order to support more complex .js needed on the client side for the tabs.

This removes the limitation that a file served from FLASH memory
needs to be smaller than the TCP buffer size. Now we serve up to
the TCP buffer size in the first go and then remember what parts
still need to be sent. As soon as the previous package has been
acked, the next chunk of data is copied from flash into the
TCP transmit buffer and gets sent. We take care only to send
the current TCP window size so no further fragmentation needs to
happen, thus optimizing transmission of the remainder.
This adds a command history, both for the CLI as well as for
commands sent by the web-interface. They are written to a ring buffer
in order to work safely with a relatively small amount of RAM
The buffer is used to read the current in-RAM configuration
from the switch by the web-interface. It could also be used
to implement cmd history via cursor up/down in the CLI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants