AY 4 years ago
parent
commit
3336e367c0
4 changed files with 63 additions and 1 deletions
  1. 3 1
      main.go
  2. 12 0
      mod/web/core.go
  3. BIN
      server/logs/2020-12-13-2 4.log.gz
  4. 48 0
      web.go

+ 3 - 1
main.go

@@ -9,7 +9,7 @@ import (
 )
 
 func main() {
-	server := server.NewHandler("java", "server.jar", "1024M", "1024M", "")
+	server := server.NewHandler("java", "server.jar", "256M", "256M", "")
 	server.StartService()
 	go func() {
 		i := 0
@@ -28,6 +28,8 @@ func main() {
 			}
 		}
 	}()
+
+	//auto stop
 	time.Sleep(50 * time.Second)
 	fmt.Println("STOP!!")
 	server.SendCommand("stop")

+ 12 - 0
mod/web/core.go

@@ -0,0 +1,12 @@
+package web
+
+//Handler is handler
+type Handler struct {
+}
+
+//NewHandler means everythign starts here :)
+func NewHandler(Dir string, Port string) *Handler {
+	NewlyCreatedHandler := Handler{}
+
+	return &NewlyCreatedHandler
+}

BIN
server/logs/2020-12-13-2 4.log.gz


+ 48 - 0
web.go

@@ -0,0 +1,48 @@
+package main
+
+import (
+	"log"
+	"net/http"
+)
+
+func webServer(Dir string, Port string) {
+	fs := http.FileServer(http.Dir(Dir))
+	http.Handle("/", fs)
+
+	//CORE FUNCTION
+	http.HandleFunc("/start", StartMCServer)
+	http.HandleFunc("/stop", StopMCServer)
+	http.HandleFunc("/kill", KillMCServer)
+	http.HandleFunc("/restart", RestartMCServer)
+	http.HandleFunc("/kickall", KickAllMCServer)
+
+	//SYSTEM FUNCTION
+	http.HandleFunc("/log", ReadLog)
+	http.HandleFunc("/ban-ip", ReadBanIP)
+	http.HandleFunc("/ban-player", ReadBanPlayer)
+	http.HandleFunc("/eula", ReadEULA)
+	http.HandleFunc("/ops", ReadOps)
+	http.HandleFunc("/properties", ReadProperties)
+	http.HandleFunc("/whitelist", ReadWhitelist)
+
+	//EDIT
+	http.HandleFunc("/eula/change", ChangeEULA)
+	http.HandleFunc("/properties/change", ChangeProperties)
+
+	//ADD
+	http.HandleFunc("/ban-ip/add", AddBanIP)
+	http.HandleFunc("/ban-player/add", AddBanPlayer)
+	http.HandleFunc("/ops/add", AddOps)
+	http.HandleFunc("/whitelist/add", AddWhitelist)
+
+	//REMOVE
+	http.HandleFunc("/ban-ip/remove", RemoveBanIP)
+	http.HandleFunc("/ban-player/remove", RemoveBanPlayer)
+	http.HandleFunc("/ops/remove", RemoveOps)
+	http.HandleFunc("/whitelist/remove", RemoveWhitelist)
+
+	err := http.ListenAndServe(":"+Port, nil)
+	if err != nil {
+		log.Fatal(err)
+	}
+}