Skip to content

Commit

Permalink
Rename defaultAccessKeyPort
Browse files Browse the repository at this point in the history
  • Loading branch information
fortuna committed Jan 4, 2019
1 parent ff788e9 commit a54d613
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/server_manager/model/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export interface Server {
getManagementApiUrl(): string;

// Returns the port number for new access keys.
// Returns undefined if the server doesn't have a default port set.
getDefaultAccessKeyPort(): number|undefined;
// Returns undefined if the server doesn't have a port set.
getPortForNewAccessKeys(): number|undefined;
}

// Manual servers are servers which the user has independently setup to run
Expand Down
4 changes: 2 additions & 2 deletions src/server_manager/ui_components/outline-server-settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ <h3>Digital Ocean</h3>
<h3>Server Information</h3>
<paper-input id="serverNameInput" class="server-name" value="{{name}}" label="Name" always-float-label maxlength="100" on-keydown="_handleNameInputKeyDown" on-blur="_handleNameInputBlur"></paper-input>
<p class="detail">Set a new name for your server. Note that this will not be reflected on the devices of the users that you invited to connect to it.</p>
<paper-input readonly value="[[serverDefaultAccessKeyPort]]" label="Port for new access keys" hidden$="[[!serverDefaultAccessKeyPort]]" always-float-label maxlength="100"></paper-input>
<paper-input readonly value="[[serverPortForNewAccessKeys]]" label="Port for new access keys" hidden$="[[!serverPortForNewAccessKeys]]" always-float-label maxlength="100"></paper-input>
<paper-input readonly value="[[serverHostname]]" label="Hostname" hidden$="[[!serverHostname]]" always-float-label maxlength="100"></paper-input>
<paper-input readonly value="[[serverManagementApiUrl]]" label="Management API URL" hidden$="[[!serverManagementApiUrl]]" always-float-label maxlength="100"></paper-input>
<paper-input readonly value="[[serverCreationDate]]" label="Created" hidden$="[[!serverCreationDate]]" always-float-label maxlength="100"></paper-input>
Expand Down Expand Up @@ -163,7 +163,7 @@ <h3>Share anonymous metrics</h3>
serverId: {type: String, value: null},
serverHostname: {type: String, value: null},
serverManagementApiUrl: {type: String, value: null},
serverDefaultAccessKeyPort: {type: Number, value: null},
serverPortForNewAccessKeys: {type: Number, value: null},
serverCreationDate: {type: String, value: null},
serverLocation: {type: String, value: null},
serverMonthlyCost: {type: String, value: null},
Expand Down
4 changes: 2 additions & 2 deletions src/server_manager/ui_components/outline-server-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ <h3>[[accessKeyRows.length]]</h3>
server-id="[[serverId]]"
server-hostname="[[serverHostname]]"
server-management-api-url="[[serverManagementApiUrl]]"
server-default-access-key-port="[[serverDefaultAccessKeyPort]]"
server-port-for-new-access-keys="[[serverPortForNewAccessKeys]]"
server-creation-date="[[serverCreationDate]]"
server-monthly-cost="[[monthlyCost]]"
server-monthly-transfer-limit="[[_formatBytesTransferred(monthlyOutboundTransferBytes)]]"
Expand Down Expand Up @@ -530,7 +530,7 @@ <h3>Create keys, share access</h3>
serverName: String,
serverHostname: String,
serverManagementApiUrl: String,
serverDefaultAccessKeyPort: Number,
serverPortForNewAccessKeys: Number,
serverCreationDate: String,
serverLocation: String,
isServerManaged: Boolean,
Expand Down
2 changes: 1 addition & 1 deletion src/server_manager/web_app/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class FakeServer implements server.Server {
getManagementApiUrl() {
return this.apiUrl || Math.random().toString();
}
getDefaultAccessKeyPort(): number {
getPortForNewAccessKeys(): number|undefined {
return undefined;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/server_manager/web_app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ export class App {
view.serverName = selectedServer.getName();
view.serverHostname = selectedServer.getHostname();
view.serverManagementApiUrl = selectedServer.getManagementApiUrl();
view.serverDefaultAccessKeyPort = selectedServer.getDefaultAccessKeyPort();
view.serverPortForNewAccessKeys = selectedServer.getPortForNewAccessKeys();
view.serverCreationDate = selectedServer.getCreatedDate().toLocaleString(
'en-US', {year: 'numeric', month: 'long', day: 'numeric'});

Expand Down
8 changes: 4 additions & 4 deletions src/server_manager/web_app/shadowbox_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface ServerConfig {
metricsEnabled: boolean;
serverId: string;
createdTimestampMs: number;
defaultAccessKeyPort: number;
portForNewAccessKeys: number;
}

export class ShadowboxServer implements server.Server {
Expand Down Expand Up @@ -132,12 +132,12 @@ export class ShadowboxServer implements server.Server {
}
}

getDefaultAccessKeyPort(): number|undefined {
getPortForNewAccessKeys(): number|undefined {
try {
if (typeof this.serverConfig.defaultAccessKeyPort !== "number") {
if (typeof this.serverConfig.portForNewAccessKeys !== 'number') {
return undefined;
}
return this.serverConfig.defaultAccessKeyPort;
return this.serverConfig.portForNewAccessKeys;
} catch (e) {
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion src/shadowbox/server/manager_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class ShadowsocksManagerService {
serverId: this.serverConfig.data().serverId,
metricsEnabled: this.serverConfig.data().metricsEnabled || false,
createdTimestampMs: this.serverConfig.data().createdTimestampMs,
defaultAccessKeyPort: this.serverConfig.data().defaultAccessKeyPort
portForNewAccessKeys: this.serverConfig.data().portForNewAccessKeys
});
next();
}
Expand Down
12 changes: 6 additions & 6 deletions src/shadowbox/server/server_access_key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface AccessKeyConfigJson {
// Next AccessKeyId to use.
nextId?: number;

// DEPRECATED: Use ServerConfigJson.defaultAccessKeyPort instead.
// DEPRECATED: Use ServerConfigJson.portForNewAccessKeys instead.
defaultPort?: number;
}

Expand Down Expand Up @@ -69,7 +69,7 @@ export class ServerAccessKeyRepository implements AccessKeyRepository {

constructor(
private portProvider: PortProvider, private proxyHostname: string,
private keyConfig: JsonConfig<AccessKeyConfigJson>,
private portForNewAccessKeys: number, private keyConfig: JsonConfig<AccessKeyConfigJson>,
private serverConfig: JsonConfig<ServerConfigJson>,
private shadowsocksServer: ShadowsocksServer) {
if (this.keyConfig.data().accessKeys === undefined) {
Expand Down Expand Up @@ -149,18 +149,18 @@ export class ServerAccessKeyRepository implements AccessKeyRepository {
}

private async getDefaultPort(): Promise<number> {
if (!this.serverConfig.data().defaultAccessKeyPort) {
if (!this.serverConfig.data().portForNewAccessKeys) {
// For backward compatibility.
if (this.keyConfig.data().defaultPort) {
this.serverConfig.data().defaultAccessKeyPort = this.keyConfig.data().defaultPort;
this.serverConfig.data().portForNewAccessKeys = this.keyConfig.data().defaultPort;
delete this.keyConfig.data().defaultPort;
this.keyConfig.write();
} else {
this.serverConfig.data().defaultAccessKeyPort = await this.portProvider.reserveNewPort();
this.serverConfig.data().portForNewAccessKeys = await this.portProvider.reserveNewPort();
}
this.serverConfig.write();
}
return this.serverConfig.data().defaultAccessKeyPort;
return this.serverConfig.data().portForNewAccessKeys;
}

private updateServer(): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion src/shadowbox/server/server_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface ServerConfigJson {
// When this server was created. Shown in the Outline Manager and to trigger the metrics opt-in.
createdTimestampMs?: number;
// What port number should we use for new access keys?
defaultAccessKeyPort?: number;
portForNewAccessKeys?: number;
// Which staged rollouts we should force enabled or disabled.
rollouts?: RolloutConfigJson[];
}
Expand Down

0 comments on commit a54d613

Please sign in to comment.