Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to detect ssh and telnet port #313

Open
wants to merge 5 commits into
base: v3.x/staging
Choose a base branch
from

Conversation

Martin-Zeithaml
Copy link

@Martin-Zeithaml Martin-Zeithaml commented Aug 15, 2024

Proposed changes

Try to detect ssh and telnet port by looking into /etc/ssh/sshd_config and /etc/services. If such check fails, set the default port 22 and 23 (same as now).

This PR addresses Issue:

Type of change

  • New feature (non-breaking change which adds functionality)

PR Checklist

Please delete options that are not relevant.

  • If the changes in this PR are meant for the next release / mainline, this PR targets the "staging" branch.
  • My code follows the style guidelines of this project (see: Contributing guideline)
  • I have commented my code, particularly in hard-to-understand areas
  • Relevant update to CHANGELOG.md
  • My changes generate no new warnings

Testing

Small unit test

Test for checking if the logic works as expected:

Input='' -> SSH_PORT=22
Input=' ' -> SSH_PORT=22
Input='123 ' -> SSH_PORT=22
Input='0' -> SSH_PORT=22
Input='asdf' -> SSH_PORT=22
Input='99999' -> SSH_PORT=22
Input='file not found' -> SSH_PORT=22
Input='C:\' -> SSH_PORT=22
Input='1' -> SSH_PORT=1
Input='23' -> SSH_PORT=23
Input='144' -> SSH_PORT=144
Input='65535' -> SSH_PORT=65535

Running without variables

In the log:

ZWED_SSH_PORT=22
ZWED_TN3270_PORT=23

Running with preset ZWED_SSH_PORT

In the log:

ZWED_SSH_PORT=123
ZWED_TN3270_PORT=23

Further comments

I keep the setting in defaults.yaml. It should work without that, because those variables are exported. But in the future, there might be a way how to do it in JavaScript, keep it as reference.

Signed-off-by: Martin Zeithaml <[email protected]>
Signed-off-by: Martin Zeithaml <[email protected]>
@Martin-Zeithaml Martin-Zeithaml changed the base branch from v2.x/staging to v3.x/staging August 16, 2024 14:11
Signed-off-by: Martin Zeithaml <[email protected]>
Signed-off-by: Martin Zeithaml <[email protected]>
Signed-off-by: Martin Zeithaml <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Ready for Review
Development

Successfully merging this pull request may close these issues.

1 participant