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

refactor(client): more config cleanup and consolidation #2265

Merged
merged 12 commits into from
Nov 11, 2024
Merged

Conversation

fortuna
Copy link
Collaborator

@fortuna fortuna commented Nov 8, 2024

This PR further removes dependencies on the Shadowsocks format, and consolidates them, so it's clear what needs to be fixed. I have created the config.ts file to centralize all the config logic.

One critical cleanup was the removal of Shadowsocks validation from the add access key view.

@fortuna fortuna requested a review from a team as a code owner November 8, 2024 21:42
@github-actions github-actions bot added the size/L label Nov 8, 2024
@fortuna fortuna changed the title clean(client): more config cleanup and consolidation refactor(client): more config cleanup and consolidation Nov 8, 2024
@github-actions github-actions bot added size/XL and removed size/L labels Nov 8, 2024
Copy link
Contributor

@daniellacosse daniellacosse left a comment

Choose a reason for hiding this comment

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

some nits. I also have issues with the moved code but I assume that can be cleaned up later

client/src/www/app/outline_server_repository/server.ts Outdated Show resolved Hide resolved
@@ -23,6 +22,7 @@ export class AddAccessKeyDialog extends LitElement {
) => string;
@property({type: Boolean}) open: boolean;
@property({type: String}) accessKey: string = '';
@property({type: Function}) isValidAccessKey: (accessKey: string) => boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: usually since this is a function not a boolean i'd give it an "action-based" name like validateAccessKey or accessKeyValidator for clarity but up to you

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 result is a boolean though. I think it reads more clearly in tha call sites that way.


import * as errors from '../../model/errors';

export type TransportConfigJson = object;
Copy link
Contributor

Choose a reason for hiding this comment

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

i assume you just moved all this code w/o modifying, but maybe we make this type more explicit? would clean up some of the type casting below. maybe in a follow up pr

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 type definition is intended to belong in the Go code. That's why I made it a generic object here.
The Typescript code is supposed to treat it as a black box and not dig into it. Though it does in the instances below.

At least now it's clearer where we violate the abstraction and what we still need to fix for advanced configs.

Copy link
Contributor

Choose a reason for hiding this comment

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

So in the future these methods would belong in go? maybe worth a comment

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree to add a comment.

Suggested change
export type TransportConfigJson = object;
/** TransportConfigJson is an opaque config format defined in Go, TypeScript should not rely on its fields. */
export type TransportConfigJson = object;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added

@fortuna
Copy link
Collaborator Author

fortuna commented Nov 11, 2024

@jyyi1 thoughts?

client/electron/go_vpn_tunnel.ts Outdated Show resolved Hide resolved

import * as errors from '../../model/errors';

export type TransportConfigJson = object;
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree to add a comment.

Suggested change
export type TransportConfigJson = object;
/** TransportConfigJson is an opaque config format defined in Go, TypeScript should not rely on its fields. */
export type TransportConfigJson = object;

* getAddressFromTransportConfig returns the address of the tunnel server, if there's a meaningful one.
* This is used to show the server address in the UI when connected.
*/
export function getAddressFromTransportConfig(
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a TODO to remind us moving this logic to Go?

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 TODO is for most of this file. I think it's pointless to add TODOs everywhere here. Also this is in flux.

client/src/www/app/outline_server_repository/config.ts Outdated Show resolved Hide resolved
client/src/www/app/outline_server_repository/config.ts Outdated Show resolved Hide resolved
client/src/www/app/outline_server_repository/index.ts Outdated Show resolved Hide resolved
@fortuna fortuna requested a review from jyyi1 November 11, 2024 21:06
Copy link
Contributor

@jyyi1 jyyi1 left a comment

Choose a reason for hiding this comment

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

Cool! LGTM, thanks for the cleanup.

@fortuna fortuna enabled auto-merge (squash) November 11, 2024 22:47
@fortuna fortuna merged commit e96c781 into master Nov 11, 2024
23 checks passed
@fortuna fortuna deleted the fortuna-clean branch November 11, 2024 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants