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

feat(www): enable providers to send custom error responses via the dynamic key #1830

Merged
merged 25 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
46422c7
proposal: add a provider message and contact option in the dynamic key
daniellacosse Feb 2, 2024
b1f4047
style/logic cleanup
daniellacosse Feb 2, 2024
69bdfd7
Merge branch 'master' into daniellacosse/provider_message_and_contact
daniellacosse Feb 6, 2024
fefa87e
Merge branch 'master' into daniellacosse/provider_message_and_contact
daniellacosse Mar 6, 2024
a18b00a
revert model changes
daniellacosse Mar 6, 2024
e32cc03
fix error pass through
daniellacosse Mar 6, 2024
9856e20
error is optional
daniellacosse Mar 6, 2024
35c8007
update model and error handling
daniellacosse Mar 6, 2024
bbd510b
missed these imports
daniellacosse Mar 7, 2024
1234265
I think that's it
daniellacosse Mar 7, 2024
82997ac
revert cleanup
daniellacosse Mar 7, 2024
43e2d32
revert message changes from UI
daniellacosse Mar 7, 2024
9b2f33a
Update access_key_serialization.ts
daniellacosse Mar 7, 2024
f7856a4
Update index.ts
daniellacosse Mar 7, 2024
5fb54de
Update style.css
daniellacosse Mar 7, 2024
cf17514
Update index.ts
daniellacosse Mar 7, 2024
2e1db31
more feedback
daniellacosse Mar 7, 2024
fb5190a
revert UI
daniellacosse Mar 7, 2024
473d9cc
finish revert
daniellacosse Mar 7, 2024
d196f17
revert list item
daniellacosse Mar 7, 2024
d6ab2eb
feedback
daniellacosse Mar 11, 2024
f7ad23f
don't need this anymore either
daniellacosse Mar 11, 2024
57306be
restore SessionConfigError
daniellacosse Mar 12, 2024
f7fe8c2
Merge branch 'master' into daniellacosse/provider_message_and_contact
daniellacosse Mar 13, 2024
cbcf94c
don't wrap sessionconfigerror
daniellacosse Mar 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GOBIND=env PATH="$(GOBIN):$(PATH)" "$(GOMOBILE)" bind
IMPORT_HOST=github.com
IMPORT_PATH=$(IMPORT_HOST)/Jigsaw-Code/outline-client

.PHONY: android apple linux windows
.PHONY: android apple linux windows browser

all: android apple linux windows

Expand Down Expand Up @@ -73,3 +73,6 @@ $(XGO): go.mod
go.mod: tools.go
go mod tidy
touch go.mod

browser:
echo 'browser environment: nothing to do'
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,16 @@ export function staticKeyToShadowsocksSessionConfig(staticKey: string): Shadowso
}
}

function parseShadowsocksSessionConfigJson(maybeJsonText: string): ShadowsocksSessionConfig | null {
const {method, password, server, server_port, prefix} = JSON.parse(maybeJsonText);
function parseShadowsocksSessionConfigJson(
maybeJsonText: string
): ShadowsocksSessionConfig | errors.SessionConfigError | null {
const responseJson = JSON.parse(maybeJsonText);
fortuna marked this conversation as resolved.
Show resolved Hide resolved
fortuna marked this conversation as resolved.
Show resolved Hide resolved

if ('error' in responseJson) {
return responseJson.error;
}

const {method, password, server, server_port, prefix} = responseJson;

// These are the mandatory keys.
const missingKeys = [];
Expand Down
8 changes: 7 additions & 1 deletion src/www/app/outline_server_repository/server.ts
daniellacosse marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ export class OutlineServer implements Server {

async connect() {
if (this.type === ServerType.DYNAMIC_CONNECTION) {
this.sessionConfig = await fetchShadowsocksSessionConfig(this.sessionConfigLocation);
const sessionConfigOrError = await fetchShadowsocksSessionConfig(this.sessionConfigLocation);

if ('error' in sessionConfigOrError) {
fortuna marked this conversation as resolved.
Show resolved Hide resolved
throw new errors.SessionConfigFetchFailed((sessionConfigOrError.error as errors.SessionConfigError).message);
}

this.sessionConfig = sessionConfigOrError;
}

try {
Expand Down
4 changes: 4 additions & 0 deletions src/www/model/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
import {Server} from './server';
import {CustomError} from '../../infrastructure/custom_error';

export interface SessionConfigError {
message: string;
}

export class ServerAlreadyAdded extends CustomError {
constructor(public readonly server: Server) {
super();
Expand Down
Loading