Skip to content

doc: document unified Config design, override flow, and lifecycle#433

Draft
kp-antonio-yang wants to merge 3 commits into
mainfrom
doc/client-config
Draft

doc: document unified Config design, override flow, and lifecycle#433
kp-antonio-yang wants to merge 3 commits into
mainfrom
doc/client-config

Conversation

@kp-antonio-yang

@kp-antonio-yang kp-antonio-yang commented May 21, 2026

Copy link
Copy Markdown
Contributor

Description

  • Fix Config validation after consuming and move validation ahead (The validation is documented, and we do not need to force user called in try_from_reload_sig_and_config)
  • Document Config struct design rationale for client and server
  • Document the layered config override flow (default → file → env → CLI)
  • Document JSON schema generation and cross-platform personas
  • Document Config lifecycle methods: take_servers(), validate(), try_from_reload_sig_and_config()
  • Cross-reference new doc from lightway-client/src/config.rs and lightway-server/src/config.rs

Motivation and Context

The client Config struct serves multiple targets (desktop, mobile, Windows, Linux, macOS) and several distinct user personas (native developers, cross-platform developers, frontend/designers). Without documentation, the design are not easy to know.

This PR documents the work from #386, #388, #411, #420, and #451.

Easy to read on GitHub.

How Has This Been Tested?

Most documentation only and follow current test

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • The correct base branch is being used, if not main

@github-actions

github-actions Bot commented May 21, 2026

Copy link
Copy Markdown

Code coverage summary for 72b8395:

Filename                                                          Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lightway-app-utils/src/args/cipher.rs                                   5                 5     0.00%           1                 1     0.00%           5                 5     0.00%           0                 0         -
lightway-app-utils/src/args/connection_type.rs                         11                 5    54.55%           3                 1    66.67%          11                 5    54.55%           0                 0         -
lightway-app-utils/src/args/duration.rs                               121                22    81.82%          11                 5    54.55%          64                15    76.56%           0                 0         -
lightway-app-utils/src/args/ip_map.rs                                  27                27     0.00%           5                 5     0.00%          19                19     0.00%           0                 0         -
lightway-app-utils/src/args/keyshare.rs                                 5                 5     0.00%           1                 1     0.00%           5                 5     0.00%           0                 0         -
lightway-app-utils/src/args/logging.rs                                 37                37     0.00%           3                 3     0.00%          31                31     0.00%           0                 0         -
lightway-app-utils/src/args/nonzero_duration.rs                       128                24    81.25%          10                 4    60.00%          68                16    76.47%           0                 0         -
lightway-app-utils/src/connection_ticker.rs                           229                17    92.58%          28                 4    85.71%         126                15    88.10%           0                 0         -
lightway-app-utils/src/dplpmtud_timer.rs                              209                13    93.78%          22                 4    81.82%         117                11    90.60%           0                 0         -
lightway-app-utils/src/event_stream.rs                                 19                 0   100.00%           3                 0   100.00%          11                 0   100.00%           0                 0         -
lightway-app-utils/src/metrics.rs                                       4                 4     0.00%           2                 2     0.00%           4                 4     0.00%           0                 0         -
lightway-app-utils/src/network_change_monitor.rs                      158                72    54.43%          13                 6    53.85%          93                49    47.31%           0                 0         -
lightway-app-utils/src/packet_codec.rs                                  2                 2     0.00%           1                 1     0.00%           1                 1     0.00%           0                 0         -
lightway-app-utils/src/sockopt/ip_mtu_discover.rs                      81                81     0.00%           6                 6     0.00%          72                72     0.00%           0                 0         -
lightway-app-utils/src/sockopt/ip_pktinfo.rs                           14                 1    92.86%           1                 0   100.00%          16                 1    93.75%           0                 0         -
lightway-app-utils/src/tun.rs                                         409               409     0.00%          42                42     0.00%         260               260     0.00%           0                 0         -
lightway-app-utils/src/utils.rs                                        21                21     0.00%           1                 1     0.00%          11                11     0.00%           0                 0         -
lightway-client/src/config.rs                                         397               105    73.55%          20                 8    60.00%         266                67    74.81%           0                 0         -
lightway-client/src/dns_manager.rs                                     18                18     0.00%           4                 4     0.00%          16                16     0.00%           0                 0         -
lightway-client/src/io/inside/tun.rs                                   82                82     0.00%          12                12     0.00%          60                60     0.00%           0                 0         -
lightway-client/src/io/outside.rs                                      14                14     0.00%           2                 2     0.00%          12                12     0.00%           0                 0         -
lightway-client/src/io/outside/tcp.rs                                 106               106     0.00%          15                15     0.00%          67                67     0.00%           0                 0         -
lightway-client/src/io/outside/udp.rs                                 184               184     0.00%          20                20     0.00%         119               119     0.00%           0                 0         -
lightway-client/src/io/outside/udp/batch_receive.rs                    99                13    86.87%          11                 1    90.91%          84                13    84.52%           0                 0         -
lightway-client/src/keepalive.rs                                      615                44    92.85%          55                 6    89.09%         330                25    92.42%           0                 0         -
lightway-client/src/lib.rs                                           1364               788    42.23%         107                58    45.79%         946               600    36.58%           0                 0         -
lightway-client/src/main.rs                                           280               280     0.00%          17                17     0.00%         158               158     0.00%           0                 0         -
lightway-client/src/platform/linux/dns_manager.rs                     118                91    22.88%          14                 9    35.71%          87                62    28.74%           0                 0         -
lightway-client/src/platform/linux/dns_manager/direct_file.rs         106                42    60.38%          12                 6    50.00%          65                29    55.38%           0                 0         -
lightway-client/src/platform/linux/dns_manager/resolvconf.rs           61                61     0.00%           8                 8     0.00%          52                52     0.00%           0                 0         -
lightway-client/src/platform/linux/dns_manager/resolvectl.rs           41                41     0.00%           5                 5     0.00%          34                34     0.00%           0                 0         -
lightway-client/src/route_manager.rs                                 1148               166    85.54%          75                 6    92.00%         636                84    86.79%           0                 0         -
lightway-core/src/borrowed_bytesmut.rs                                373                 0   100.00%          24                 0   100.00%         185                 0   100.00%           0                 0         -
lightway-core/src/builder_predicates.rs                                24                12    50.00%           4                 2    50.00%          24                12    50.00%           0                 0         -
lightway-core/src/cipher.rs                                            13                 0   100.00%           2                 0   100.00%          10                 0   100.00%           0                 0         -
lightway-core/src/connection.rs                                      1823               969    46.85%          74                29    60.81%        1295               662    48.88%           0                 0         -
lightway-core/src/connection/builders.rs                              252                46    81.75%          22                 8    63.64%         260                53    79.62%           0                 0         -
lightway-core/src/connection/dplpmtud.rs                             1741                81    95.35%          63                 0   100.00%         830                 7    99.16%           0                 0         -
lightway-core/src/connection/expresslane.rs                            27                11    59.26%           4                 1    75.00%          36                 7    80.56%           0                 0         -
lightway-core/src/connection/fragment_map.rs                          366                 6    98.36%          25                 0   100.00%         254                 3    98.82%           0                 0         -
lightway-core/src/connection/io_adapter.rs                            877               149    83.01%          55                 8    85.45%         467                95    79.66%           0                 0         -
lightway-core/src/connection/key_update.rs                             34                13    61.76%           5                 0   100.00%          38                19    50.00%           0                 0         -
lightway-core/src/context.rs                                          214                51    76.17%          28                11    60.71%         235                64    72.77%           0                 0         -
lightway-core/src/context/ip_pool.rs                                    8                 3    62.50%           1                 0   100.00%           5                 0   100.00%           0                 0         -
lightway-core/src/context/server_auth.rs                               37                37     0.00%           4                 4     0.00%          26                26     0.00%           0                 0         -
lightway-core/src/encoding_request_states.rs                            3                 0   100.00%           1                 0   100.00%           3                 0   100.00%           0                 0         -
lightway-core/src/gso.rs                                              900               143    84.11%          29                 6    79.31%         424                92    78.30%           0                 0         -
lightway-core/src/io.rs                                                10                10     0.00%           3                 3     0.00%           9                 9     0.00%           0                 0         -
lightway-core/src/keyshare.rs                                           5                 0   100.00%           1                 0   100.00%           5                 0   100.00%           0                 0         -
lightway-core/src/lib.rs                                                9                 0   100.00%           3                 0   100.00%           9                 0   100.00%           0                 0         -
lightway-core/src/metrics.rs                                           81                71    12.35%          33                29    12.12%          73                63    13.70%           0                 0         -
lightway-core/src/packet.rs                                            38                10    73.68%           4                 1    75.00%          30                 6    80.00%           0                 0         -
lightway-core/src/plugin.rs                                           307                17    94.46%          22                 4    81.82%         148                10    93.24%           0                 0         -
lightway-core/src/tls/mod.rs                                            4                 4     0.00%           1                 1     0.00%           3                 3     0.00%           0                 0         -
lightway-core/src/utils.rs                                            341                28    91.79%          24                 3    87.50%         170                18    89.41%           0                 0         -
lightway-core/src/version.rs                                           93                 0   100.00%          17                 0   100.00%          82                 0   100.00%           0                 0         -
lightway-core/src/wire.rs                                             438                42    90.41%          29                 1    96.55%         235                12    94.89%           0                 0         -
lightway-core/src/wire/auth_failure.rs                                 27                 1    96.30%           3                 0   100.00%          17                 0   100.00%           0                 0         -
lightway-core/src/wire/auth_request.rs                                684                57    91.67%          34                 1    97.06%         351                24    93.16%           0                 0         -
lightway-core/src/wire/auth_success_with_config_ipv4.rs               222                 3    98.65%          11                 0   100.00%         124                 0   100.00%           0                 0         -
lightway-core/src/wire/data.rs                                         51                 1    98.04%           5                 0   100.00%          33                 0   100.00%           0                 0         -
lightway-core/src/wire/data_frag.rs                                   127                 1    99.21%          14                 0   100.00%          80                 0   100.00%           0                 0         -
lightway-core/src/wire/encoding_request.rs                             82                 2    97.56%           6                 0   100.00%          42                 1    97.62%           0                 0         -
lightway-core/src/wire/encoding_response.rs                            82                 2    97.56%           6                 0   100.00%          42                 1    97.62%           0                 0         -
lightway-core/src/wire/expresslane_config.rs                          192                 1    99.48%          10                 0   100.00%         110                 0   100.00%           0                 0         -
lightway-core/src/wire/expresslane_data.rs                           1332                70    94.74%          48                 5    89.58%         681                38    94.42%           0                 0         -
lightway-core/src/wire/ping.rs                                         95                 2    97.89%           7                 0   100.00%          59                 0   100.00%           0                 0         -
lightway-core/src/wire/pong.rs                                        109                 2    98.17%           8                 0   100.00%          72                 0   100.00%           0                 0         -
lightway-core/src/wire/server_config.rs                                69                 2    97.10%           4                 0   100.00%          37                 0   100.00%           0                 0         -
lightway-server/src/auth.rs                                           273                49    82.05%          22                 6    72.73%         171                28    83.63%           0                 0         -
lightway-server/src/config.rs                                          85                 0   100.00%           7                 0   100.00%          88                 0   100.00%           0                 0         -
lightway-server/src/connection.rs                                     137               137     0.00%          11                11     0.00%         110               110     0.00%           0                 0         -
lightway-server/src/connection_manager.rs                             339               339     0.00%          40                40     0.00%         294               294     0.00%           0                 0         -
lightway-server/src/connection_manager/connection_map.rs              407                16    96.07%          21                 1    95.24%         228                 7    96.93%           0                 0         -
lightway-server/src/io/inside.rs                                       97                18    81.44%          22                 8    63.64%          66                16    75.76%           0                 0         -
lightway-server/src/io/inside/tun.rs                                   57                57     0.00%          13                13     0.00%          42                42     0.00%           0                 0         -
lightway-server/src/io/outside/tcp.rs                                  93                93     0.00%          10                10     0.00%          68                68     0.00%           0                 0         -
lightway-server/src/io/outside/udp.rs                                 484               429    11.36%          27                24    11.11%         329               295    10.33%           0                 0         -
lightway-server/src/io/outside/udp/batch_receive.rs                   467                19    95.93%          20                 1    95.00%         265                15    94.34%           0                 0         -
lightway-server/src/io/outside/udp/cmsg.rs                            211                48    77.25%          17                 3    82.35%         174                43    75.29%           0                 0         -
lightway-server/src/io/outside/udp/send_queue.rs                      381                26    93.18%          24                 1    95.83%         209                16    92.34%           0                 0         -
lightway-server/src/ip_manager.rs                                     542                50    90.77%          22                 4    81.82%         242                23    90.50%           0                 0         -
lightway-server/src/ip_manager/ip_pool.rs                             545                 0   100.00%          28                 0   100.00%         257                 0   100.00%           0                 0         -
lightway-server/src/lib.rs                                            594               490    17.51%          34                26    23.53%         406               333    17.98%           0                 0         -
lightway-server/src/main.rs                                           201               201     0.00%          10                10     0.00%          96                96     0.00%           0                 0         -
lightway-server/src/metrics.rs                                        277               255     7.94%          95                85    10.53%         235               215     8.51%           0                 0         -
lightway-server/src/statistics.rs                                     132                59    55.30%           8                 4    50.00%          90                39    56.67%           0                 0         -
uniffi-bindgen/src/uniffi-bindgen.rs                                    3                 3     0.00%           1                 1     0.00%           3                 3     0.00%           0                 0         -
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                               22528              6916    69.30%        1596               628    60.65%       13723              4786    65.12%           0                 0         -

✅ Region coverage 69% passes
✅ Line coverage 65% passes

@kp-antonio-yang
kp-antonio-yang force-pushed the doc/client-config branch 4 times, most recently from e3bbe81 to 4368088 Compare May 21, 2026 11:29
@kp-antonio-yang
kp-antonio-yang marked this pull request as ready for review May 21, 2026 11:31
@kp-antonio-yang
kp-antonio-yang requested a review from a team as a code owner May 21, 2026 11:31
@kp-antonio-yang
kp-antonio-yang force-pushed the doc/client-config branch 2 times, most recently from d92647c to 8cdd62f Compare May 22, 2026 06:20

@kp-samuel-tam kp-samuel-tam left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's a great write-up overall, the flow chart captures the layering really well. I would like to raise a few blockers.

Comment thread docs/design_overview.md Outdated
Comment thread docs/design_overview.md Outdated
6 ==> clientFn
```

As shown, `Config` is the single source of truth for all clients — all user inputs, whether from a UI or a file,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

From this line onwards there's a clear disjoint between the convention you're documenting and how Config actually ships today. Looking at the merged PR #411:

  • wintun_file, enable_dpapi#[cfg(windows)] (target gate on field)
  • route_mode, dns_config_mode, enable_pmtud, enable_tun_iouring, enable_inside_pkt_encoding#[cfg(desktop)] (custom cfg on field)
  • enable_batch_receive#[cfg(batch_receive)] (custom cfg on field)

The doc says "feature gates belong on fields" but there's 8+ fields in the prior PR being documented use target/custom cfg on fields.

Even if we're aligned on the direction, the code needs to follow the rule before we declare it a developer practice in the docs.

@kp-antonio-yang kp-antonio-yang May 25, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeh, not all the code following the design and only mobile does.

The reason it when we use json schema on windows/macos client and we will refactor it to follow this design. For now, we do the least change on the code when mobile introduce. And it will make really sense when developer working on that target and test it at the same time, so we do not touch these target now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The lingering concerns are a signal that the documentation itself isn't clear enough. Ideally, after reading your doc, people should walk away feeling that what you're proposing makes sense.

The current document covers the what in depth, but doesn't really address the why. This is especially important in your case because you're deviating from the standard, which naturally raises concerns. Addressing those concerns head-on is exactly what this change needs to do, and it's also why I suggested writing this up in the first place.

In a technical context, explaining the why well means laying out your motivation, the technical constraints you're working within, and how this design directly addresses those challenges. I'd suggest following this exact structure in your doc for clarity.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, the why is the important and making focus.

A introduction is added, and also the using scenario put more details about why the scope is boarder than before. This issue should not be a problem.

Comment thread docs/design_overview.md Outdated
Comment on lines +98 to +122
fn main () {
let config = Config::load();
client(config)
}

#[cfg(window)]
fn client(config: Config) {
let Config {
win_only_field,
..
} = config;

if win_only_filed > 256 {
// ...
}
}

#[cfg(android)]
fn client(config: Config) {
let Config {
android_only_field,
..
} = config;
let tun = Tun::new(android_only_field);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like this pseudocode was copy-pasted from #411 (comment) with typos - #[cfg(window)] is missing the s, and win_only_filed should be win_only_field.

Also, this code actively encourages the paired use of #[cfg(windows)] and #[cfg(feature="windows")]. This is unsound because we can't ever guarantee they are in sync or supported, adding to the drift Thomas was trying to talk about.

@kp-antonio-yang kp-antonio-yang May 25, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It will always need to enable the corresponding feature gate for targets with this design, like current mobile feature.

Also, we can make sure it always sync and supported via cargo make, and also that is the reason we have script or make file in the project.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about we make this less controversial by only applying this rule on mobile for now? i.e.:

  • Mobile -> use #[cfg(feature="mobile")] to allow schema generation on desktop
  • Desktop -> follow Rust's default convention

As you noted in the doc, desktop won't adopt this convention until the larger refactor lands. Any new desktop config added before then would deviate from the proposal anyway, which somewhat undercuts its value if we roll it out broadly now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The intent was never to lay down strict rules — it started as a brief three-line comment to guide developers when they need to revisit the JSON schema. As it evolved into a document, it made more sense to capture not just the current state but also the details we will likely encounter going forward, especially since the discussion is already open. Current document put introduction and easier for reader to have the focus.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The intent was never to lay down strict rules

No, by writing down what people should do, you are setting rules, no matter what you call it.

If you want to keep your vision for the desktop config, you may put it in a section labeled "Future Plans", but it must be distinctive that it's not meant to be followed.

Comment thread docs/design_overview.md Outdated
Comment thread docs/design_overview.md Outdated
Comment thread docs/design_overview.md Outdated
@kp-antonio-yang
kp-antonio-yang marked this pull request as draft May 25, 2026 01:43
@kp-antonio-yang
kp-antonio-yang force-pushed the doc/client-config branch 4 times, most recently from 57667a2 to 5ce523f Compare May 25, 2026 03:45
@kp-antonio-yang

Copy link
Copy Markdown
Contributor Author

Hi @kp-samuel-tam
The docs is move to a split one general_config.md, and also an general introduction of this topic is added with two possible option as open question, such that we are not enforce to use #[cfg(feature = ...)] at this moment and keep it open. May you review again with your suggestion on these? Thank you. 🙏

@kp-antonio-yang
kp-antonio-yang marked this pull request as ready for review May 25, 2026 05:20
Comment thread docs/general_config.md Outdated
## Use cases by developer persona

The general config centralizes all settings into a single `Config` struct and aligns the config generation flow across clients. However, only the mobile feature has been implemented with this design so far — existing clients may not adopt it until a larger refactor happens.
There are two possible directions going forward:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you clarify when to use each direction?

It's not clear what the differences are or which scenarios call for which approach. If they're effectively the same, let's pick one as the standard going forward.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If we can reach a decision on Option 1, I can drop the redundant documentation and keep things lean. Once that lands, a follow-up PR can enforce the same design across the desktop clients.

Personally, I lean towards Option 1 with feature gates. Since we are already using Makefile.toml, passing --features is not an extra burden — it is a common pattern in our build flow for each target. However, since there seems to be resistance towards --feature=target, so I am leaving this as an open question for now.

Comment thread docs/general_config.md Outdated
@@ -0,0 +1,144 @@
# General Config

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggesting a more concise title:

Suggested change
# General Config
# Client Config Design Rationale

Can you also link this doc in lightway-client/src/config.rs, such that people are aware that there is a relevant doc here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is General Config.

I should doc the server part, although it is really similar with cli part of the client.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Then I would suggest Client/Server Config Design Rationale. The word "General" doesn't really mean anything.

I see you've extended the diagram to include server as well, but that has become a bit messy. Can you separate it into its own flow chart?

Comment thread docs/design_overview.md Outdated
6 ==> clientFn
```

As shown, `Config` is the single source of truth for all clients — all user inputs, whether from a UI or a file,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The lingering concerns are a signal that the documentation itself isn't clear enough. Ideally, after reading your doc, people should walk away feeling that what you're proposing makes sense.

The current document covers the what in depth, but doesn't really address the why. This is especially important in your case because you're deviating from the standard, which naturally raises concerns. Addressing those concerns head-on is exactly what this change needs to do, and it's also why I suggested writing this up in the first place.

In a technical context, explaining the why well means laying out your motivation, the technical constraints you're working within, and how this design directly addresses those challenges. I'd suggest following this exact structure in your doc for clarity.

Comment thread docs/general_config.md
Comment thread docs/design_overview.md Outdated
Comment on lines +98 to +122
fn main () {
let config = Config::load();
client(config)
}

#[cfg(window)]
fn client(config: Config) {
let Config {
win_only_field,
..
} = config;

if win_only_filed > 256 {
// ...
}
}

#[cfg(android)]
fn client(config: Config) {
let Config {
android_only_field,
..
} = config;
let tun = Tun::new(android_only_field);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about we make this less controversial by only applying this rule on mobile for now? i.e.:

  • Mobile -> use #[cfg(feature="mobile")] to allow schema generation on desktop
  • Desktop -> follow Rust's default convention

As you noted in the doc, desktop won't adopt this convention until the larger refactor lands. Any new desktop config added before then would deviate from the proposal anyway, which somewhat undercuts its value if we roll it out broadly now.

@kp-antonio-yang
kp-antonio-yang marked this pull request as draft May 28, 2026 02:20
@kp-antonio-yang
kp-antonio-yang force-pushed the doc/client-config branch 5 times, most recently from 6d460c2 to dddfeec Compare May 28, 2026 06:57
@kp-antonio-yang

Copy link
Copy Markdown
Contributor Author

Hi @xv-thomas-leong

Please take a look at the updated doc when you get a chance. 🙏
Here is a summary of the major changes since the last review:

  • Added server-side description.
  • Added doc links in the source code.
  • Explained the reasoning behind the broader persona scope and called it out explicitly.

On the options section — if we would rather not leave it open-ended in the doc, I am happy to implement either Option 1 or Option 2 in a follow-up PR. But we need to reach consensus here first before I proceed.

@kp-antonio-yang
kp-antonio-yang marked this pull request as ready for review May 28, 2026 07:31
@kp-antonio-yang
kp-antonio-yang force-pushed the doc/client-config branch 2 times, most recently from 7f719d8 to 72f5f31 Compare May 29, 2026 05:39
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.

@github-actions github-actions Bot added the stale label Jul 5, 2026
@kp-antonio-yang
kp-antonio-yang marked this pull request as draft July 8, 2026 03:13
@kp-antonio-yang

Copy link
Copy Markdown
Contributor Author

Will update docs with #457 and #451, because these are also related to the Config.

@kp-antonio-yang
kp-antonio-yang force-pushed the doc/client-config branch 8 times, most recently from 7350c2b to 400e4f5 Compare July 15, 2026 06:55
@kp-antonio-yang kp-antonio-yang changed the title doc: add clients config setup flow doc: document unified Config design, override flow, and lifecycle Jul 21, 2026
Previously, `config.validate()` was called inside the constructor
before CLI and environment patches were applied, meaning validation ran
on a partially-configured state and could reject a valid final config
or pass on one that becomes invalid after patching.

Move the validation call to after all patches are applied in `main.rs`
and `mobile.rs`, so the check reflects the actual configuration that
will be used.
@kp-antonio-yang
kp-antonio-yang force-pushed the doc/client-config branch 2 times, most recently from 5599572 to c0da437 Compare July 21, 2026 03:10
@kp-antonio-yang
kp-antonio-yang marked this pull request as ready for review July 21, 2026 03:51
- documents with flow about config changes in cli, mobile
- add mermaid chart for the flow
- add how to apply the flow when introducing a new client
Add a "Config Lifecycle Methods" subsection covering the three methods
that bridge a fully determined Config (step 6) into the client runtime,
in call-site order:

- validate(): checks the resolved Config for conflicts and invalid
  values — warns on sndbuf/rcvbuf/enable_pmtud set on TCP connections
  (non-macOS), and errors on invalid device_guid UUID or out-of-range
  wintun_ring_capacity (Windows). Called standalone in main.rs as the
  first step after config is determined, before logging or any other
  setup.

- take_servers(): normalizes the server list before ClientConfig is
  constructed — promotes top-level single-server fields into
  Vec<ConnectionConfig>, resolves ca_cert (per-server → top-level →
  file path on desktop, error if unresolvable), and propagates shared
  auth (user/password/token) to servers that lack their own.

- try_from_reload_sig_and_config(): the canonical ClientConfig
  constructor — builds TunConfig (name, WinTun settings, MTU,
  addresses), and maps all remaining Config fields including the
  optional config_reload_signal for runtime hot-reload.

A call-site example showing the required ordering is placed at the top
of the section before the per-method entries. The flow diagram is also
updated to show validate() as the first step after step 6.
@kp-antonio-yang
kp-antonio-yang marked this pull request as draft July 24, 2026 02:24
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.

3 participants