-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Web app online config #921
Conversation
37592b6
to
473d688
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm glad to see this change!
} | ||
|
||
async connect() { | ||
try { | ||
if (this.config.source) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this logic to get the config to a ConfigSource object, with a getConfigForNewConnection().
This will separate the concerns. The OutlineServer does not have to know how the config is obtained.
@@ -40,10 +43,21 @@ export interface Server { | |||
checkReachable(): Promise<boolean>; | |||
} | |||
|
|||
export type ServerConfig = ShadowsocksConfig; | |||
|
|||
export interface ServerConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove ServerConfig from the model. That's a persistency/application concept.
For persistency, let's use {name, access_key}, This way we reuse the existing serialization format. No need to have two different formats.
|
||
export interface ServerRepository { | ||
add(serverConfig: ServerConfig): void; | ||
update(serverId: string, newConfig: ServerConfig): void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a method on the ConfigSource instead. On permanent redirection + successful connection, we can call configSource.setAccessKey(newAccessKey)
, and the implementation takes care of persisting that.
@@ -20,3 +20,8 @@ export interface ShadowsocksConfig { | |||
method?: string; | |||
name?: string; | |||
} | |||
|
|||
// Endpoint to retrieve Shadowsocks proxy configurations. | |||
export interface ShadowsocksConfigSource { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ConfigSource doesn't need to live in the model. It can be defined in the repository module.
@@ -155,7 +159,7 @@ | |||
></server-connection-viz> | |||
<div id="serverInfo"> | |||
<div id="serverName">[[serverName]]</div> | |||
<div id="serverHost">[[serverHost]]:[[serverPort]]</div> | |||
<div id="serverHost">[[serverHost]]</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should still show server and port, but only while connected?
This is really a UI question.
/cc @cjhenck
const serversJsonV1 = JSON.stringify(configByIdV1); | ||
storage.setItem(PersistentServerRepository.SERVERS_STORAGE_KEY, serversJsonV1); | ||
} | ||
|
||
function configsMatch(left: ServerConfig, right: ServerConfig) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use the access key, this can be a simple ==
@@ -35,13 +38,20 @@ export type PersistentServerFactory = | |||
// Maintains a persisted set of servers and liaises with the core. | |||
export class PersistentServerRepository implements ServerRepository { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can move this code to the outline_server.ts file.
@@ -58,15 +68,25 @@ export class PersistentServerRepository implements ServerRepository { | |||
if (alreadyAddedServer) { | |||
throw new ServerAlreadyAdded(alreadyAddedServer); | |||
} | |||
if (!OutlineServer.isServerCipherSupported(serverConfig.method)) { | |||
throw new ShadowsocksUnsupportedCipher(serverConfig.method || 'unknown'); | |||
if (!isServerCipherSupported(serverConfig)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to fetch the config from the ConfigSource here, so we can validate it and make sure it works.
|
||
config: ShadowsocksConfig; | ||
config?: ShadowsocksConfig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this shouldn't be explosed?
|
||
readonly id: string; | ||
|
||
fetchProxyConfig(source: ShadowsocksConfigSource): Promise<ProxyConfigResponse>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would go away, since the TS code would already be giving you the Shadowsocks config to use.
Implements SIP008 online config in the web app per #891.
ServerConfig
to include the proxy configuration source. Performs a data migration on local storage.Tunnel
interface exposes a method,fetchProxyConfig
, to retrieve the proxy configuration.ProxyConfigResponse
type enables the web app to update the configuration source on redirects and surface HTTP status codes.OutlineServer
retrieves the proxy configuration upon connecting.TODO
ssconf://
in addtion tohttps://
.