It's messy rn, but I'll clean it up. uwu

This commit is contained in:
CornierKhan1 2018-11-09 16:46:05 +11:00
parent 7734e5d911
commit ffb6d4d1ff
4 changed files with 18 additions and 15 deletions

View File

@ -1,5 +0,0 @@
{
"SQLUser":"username",
"SQLPass":"password",
"Port":"2018"
}

5
config.xml Normal file
View File

@ -0,0 +1,5 @@
<SOAP-GO-WSC_Config>
<SQLUser>uwu</SQLUser>
<SQLPass>owo</SQLPass>
<Port>nou</Port>
</SOAP-GO-WSC_Config>

16
main.go
View File

@ -19,13 +19,13 @@ package main
import ( import (
"bytes" "bytes"
"encoding/json"
"encoding/xml" "encoding/xml"
"fmt" "fmt"
_ "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql"
"io/ioutil" "io/ioutil"
"log" "log"
"net/http" "net/http"
"os"
"strconv" "strconv"
"time" "time"
) )
@ -37,8 +37,6 @@ const (
Header = `<?xml version="1.0" encoding="UTF-8"?>` + "\n" Header = `<?xml version="1.0" encoding="UTF-8"?>` + "\n"
) )
var configs []Config
// CheckError makes error handling not as ugly and inefficient. // CheckError makes error handling not as ugly and inefficient.
func CheckError(e error) { func CheckError(e error) {
if e != nil { if e != nil {
@ -47,12 +45,16 @@ func CheckError(e error) {
} }
func main() { func main() {
configblob, err := ioutil.ReadFile("config.json")
CheckError(err)
err = json.Unmarshal(configblob, &configs)
CheckError(err)
fmt.Println("Open SOAP-GO for Server Environments.") fmt.Println("Open SOAP-GO for Server Environments.")
fmt.Println("Reading the Config...")
configfile, err := os.Open("./config.xml")
CheckError(err)
ioconfig, err := ioutil.ReadAll(configfile)
CheckError(err)
err = xml.Unmarshal(ioconfig, &Config{})
fmt.Println(Config{})
CheckError(err)
fmt.Println("Initializing core...") fmt.Println("Initializing core...")
fmt.Println("Starting HTTP connection (Port 2018)...") fmt.Println("Starting HTTP connection (Port 2018)...")

View File

@ -25,9 +25,10 @@ import "encoding/xml"
// The structures may seem repetitive and redundant, but blame WSC's inconsistent SOAP requests. // The structures may seem repetitive and redundant, but blame WSC's inconsistent SOAP requests.
type Config struct { type Config struct {
SQLUser string XMLName xml.Name `xml:"SOAP-GO-WSC_Config"`
SQLPass string SQLUser string `xml:"SQLUser"`
Port string SQLPass string `xml:"SQLPass"`
Port string `xml:"Port"`
} }
// CheckDeviceStatus // CheckDeviceStatus