Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define Tunnel interface in typescript (#922)
- Loading branch information
Showing
14 changed files
with
120 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2020 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. | ||
|
||
import {ShadowsocksConfig} from '../../www/model/shadowsocks'; | ||
|
||
export const enum TunnelStatus { | ||
CONNECTED, | ||
DISCONNECTED, | ||
RECONNECTING | ||
} | ||
|
||
// Represents a VPN tunnel to a Shadowsocks proxy server. Implementations provide native tunneling | ||
// functionality through cordova.plugins.oultine.Tunnel and ElectronOutlineTunnel. | ||
export interface Tunnel { | ||
// Unique instance identifier. | ||
readonly id: string; | ||
|
||
// Shadowsocks proxy configuration. | ||
config: ShadowsocksConfig; | ||
|
||
// Connects a VPN, routing all device traffic to a Shadowsocks server as dictated by `config`. | ||
// If there is another running instance, broadcasts a disconnect event and stops the active | ||
// tunnel. In such case, restarts tunneling while preserving the VPN. | ||
// Throws OutlinePluginError. | ||
start(): Promise<void>; | ||
|
||
// Stops the tunnel and VPN service. | ||
stop(): Promise<void>; | ||
|
||
// Returns whether the tunnel instance is active. | ||
isRunning(): Promise<boolean>; | ||
|
||
// Returns whether the proxy server is reachable by attempting to open a TCP socket | ||
// to the IP and port specified in `config`. | ||
isReachable(): Promise<boolean>; | ||
|
||
// Sets a listener, to be called when the tunnel status changes. | ||
onStatusChange(listener: (status: TunnelStatus) => void): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2020 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. | ||
|
||
// Represents a Shadowsocks proxy server configuration. | ||
export interface ShadowsocksConfig { | ||
host?: string; | ||
port?: number; | ||
password?: string; | ||
method?: string; | ||
name?: string; | ||
} |