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

This commit is contained in:
CornierKhan1 2018-10-18 16:49:29 +11:00
parent c5454ab7c2
commit 7734e5d911
4 changed files with 46 additions and 0 deletions

5
config.json Normal file
View File

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

16
core.go Normal file
View File

@ -0,0 +1,16 @@
package main
import (
"database/sql"
_ "github.com/go-sql-driver/mysql"
"log"
)
func StartSQL() {
db, err := sql.Open("mysql",
"opensoap:@tcp(127.0.0.1:3306)/hello")
if err != nil {
log.Fatal(err)
}
defer db.Close()
}

19
main.go
View File

@ -19,8 +19,10 @@ package main
import ( import (
"bytes" "bytes"
"encoding/json"
"encoding/xml" "encoding/xml"
"fmt" "fmt"
_ "github.com/go-sql-driver/mysql"
"io/ioutil" "io/ioutil"
"log" "log"
"net/http" "net/http"
@ -35,7 +37,24 @@ 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.
func CheckError(e error) {
if e != nil {
log.Fatal("There has been an error while performing this action. Reason: ", e)
}
}
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("Initializing core...")
fmt.Println("Starting HTTP connection (Port 2018)...") fmt.Println("Starting HTTP connection (Port 2018)...")
fmt.Println("NOTICE: The SOAP Server runs under a port that doesn't work with WSC naturally.") fmt.Println("NOTICE: The SOAP Server runs under a port that doesn't work with WSC naturally.")
fmt.Println("You can either use proxying from Nginx (recommended) or another web server software, or edit this script to use port 80.") fmt.Println("You can either use proxying from Nginx (recommended) or another web server software, or edit this script to use port 80.")

View File

@ -24,6 +24,12 @@ 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 {
SQLUser string
SQLPass string
Port string
}
// CheckDeviceStatus // CheckDeviceStatus
type CDS struct { type CDS struct {
XMLName xml.Name `xml:"Envelope"` XMLName xml.Name `xml:"Envelope"`