-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
6 changed files
with
126 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"strconv" | ||
|
||
docs "github.com/SkyPierIO/skypier-vpn/pkg/docs" | ||
|
@@ -14,11 +15,11 @@ import ( | |
"github.com/gin-gonic/gin" | ||
) | ||
|
||
// @title Swagger Skypier API | ||
// @version 1.0 | ||
// @description This is a Skypier VPN REST API. | ||
// @title Skypier | ||
// @version 0.0.1 | ||
// @description Skypier - Embark securely on web3 | ||
|
||
// @contact.name Skypier info | ||
// @contact.name Skypier | ||
// @contact.url http://skypier.io/ | ||
// @contact.email [email protected] | ||
|
||
|
@@ -57,6 +58,7 @@ func main() { | |
if config.SwaggerEnabled { | ||
docs.SwaggerInfo.BasePath = "/api/v0" | ||
router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler)) | ||
log.Println("Swagger UI available at http://127.0.0.1:8081/swagger/index.html") | ||
} | ||
|
||
api := router.Group("/api/v0") | ||
|
@@ -67,6 +69,7 @@ func main() { | |
c.String(200, "pong") | ||
}) | ||
api.GET("/getConfig", utils.GetConfiguration) | ||
api.GET("/id", vpn.GetPeerId) | ||
|
||
// Run with HTTP | ||
router.Run("0.0.0.0:" + strconv.FormatUint(uint64(innerConfig.Port), 10)) | ||
|
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ const docTemplate = `{ | |
"description": "{{escape .Description}}", | ||
"title": "{{.Title}}", | ||
"contact": { | ||
"name": "Skypier info", | ||
"name": "Skypier", | ||
"url": "http://skypier.io/", | ||
"email": "[email protected]" | ||
}, | ||
|
@@ -48,6 +48,32 @@ const docTemplate = `{ | |
} | ||
} | ||
} | ||
}, | ||
"/id": { | ||
"get": { | ||
"description": "Get the local libp2p peer ID (this is the identity of your node on the Skypier Network)", | ||
"produces": [ | ||
"application/json" | ||
], | ||
"tags": [ | ||
"P2P" | ||
], | ||
"summary": "Get the local peer ID", | ||
"responses": { | ||
"200": { | ||
"description": "OK" | ||
}, | ||
"400": { | ||
"description": "Bad Request" | ||
}, | ||
"404": { | ||
"description": "Not Found" | ||
}, | ||
"500": { | ||
"description": "Internal Server Error" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"externalDocs": { | ||
|
@@ -58,12 +84,12 @@ const docTemplate = `{ | |
|
||
// SwaggerInfo holds exported Swagger Info so clients can modify it | ||
var SwaggerInfo = &swag.Spec{ | ||
Version: "1.0", | ||
Version: "0.0.1", | ||
Host: "localhost:8081", | ||
BasePath: "/api/v0", | ||
Schemes: []string{}, | ||
Title: "Swagger Skypier API", | ||
Description: "This is a Skypier VPN REST API.", | ||
Title: "Skypier", | ||
Description: "Skypier - Embark securely on web3", | ||
InfoInstanceName: "swagger", | ||
SwaggerTemplate: docTemplate, | ||
LeftDelim: "{{", | ||
|
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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
{ | ||
"swagger": "2.0", | ||
"info": { | ||
"description": "This is a Skypier VPN REST API.", | ||
"title": "Swagger Skypier API", | ||
"description": "Skypier - Embark securely on web3", | ||
"title": "Skypier", | ||
"contact": { | ||
"name": "Skypier info", | ||
"name": "Skypier", | ||
"url": "http://skypier.io/", | ||
"email": "[email protected]" | ||
}, | ||
"license": { | ||
"name": "MIT", | ||
"url": "https://choosealicense.com/licenses/mit/" | ||
}, | ||
"version": "1.0" | ||
"version": "0.0.1" | ||
}, | ||
"host": "localhost:8081", | ||
"basePath": "/api/v0", | ||
|
@@ -42,6 +42,32 @@ | |
} | ||
} | ||
} | ||
}, | ||
"/id": { | ||
"get": { | ||
"description": "Get the local libp2p peer ID (this is the identity of your node on the Skypier Network)", | ||
"produces": [ | ||
"application/json" | ||
], | ||
"tags": [ | ||
"P2P" | ||
], | ||
"summary": "Get the local peer ID", | ||
"responses": { | ||
"200": { | ||
"description": "OK" | ||
}, | ||
"400": { | ||
"description": "Bad Request" | ||
}, | ||
"404": { | ||
"description": "Not Found" | ||
}, | ||
"500": { | ||
"description": "Internal Server Error" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"externalDocs": { | ||
|
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 |
---|---|---|
|
@@ -6,14 +6,14 @@ host: localhost:8081 | |
info: | ||
contact: | ||
email: [email protected] | ||
name: Skypier info | ||
name: Skypier | ||
url: http://skypier.io/ | ||
description: This is a Skypier VPN REST API. | ||
description: Skypier - Embark securely on web3 | ||
license: | ||
name: MIT | ||
url: https://choosealicense.com/licenses/mit/ | ||
title: Swagger Skypier API | ||
version: "1.0" | ||
title: Skypier | ||
version: 0.0.1 | ||
paths: | ||
/getConfig: | ||
get: | ||
|
@@ -32,4 +32,22 @@ paths: | |
summary: Get the configuration | ||
tags: | ||
- config | ||
/id: | ||
get: | ||
description: Get the local libp2p peer ID (this is the identity of your node | ||
on the Skypier Network) | ||
produces: | ||
- application/json | ||
responses: | ||
"200": | ||
description: OK | ||
"400": | ||
description: Bad Request | ||
"404": | ||
description: Not Found | ||
"500": | ||
description: Internal Server Error | ||
summary: Get the local peer ID | ||
tags: | ||
- P2P | ||
swagger: "2.0" |
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,26 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
pushd ./pkg | ||
echo -e "\n[+]\tGenerating swagger doc..." | ||
swag init --dir ../cmd/skypier-vpn-node/,../pkg/ui/,../pkg/vpn/,../pkg/utils/ | ||
popd | ||
|
||
echo -e "\n[+]\tGo build..." | ||
go build -o build/skypier-vpn-node cmd/skypier-vpn-node/main.go | ||
echo -e "\n[+]\tRun..." | ||
sudo ./build/skypier-vpn-node | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|