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

SplitTunnel 01: Use a factory for creation #9889

Merged
merged 1 commit into from
Sep 24, 2024
Merged

SplitTunnel 01: Use a factory for creation #9889

merged 1 commit into from
Sep 24, 2024

Conversation

strseb
Copy link
Collaborator

@strseb strseb commented Sep 19, 2024

Stacked PRs:


SplitTunnel 01: Use a factory for creation

Currently you need to create the object and then call
the correct functions in order to have an initialized object.

Similar to wgnt lets make sure that no "invalid" object can even exist.
so that we can assert you will not call i.e. start() on a closed handle.
Given that it's not cool to have constructors throw exceptions lets add
a create() factory that will spit out nullptr or a working instance.

MZ_COUNT_CTOR(WindowsDaemon);

m_firewallManager = WindowsFirewall::instance();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor nit: Perhaps we could make this WindowsFirewall::create() or just new WindowsFirewall(this) to make its initialization call explicit and consistent with the rest of the stuff here (and establish an obvious object ownership hierarchy).

@strseb strseb changed the base branch from strseb/stack/1 to main September 19, 2024 14:52
@strseb strseb changed the base branch from main to strseb/stack/1 September 19, 2024 14:53
}
// 04: Make sure the Windows Firewall has created the sublayer
// otherwise the driver will fail to initialize
if (!fw || !fw->init()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor nit: I get that this hasn't really changed, but it is kindof odd for the firewall init to be happening here. It would be a little more appropriate for WindowsDaemon to do the init, and then pass in a reference to the WFP sublayer as an argument to WindowsSplitTunnel::create()

Copy link
Collaborator

Choose a reason for hiding this comment

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

How exactly does the split tunnel driver figure out the WFP sublayer to use?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The Sublayer is hardcoded in the driver...

@strseb strseb changed the base branch from strseb/stack/1 to main September 23, 2024 13:23
@strseb strseb changed the base branch from main to strseb/stack/1 September 23, 2024 13:23
@strseb strseb changed the base branch from strseb/stack/1 to main September 23, 2024 13:25
@strseb strseb changed the base branch from main to strseb/stack/1 September 23, 2024 13:25
Base automatically changed from strseb/stack/1 to main September 23, 2024 14:19
Currently you need to create the object and then call
the correct functions in order to have an initialized object.

Similar to wgnt lets make sure that no "invalid" object can even exist.
so that we can assert you will not call i.e. start() on a closed handle.
Given that it's not cool to have constructors throw exceptions lets add
a create() factory that will spit out nullptr or a working instance.

stack-info: PR: #9889, branch: strseb/stack/2
@strseb strseb merged commit 4dfcad9 into main Sep 24, 2024
115 of 116 checks passed
@strseb strseb deleted the strseb/stack/2 branch September 24, 2024 13:29
strseb added a commit that referenced this pull request Sep 24, 2024
* SplitTunnel 01: Use a factory for creation

Currently you need to create the object and then call
the correct functions in order to have an initialized object.

Similar to wgnt lets make sure that no "invalid" object can even exist.
so that we can assert you will not call i.e. start() on a closed handle.
Given that it's not cool to have constructors throw exceptions lets add
a create() factory that will spit out nullptr or a working instance.

stack-info: PR: #9889, branch: strseb/stack/2

* SplitTunnel 02: remove dupe code in generateIPConfiguration

Inline Lambdas are cool, let's use them to reduce dupecode and lets
give this function a failstate to bubble that up later to the client.

stack-info: PR: #9890, branch: strseb/stack/3
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