-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3c5a98
commit 15a5b7c
Showing
5 changed files
with
67 additions
and
2 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
24 changes: 24 additions & 0 deletions
24
...unityCoreiOS/SOLARdVPNCommunityCoreiOS/Services/Tunnel/Routes/PostConnectionRequest.swift
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 @@ | ||
// | ||
// PostConnectionRequest.swift | ||
// SOLARdVPNCommunityCoreiOS | ||
// | ||
// Created by Lika Vorobeva on 30.09.2022. | ||
// | ||
|
||
import Foundation | ||
|
||
struct PostConnectionRequest: Codable { | ||
let nodeAddress: String | ||
|
||
init(nodeAddress: String) { | ||
self.nodeAddress = nodeAddress | ||
} | ||
} | ||
|
||
// MARK: - Codable implementation | ||
|
||
extension PostConnectionRequest { | ||
enum CodingKeys: String, CodingKey { | ||
case nodeAddress | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...unityCoreiOS/SOLARdVPNCommunityCoreiOS/Services/Tunnel/Routes/TunnelRouteCollection.swift
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,29 @@ | ||
// | ||
// TunnelRouteCollection.swift | ||
// SOLARdVPNCommunityCoreiOS | ||
// | ||
// Created by Lika Vorobeva on 30.09.2022. | ||
// | ||
|
||
import Vapor | ||
|
||
struct TunnelRouteCollection: RouteCollection { | ||
let context: HasTunnelManager | ||
|
||
func boot(routes: RoutesBuilder) throws { | ||
routes.post("connection", use: createNewSession) | ||
routes.delete("connection", use: startDeactivationOfActiveTunnel) | ||
} | ||
} | ||
|
||
extension TunnelRouteCollection { | ||
func startDeactivationOfActiveTunnel(_ req: Request) async throws -> Bool { | ||
return !context.tunnelManager.startDeactivationOfActiveTunnel() | ||
} | ||
|
||
func createNewSession(_ req: Request) async throws -> Bool { | ||
let continentCode = req.query[String.self, at: PostConnectionRequest.CodingKeys.nodeAddress.rawValue] | ||
|
||
return true | ||
} | ||
} |