Skip to content

Add per-connection master address override for outstation clients#406

Merged
jadamcrain merged 11 commits into
mainfrom
feature/change-master-address
Nov 13, 2025
Merged

Add per-connection master address override for outstation clients#406
jadamcrain merged 11 commits into
mainfrom
feature/change-master-address

Conversation

@jadamcrain

Copy link
Copy Markdown
Member

Summary

  • Add ConnectionInfo::set_master_address() to allow outstations to use different master addresses
    per connection
  • Master address changes persist across reconnections until explicitly changed
  • Useful for failover scenarios where an outstation connects to different masters at different
    endpoints

Changes

  • Core API: Add set_master_address() to ConnectionInfo builder
    (dnp3/src/tcp/connector.rs:102-112)
  • FFI Bindings: Refactor connection handler to use ConnectionInfo builder pattern with master
    address support
  • Examples: Update C++ outstation example to demonstrate round-robin connections with per-endpoint
    master addresses
  • Code Quality: Replace manual Default implementations with #[derive(Default)] for decode/attr
    enums
  • Misc: Update .NET examples to target .NET 8.0

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @jadamcrain, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant enhancement for DNP3 outstation clients, allowing them to dynamically override the master address on a per-connection basis. This feature is crucial for robust failover mechanisms, enabling outstations to connect to different masters at various endpoints. The changes involve updates to the core API, FFI bindings, and example code to facilitate this new capability, alongside minor code quality improvements and .NET target updates.

Highlights

  • Per-Connection Master Address Override: Outstation clients can now specify a different master address for each connection attempt using ConnectionInfo::set_master_address().
  • Persistent Master Address Changes: Once set, the master address persists across reconnections until explicitly changed, supporting failover scenarios where an outstation connects to different masters at various endpoints.
  • FFI Bindings Refactor: The FFI bindings for connection handling have been updated to utilize a ConnectionInfo builder pattern, providing more granular control over connection parameters for C/C++ clients.
  • C++ Example Update: The C++ outstation example now demonstrates round-robin connections with per-endpoint master addresses, showcasing the new functionality.
  • Code Quality Improvement: Manual Default implementations for several enums (AttrSet, AppDecodeLevel, TransportDecodeLevel, LinkDecodeLevel, PhysDecodeLevel) have been replaced with #[derive(Default)] and #[default] attributes for cleaner and more concise code.
  • .NET Example Target Update: The .NET examples have been updated to target .NET 8.0.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a valuable feature for outstation clients, allowing per-connection master address overrides, which is particularly useful for failover scenarios. The implementation is well-structured, propagating the new master_address setting from the ConnectionInfo builder down to the outstation session. The refactoring of the FFI connection handler to a builder pattern is a significant improvement, making the API more extensible and idiomatic, although it introduces breaking changes for FFI consumers. The accompanying updates to examples, especially the C++ outstation example, clearly demonstrate the new functionality. The code quality improvements, such as using #[derive(Default)], are also welcome. I have one suggestion to improve the robustness of the session handling.

Comment thread dnp3/src/util/session.rs
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@jadamcrain jadamcrain merged commit 11ae614 into main Nov 13, 2025
30 checks passed
@jadamcrain jadamcrain deleted the feature/change-master-address branch November 13, 2025 20:07
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.

1 participant