-
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
0 parents
commit 9838936
Showing
22 changed files
with
728 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# .github/workflows/main.yml | ||
name: Build | ||
on: | ||
push: | ||
braches: [main] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Getting Go Binaries | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.18' | ||
- name: Build Application | ||
run: | | ||
go get -u && go mod tidy | ||
go build -o rest-server | ||
- name: Create Zip | ||
run: | | ||
zip -r /tmp/rest-server-${{ github.run_number }}.zip rest-server | ||
- name: Release | ||
id: create_release | ||
uses: softprops/action-gh-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.TOKEN }} | ||
with: | ||
files: /tmp/rest-server-${{ github.run_number }}.zip | ||
name: "Release ${{ github.run_number }}" | ||
tag_name: "release.${{ github.run_number }}" |
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,2 @@ | ||
.env | ||
tmp/ |
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,2 @@ | ||
# Liman MYS Render Engine | ||
|
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,25 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/gofiber/fiber/v2" | ||
"github.com/limanmys/render-engine/app/models" | ||
"github.com/limanmys/render-engine/internal/bridge" | ||
) | ||
|
||
func CredentialTest(c *fiber.Ctx) error { | ||
|
||
credentials, err := bridge.GetCredentials( | ||
&models.User{ | ||
ID: c.Params("user"), | ||
}, | ||
&models.Server{ | ||
ID: c.Params("server"), | ||
}, | ||
) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
return c.JSON(credentials) | ||
} |
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,18 @@ | ||
package models | ||
|
||
// AccessToken Structure of the personal access token | ||
type AccessToken struct { | ||
ID string `json:"id"` | ||
Name string `json:"name"` | ||
UserID string `json:"user_id"` | ||
LastUsedAt string `json:"last_used_at"` | ||
LastUsedIP string `json:"last_used_ip"` | ||
Token string `json:"token"` | ||
CreatedAt string `json:"created_at"` | ||
UpdatedAt string `json:"updated_at"` | ||
IPRange string `json:"ip_range"` | ||
} | ||
|
||
func (AccessToken) TableName() string { | ||
return "access_tokens" | ||
} |
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,15 @@ | ||
package models | ||
|
||
type Credentials struct { | ||
// Type | ||
Type string `json:"type"` | ||
|
||
// Username | ||
Username string `json:"username"` | ||
|
||
// Certificate or password | ||
Key string `json:"key"` | ||
|
||
// Connection port | ||
Port string `json:"port"` | ||
} |
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 @@ | ||
package models | ||
|
||
// Extension Structure of the extension obj | ||
type Extension struct { | ||
ID string `json:"id"` | ||
Name string `json:"name"` | ||
Version string `json:"version"` | ||
Icon string `json:"icon"` | ||
Service string `json:"service"` | ||
CreatedAt string `json:"created_at"` | ||
UpdatedAt string `json:"updated_at"` | ||
Order int `json:"order"` | ||
SslPorts string `json:"sslPorts" pg:"sslPorts"` | ||
Issuer string `json:"issuer"` | ||
Language string `json:"language"` | ||
Support string `json:"support"` | ||
Displays string `json:"displays"` | ||
Status string `json:"status"` | ||
RequireKey string `json:"require_key"` | ||
} | ||
|
||
func (Extension) TableName() string { | ||
return "extensions" | ||
} |
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 @@ | ||
package models | ||
|
||
// ServerModel Structure of the server obj | ||
type Server struct { | ||
ID string `json:"id"` | ||
Name string `json:"name"` | ||
Type string `json:"type"` | ||
IPAddress string `json:"ip_address"` | ||
City string `json:"city"` | ||
ControlPort string `json:"control_port"` | ||
UserID string `json:"user_id"` | ||
CreatedAt string `json:"created_at"` | ||
UpdatedAt string `json:"updated_at"` | ||
Os string `json:"os"` | ||
Enabled string `json:"enabled"` | ||
KeyPort int `json:"key_port"` | ||
SharedKey int `json:"shared_key"` | ||
} | ||
|
||
func (Server) TableName() string { | ||
return "servers" | ||
} |
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,38 @@ | ||
package models | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/mervick/aes-everywhere/go/aes256" | ||
) | ||
|
||
// ServerKey Structure of the server keys | ||
type ServerKey struct { | ||
ID string `json:"id"` | ||
Type string `json:"type"` | ||
Data string `json:"data"` | ||
ServerID string `json:"server_id"` | ||
UserID string `json:"user_id"` | ||
CreatedAt string `json:"created_at"` | ||
UpdatedAt string `json:"updated_at"` | ||
} | ||
|
||
type KeyData struct { | ||
ClientUsername string `json:"clientUsername"` | ||
ClientPassword string `json:"clientPassword"` | ||
KeyPort string `json:"key_port"` | ||
} | ||
|
||
func (ServerKey) TableName() string { | ||
return "server_keys" | ||
} | ||
|
||
func (d KeyData) DecryptKey(user *User, server *Server) *Credentials { | ||
key := os.Getenv("APP_KEY") + user.ID + server.ID | ||
|
||
return &Credentials{ | ||
Username: aes256.Decrypt(d.ClientUsername, key), | ||
Key: aes256.Decrypt(d.ClientPassword, key), | ||
Port: d.KeyPort, | ||
} | ||
} |
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,14 @@ | ||
package models | ||
|
||
// TokenModel Structure of the tokens tableD | ||
type Token struct { | ||
ID string `json:"id"` | ||
UserID string `json:"user_id"` | ||
Token string `json:"token"` | ||
CreatedAt string `json:"created_at"` | ||
UpdatedAt string `json:"updated_at"` | ||
} | ||
|
||
func (Token) TableName() string { | ||
return "tokens" | ||
} |
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 @@ | ||
package models | ||
|
||
// UserModel Structure of the users table | ||
type User struct { | ||
ID string `json:"id"` | ||
Name string `json:"name"` | ||
Email string `json:"email"` | ||
Password string `json:"password"` | ||
Status int `json:"status"` | ||
LastLoginAt string `json:"last_login_at"` | ||
RememberToken string `json:"remember_token"` | ||
LastLoginIP string `json:"last_login_ip"` | ||
CreatedAt string `json:"created_at"` | ||
UpdatedAt string `json:"updated_at"` | ||
ForceChange bool `json:"forcechange" pg:"forceChange"` | ||
ObjectGUID string `json:"objectguid" pg:"objectguid"` | ||
AuthType string `json:"auth_type"` | ||
} | ||
|
||
func (User) TableName() string { | ||
return "users" | ||
} |
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,10 @@ | ||
package routes | ||
|
||
import ( | ||
"github.com/gofiber/fiber/v2" | ||
"github.com/limanmys/render-engine/app/controllers" | ||
) | ||
|
||
func Install(app *fiber.App) { | ||
app.Get("/credentials/:user/:server", controllers.CredentialTest) | ||
} |
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 @@ | ||
module github.com/limanmys/render-engine | ||
|
||
go 1.18 | ||
|
||
require ( | ||
github.com/gofiber/fiber/v2 v2.36.0 | ||
github.com/google/uuid v1.3.0 | ||
github.com/joho/godotenv v1.4.0 | ||
gorm.io/driver/mysql v1.3.6 | ||
gorm.io/driver/postgres v1.3.9 | ||
gorm.io/gorm v1.23.8 | ||
) | ||
|
||
require ( | ||
github.com/andybalholm/brotli v1.0.4 // indirect | ||
github.com/go-sql-driver/mysql v1.6.0 // indirect | ||
github.com/jackc/chunkreader/v2 v2.0.1 // indirect | ||
github.com/jackc/pgconn v1.13.0 // indirect | ||
github.com/jackc/pgio v1.0.0 // indirect | ||
github.com/jackc/pgpassfile v1.0.0 // indirect | ||
github.com/jackc/pgproto3/v2 v2.3.1 // indirect | ||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect | ||
github.com/jackc/pgtype v1.12.0 // indirect | ||
github.com/jackc/pgx/v4 v4.17.1 // indirect | ||
github.com/jinzhu/inflection v1.0.0 // indirect | ||
github.com/jinzhu/now v1.1.5 // indirect | ||
github.com/klauspost/compress v1.15.9 // indirect | ||
github.com/mervick/aes-everywhere/go/aes256 v0.0.0-20220722115308-bf92805fe805 | ||
github.com/valyala/bytebufferpool v1.0.0 // indirect | ||
github.com/valyala/fasthttp v1.39.0 // indirect | ||
github.com/valyala/tcplisten v1.0.0 // indirect | ||
golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d // indirect | ||
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64 // indirect | ||
golang.org/x/text v0.3.7 // indirect | ||
) |
Oops, something went wrong.