From 071173819549cb696933b5598577f01f919d49ab Mon Sep 17 00:00:00 2001
From: <29165304+Dot-Rar@users.noreply.github.com>
Date: Fri, 22 Mar 2019 16:43:31 +0000
Subject: [PATCH] Add files
---
.gitignore | 1 +
.idea/PanelV2.iml | 9 ++
.idea/misc.xml | 9 ++
.idea/modules.xml | 8 ++
.idea/workspace.xml | 231 ++++++++++++++++++++++++++++++++++++++++++++
cmd/panel/main.go | 7 ++
config.toml.example | 27 ++++++
config/config.go | 68 +++++++++++++
http/server.go | 18 ++++
9 files changed, 378 insertions(+)
create mode 100644 .gitignore
create mode 100644 .idea/PanelV2.iml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/workspace.xml
create mode 100644 cmd/panel/main.go
create mode 100644 config.toml.example
create mode 100644 config/config.go
create mode 100644 http/server.go
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5b6c096
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+config.toml
diff --git a/.idea/PanelV2.iml b/.idea/PanelV2.iml
new file mode 100644
index 0000000..5e764c4
--- /dev/null
+++ b/.idea/PanelV2.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..0ecb5c3
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..d05a90e
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..a9ca449
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,231 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/cmd/panel/main.go b/cmd/panel/main.go
new file mode 100644
index 0000000..e8f78df
--- /dev/null
+++ b/cmd/panel/main.go
@@ -0,0 +1,7 @@
+package main
+
+import "github.com/TicketsBot/PanelV2/config"
+
+func main() {
+ config.LoadConfig()
+}
diff --git a/config.toml.example b/config.toml.example
new file mode 100644
index 0000000..742b39b
--- /dev/null
+++ b/config.toml.example
@@ -0,0 +1,27 @@
+[server]
+host="0.0.0.0:3000"
+baseUrl="http://localhost:3000"
+mainSite="https://ticketsbot.net"
+ [server.ratelimit]
+ window=10
+ max=600
+ [server.session]
+ database="session"
+
+[oauth]
+id=1
+secret="secret"
+
+[mariadb]
+host="127.0.0.1"
+username="root"
+password="root"
+database="tickets"
+threads=5
+
+[bot]
+key=""
+httpServers=[]
+
+[redis]
+uri="redis://:pwd@127.0.0.1:6379/0"
diff --git a/config/config.go b/config/config.go
new file mode 100644
index 0000000..92a7ae1
--- /dev/null
+++ b/config/config.go
@@ -0,0 +1,68 @@
+package config
+
+import (
+ "github.com/BurntSushi/toml"
+ "io/ioutil"
+)
+
+type(
+ Config struct {
+ Server Server
+ Oauth Oauth
+ Bot Bot
+ Redis Redis
+ }
+
+ Server struct {
+ Host string
+ BaseUrl string
+ MainSite string
+ Ratelimit Ratelimit
+ Session Session
+ }
+
+ Ratelimit struct {
+ Window int
+ Max int
+ }
+
+ Session struct {
+ Database string
+ }
+
+ Oauth struct {
+ Id int64
+ Secret string
+ }
+
+ MariaDB struct {
+ Host string
+ Username string
+ Password string
+ Database string
+ Threads int
+ }
+
+ Bot struct {
+ Key string
+ HttpServer []string
+ }
+
+ Redis struct {
+ Uri string
+ }
+)
+
+var(
+ Conf Config
+)
+
+func LoadConfig() {
+ raw, err := ioutil.ReadFile("config.toml"); if err != nil {
+ panic(err)
+ }
+
+ _, err = toml.Decode(string(raw), &Conf); if err != nil {
+ panic(err)
+ }
+}
diff --git a/http/server.go b/http/server.go
new file mode 100644
index 0000000..3760de2
--- /dev/null
+++ b/http/server.go
@@ -0,0 +1,18 @@
+package http
+
+import (
+ "github.com/TicketsBot/PanelV2/config"
+ "github.com/qiangxue/fasthttp-routing"
+ "github.com/valyala/fasthttp"
+ "log"
+)
+
+func StartServer() {
+ log.Println("Starting HTTP server")
+
+ router := routing.New()
+
+ err := fasthttp.ListenAndServe(config.Conf.Server.Host, router.HandleRequest); if err != nil {
+ panic(err)
+ }
+}