-
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
proposal(www): allow providers to make access keys shareable. #1836
Changes from all commits
46422c7
b1f4047
69bdfd7
f2ac0af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,6 +130,8 @@ | |
this.rootEl.addEventListener('DisconnectPressed', this.disconnectServer.bind(this)); | ||
this.rootEl.addEventListener('ForgetPressed', this.forgetServer.bind(this)); | ||
this.rootEl.addEventListener('RenameRequested', this.renameServer.bind(this)); | ||
this.rootEl.addEventListener('ForgetPressed', this.forgetServer.bind(this)); | ||
this.rootEl.addEventListener('ShareServer', this.shareServer.bind(this)); | ||
this.rootEl.addEventListener('QuitPressed', this.quitApplication.bind(this)); | ||
this.rootEl.addEventListener('AutoConnectDialogDismissed', this.autoConnectDialogDismissed.bind(this)); | ||
this.rootEl.addEventListener('ShowServerRename', this.rootEl.showServerRename.bind(this.rootEl)); | ||
|
@@ -378,6 +380,23 @@ | |
this.serverRepo.rename(serverId, newName); | ||
} | ||
|
||
private async shareServer(event: CustomEvent) { | ||
const {serverId} = event.detail; | ||
const server = this.getServerByServerId(serverId); | ||
|
||
// TODO: fallback to copying to clipboard if share is not available | ||
if (!navigator.share) { | ||
console.warn('Web Share API not available'); | ||
return; | ||
} | ||
|
||
await navigator.share({ | ||
title: server.name || 'Outline Server', | ||
text: this.localize('share-server-text'), | ||
url: server.accessKey, | ||
}); | ||
} | ||
|
||
private async connectServer(event: CustomEvent) { | ||
event.stopImmediatePropagation(); | ||
|
||
|
@@ -589,7 +608,7 @@ | |
// Helpers: | ||
|
||
private makeServerListItem(server: Server): ServerListItem { | ||
return { | ||
const serverListItem: ServerListItem = { | ||
disabled: false, | ||
errorMessageId: server.errorMessageId, | ||
isOutlineServer: server.isOutlineServer, | ||
|
@@ -598,6 +617,29 @@ | |
id: server.id, | ||
connectionState: ServerConnectionState.DISCONNECTED, | ||
}; | ||
|
||
if (server.sessionConfig?.extra) { | ||
const extraParams = server.sessionConfig.extra; | ||
|
||
if (['error', 'warning', 'info'].includes(extraParams.messageType) && extraParams.messageContent) { | ||
serverListItem.message = { | ||
type: extraParams.messageType as 'error' | 'warning' | 'info', | ||
content: extraParams.messageContent, | ||
}; | ||
} | ||
|
||
if (extraParams.contactEmail) { | ||
serverListItem.contact = { | ||
email: extraParams.email, | ||
}; | ||
} | ||
|
||
if (extraParams.share) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it should be called Also, we could add this to the static keys as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do worry about extending our bad config format that doesn't differentiate service and transport configuration, and has a very rigid transport configuration. I would like us to not get stuck with it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hear you, but I wonder the degree to which we're tied to SIPOO2 already? I mean people use the client to connect to other shadowsocks servers all the time. How about this - if we don't block adding these features to the access keys on inventing a new format I promise to draft a proposal for an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here I already started https://docs.google.com/document/d/1FnhjpEMWvikGPhKjfH75Y-UYT7RQlqa1z_yycmL5Pow/edit?tab=t.0 |
||
serverListItem.canShare = true; | ||
} | ||
} | ||
|
||
return serverListItem; | ||
} | ||
|
||
private throttleServerConnectionChange(serverId: string, time: number) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2024 The Outline Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
export interface ShadowsocksSessionConfig { | ||
host?: string; | ||
port?: number; | ||
password?: string; | ||
method?: string; | ||
prefix?: string; | ||
extra?: {[key: string]: string}; | ||
} |
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.
Need to test this on multiple platforms!
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.
What Chrome version are we using with Electron? Compare with https://caniuse.com/?search=navigator.share
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 believe it's over 100, we should be okay - but I will test to confirm once we're aligned on this idea