-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client/linux): revamp the Linux routing logic
- Loading branch information
Showing
7 changed files
with
177 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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. | ||
|
||
import {TransportConfigJson} from '../src/www/app/outline_server_repository/config'; | ||
import {invokeGoApi} from './go_plugin'; | ||
|
||
interface VpnConfig { | ||
interfaceName: string; | ||
ipAddress: string; | ||
dnsServers: string[]; | ||
transport: string; | ||
} | ||
|
||
export async function establishVpn(transportConfig: TransportConfigJson) { | ||
const config: VpnConfig = { | ||
interfaceName: 'outline-tun0', | ||
ipAddress: '10.0.85.2', | ||
dnsServers: ['9.9.9.9'], | ||
transport: JSON.stringify(transportConfig), | ||
}; | ||
const connection = await invokeGoApi('EstablishVPN', JSON.stringify(config)); | ||
Check failure on line 32 in client/electron/vpn_service.ts GitHub Actions / Lint
|
||
} | ||
|
||
export async function closeVpn() {} |
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,65 @@ | ||
// 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. | ||
|
||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/Jigsaw-Code/outline-apps/client/go/outline/platerrors" | ||
) | ||
|
||
type VPNConfig struct { | ||
InterfaceName string `json:"interfaceName"` | ||
IPAddress string `json:"ipAddress"` | ||
DNSServers []string `json:"dnsServers"` | ||
TransportConfig string `json:"transport"` | ||
} | ||
|
||
type VPNConnection struct { | ||
RouteUDP bool `json:"routeUDP"` | ||
} | ||
|
||
func EstablishVPN(configStr string) (string, *platerrors.PlatformError) { | ||
var config VPNConfig | ||
err := json.Unmarshal([]byte(configStr), &config) | ||
if err != nil { | ||
return "", &platerrors.PlatformError{ | ||
Code: platerrors.IllegalConfig, | ||
Message: "illegal VPN config format", | ||
Cause: platerrors.ToPlatformError(err), | ||
} | ||
} | ||
|
||
conn, perr := establishVPN(&config) | ||
if perr != nil { | ||
return "", perr | ||
} | ||
|
||
if conn == nil { | ||
return "", &platerrors.PlatformError{ | ||
Code: platerrors.InternalError, | ||
Message: "unexpected nil VPN connection", | ||
} | ||
} | ||
connJson, err := json.Marshal(conn) | ||
if err != nil { | ||
return "", &platerrors.PlatformError{ | ||
Code: platerrors.InternalError, | ||
Message: "failed to marshal VPN connection", | ||
Cause: platerrors.ToPlatformError(err), | ||
} | ||
} | ||
return string(connJson), nil | ||
} |
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,23 @@ | ||
// 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. | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/Jigsaw-Code/outline-apps/client/go/outline/platerrors" | ||
) | ||
|
||
func establishVPN(config *VPNConfig) (*VPNConnection, *platerrors.PlatformError) { | ||
return nil, platerrors.NewPlatformError(platerrors.InternalError, "Working in progress !!!") | ||
} |
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,24 @@ | ||
// 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. | ||
|
||
package main | ||
|
||
import "github.com/Jigsaw-Code/outline-apps/client/go/outline/platerrors" | ||
|
||
func establishVPN(config *VPNConfig) (*VPNConnection, *platerrors.PlatformError) { | ||
return nil, &platerrors.PlatformError{ | ||
Code: platerrors.InternalError, | ||
Message: "not implemented yet", | ||
} | ||
} |