From fb3099169ee548d1797e3549996649278e31c4c9 Mon Sep 17 00:00:00 2001
From: Apfel <32610623+Apfel@users.noreply.github.com>
Date: Thu, 14 Mar 2019 02:56:18 +0100
Subject: [PATCH 1/6] fixed error handling
---
main.go | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/main.go b/main.go
index 2d6a052..ed86dfa 100644
--- a/main.go
+++ b/main.go
@@ -39,9 +39,9 @@ const (
)
// CheckError makes error handling not as ugly and inefficient.
-func CheckError(e error) {
- if e != nil {
- log.Fatal("WiiSOAP forgot how to drive and suddenly crashed! Reason: ", e)
+func CheckError(err error) {
+ if err != nil {
+ log.Fatalf("WiiSOAP forgot how to drive and suddenly crashed! Reason: %s\n", err.Error())
}
}
@@ -71,7 +71,7 @@ func main() {
CheckError(err)
// Start the HTTP server.
- fmt.Printf("Starting HTTP connection (%s)...\nNot using the usual port for HTTP? Be sure to use a proxy, otherwise the Wii can't connect!", CON.Address)
+ fmt.Printf("Starting HTTP connection (%s)...\nNot using the usual port for HTTP?\nBe sure to use a proxy, otherwise the Wii can't connect!\n", CON.Address)
http.HandleFunc("/", handler) // each request calls handler
log.Fatal(http.ListenAndServe(CON.Address, nil))
@@ -97,9 +97,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
case "CheckDeviceStatus":
fmt.Println("CDS.")
CDS := CDS{}
- if err = xml.Unmarshal(body, &CDS); os.IsExist(err) {
+ if err = xml.Unmarshal(body, &CDS); err != nil {
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
- fmt.Fprint(w, "You need to POST some SOAP from WSC if you wanna get some, honey. ;)")
+ fmt.Fprint(w, "You need to POST some SOAP from WSC if you wanna get some, honey. ;3")
return
}
fmt.Println(CDS)
@@ -131,9 +131,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
case "NotifiedETicketsSynced":
fmt.Println("NETS")
NETS := NETS{}
- if err = xml.Unmarshal(body, &NETS); os.IsExist(err) {
+ if err = xml.Unmarshal(body, &NETS); err != nil {
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
- fmt.Fprint(w, "This is a disgusting request, but 20 dollars is 20 dollars. ;)")
+ fmt.Fprint(w, "This is a disgusting request, but 20 dollars is 20 dollars. ;3")
fmt.Printf("error: %v", err)
return
}
@@ -159,9 +159,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
case "ListETickets":
fmt.Println("LET")
LET := LET{}
- if err = xml.Unmarshal(body, &LET); os.IsExist(err) {
+ if err = xml.Unmarshal(body, &LET); err != nil {
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
- fmt.Fprint(w, "This is a disgusting request, but 20 dollars is 20 dollars. ;)")
+ fmt.Fprint(w, "This is a disgusting request, but 20 dollars is 20 dollars. ;3")
fmt.Printf("error: %v", err)
return
}
@@ -190,9 +190,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
case "PurchaseTitle":
fmt.Println("PT")
PT := PT{}
- if err = xml.Unmarshal(body, &PT); os.IsExist(err) {
+ if err = xml.Unmarshal(body, &PT); err != nil {
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
- fmt.Fprint(w, "if you wanna fun time, its gonna cost ya extra sweetie. ;)")
+ fmt.Fprint(w, "if you wanna fun time, its gonna cost ya extra sweetie. ;3")
fmt.Printf("Error: %s", err.Error())
return
}
@@ -232,9 +232,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
case "CheckRegistration":
fmt.Println("CR.")
CR := CR{}
- if err = xml.Unmarshal(body, &CR); os.IsExist(err) {
+ if err = xml.Unmarshal(body, &CR); err != nil {
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
- fmt.Fprint(w, "not good enough for me. ;)")
+ fmt.Fprint(w, "not good enough for me. ;3")
fmt.Printf("Error: %s", err.Error())
return
}
@@ -262,9 +262,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
case "GetRegistrationInfo":
fmt.Println("GRI.")
GRI := GRI{}
- if err = xml.Unmarshal(body, &GRI); os.IsExist(err) {
+ if err = xml.Unmarshal(body, &GRI); err != nil {
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
- fmt.Fprint(w, "how dirty. ;)")
+ fmt.Fprint(w, "how dirty. ;3")
fmt.Printf("Error: %s", err.Error())
return
}
@@ -298,9 +298,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
case "Register":
fmt.Println("REG.")
REG := REG{}
- if err = xml.Unmarshal(body, ®); os.IsExist(err) {
+ if err = xml.Unmarshal(body, ®); err != nil {
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
- fmt.Fprint(w, "disgustingly invalid. ;)")
+ fmt.Fprint(w, "disgustingly invalid. ;3")
fmt.Printf("Error: %s", err.Error())
return
}
@@ -331,9 +331,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
case "Unregister":
fmt.Println("UNR.")
UNR := UNR{}
- if err = xml.Unmarshal(body, &UNR); os.IsExist(err) {
+ if err = xml.Unmarshal(body, &UNR); err != nil {
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
- fmt.Fprint(w, "how abnormal... ;)")
+ fmt.Fprint(w, "how abnormal... ;3")
fmt.Printf("Error: %s", err.Error())
return
}
From 1ebff33f5d67a43a4c24bceec8e9a6405bd00b11 Mon Sep 17 00:00:00 2001
From: Apfel <32610623+Apfel@users.noreply.github.com>
Date: Thu, 14 Mar 2019 02:56:29 +0100
Subject: [PATCH 2/6] added go.mod
---
go.mod | 5 +++++
go.sum | 7 +++++++
2 files changed, 12 insertions(+)
create mode 100644 go.mod
create mode 100644 go.sum
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..abc252d
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,5 @@
+module github.com/Apfel/WiiSOAP
+
+go 1.12
+
+require github.com/go-sql-driver/mysql v1.4.1
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..72d1518
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,7 @@
+github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
+github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
+google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
From 896cf1affaebb17e85bd1318c264a2c8b6b405f3 Mon Sep 17 00:00:00 2001
From: Apfel <32610623+Apfel@users.noreply.github.com>
Date: Thu, 14 Mar 2019 02:58:14 +0100
Subject: [PATCH 3/6] once again, a better name in the config
---
config.xml.example | 8 --------
main.go | 2 +-
structure.go | 8 ++++----
3 files changed, 5 insertions(+), 13 deletions(-)
delete mode 100644 config.xml.example
diff --git a/config.xml.example b/config.xml.example
deleted file mode 100644
index a49dfe9..0000000
--- a/config.xml.example
+++ /dev/null
@@ -1,8 +0,0 @@
-
- 127.0.0.1:8080
-
- uwu
- owo
- wiisoap
- 127.0.0.1:3306
-
diff --git a/main.go b/main.go
index ed86dfa..57a0a41 100644
--- a/main.go
+++ b/main.go
@@ -62,7 +62,7 @@ func main() {
fmt.Println("Initializing core...")
// Start SQL.
- db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s)", CON.SQLUser, CON.SQLPass, CON.SQLPort, CON.SQLDB))
+ db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s)", CON.SQLUser, CON.SQLPass, CON.SQLAddress, CON.SQLDB))
CheckError(err)
// Close SQL after everything else is done.
diff --git a/structure.go b/structure.go
index b1da01e..11b416c 100644
--- a/structure.go
+++ b/structure.go
@@ -30,10 +30,10 @@ type Config struct {
Address string `xml:"Address"`
- SQLUser string `xml:"SQLUser"`
- SQLPass string `xml:"SQLPass"`
- SQLPort string `xml:"SQLPort"`
- SQLDB string `xml:"SQLDB"`
+ SQLAddress string `xml:"SQLAddress"`
+ SQLUser string `xml:"SQLUser"`
+ SQLPass string `xml:"SQLPass"`
+ SQLDB string `xml:"SQLDB"`
}
// CDS - CheckDeviceStatus
From c6427795ef3823b6460efd2b354f0ecb1a5830f1 Mon Sep 17 00:00:00 2001
From: Apfel <32610623+Apfel@users.noreply.github.com>
Date: Thu, 14 Mar 2019 02:58:43 +0100
Subject: [PATCH 4/6] Moved the config example
---
config.example.xml | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 config.example.xml
diff --git a/config.example.xml b/config.example.xml
new file mode 100644
index 0000000..af1f1b1
--- /dev/null
+++ b/config.example.xml
@@ -0,0 +1,8 @@
+
+ 127.0.0.1:8080
+
+ 127.0.0.1:3306
+ uwu
+ owo
+ wiisoap
+
From e578d6e4d2942d95f31b9eacd933502a3927e165 Mon Sep 17 00:00:00 2001
From: Apfel <32610623+Apfel@users.noreply.github.com>
Date: Thu, 14 Mar 2019 02:59:20 +0100
Subject: [PATCH 5/6] no need to export this
---
main.go | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/main.go b/main.go
index 57a0a41..1a43e59 100644
--- a/main.go
+++ b/main.go
@@ -38,8 +38,8 @@ const (
Header = `` + "\n"
)
-// CheckError makes error handling not as ugly and inefficient.
-func CheckError(err error) {
+// checkError makes error handling not as ugly and inefficient.
+func checkError(err error) {
if err != nil {
log.Fatalf("WiiSOAP forgot how to drive and suddenly crashed! Reason: %s\n", err.Error())
}
@@ -51,24 +51,24 @@ func main() {
// Check the Config.
configfile, err := os.Open("./config.xml")
- CheckError(err)
+ checkError(err)
ioconfig, err := ioutil.ReadAll(configfile)
- CheckError(err)
+ checkError(err)
CON := Config{}
err = xml.Unmarshal([]byte(ioconfig), &CON)
fmt.Println(CON)
- CheckError(err)
+ checkError(err)
fmt.Println("Initializing core...")
// Start SQL.
db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s)", CON.SQLUser, CON.SQLPass, CON.SQLAddress, CON.SQLDB))
- CheckError(err)
+ checkError(err)
// Close SQL after everything else is done.
defer db.Close()
err = db.Ping()
- CheckError(err)
+ checkError(err)
// Start the HTTP server.
fmt.Printf("Starting HTTP connection (%s)...\nNot using the usual port for HTTP?\nBe sure to use a proxy, otherwise the Wii can't connect!\n", CON.Address)
From 62ab30fbe36ee44a1b518a76bb56f579270cbaa5 Mon Sep 17 00:00:00 2001
From: Apfel <32610623+Apfel@users.noreply.github.com>
Date: Thu, 14 Mar 2019 03:01:27 +0100
Subject: [PATCH 6/6] Bumped version
---
README.md | 6 ++++++
main.go | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 8ca94e3..ace9c81 100644
--- a/README.md
+++ b/README.md
@@ -7,6 +7,12 @@ This is the SOAP Server Software. The other repository only has the communicatio
# Changelog
Versions on this software are based on goals. (e.g 0.2 works towards SQL support. 0.3 works towards NUS support, etc.)
## 0.2.x Kawauso
+### 0.2.6
+*This version of WiiSOAP Server was brought to you by Apfel. Thank you for your contribution.*
+- Fixed error handling.
+- Moved configuration example.
+- Added `go.mod` for an easier installation.
+- Changed `SQLPort` to `SQLAddress` in the `config.xml` file.
### 0.2.5
*This version of WiiSOAP Server was brought to you by Apfel. Thank you for your contribution.*
- Fixed lint errors.
diff --git a/main.go b/main.go
index 1a43e59..1600d7b 100644
--- a/main.go
+++ b/main.go
@@ -47,7 +47,7 @@ func checkError(err error) {
func main() {
// Initial Start.
- fmt.Println("WiiSOAP 0.2.5 Kawauso\nReading the Config...")
+ fmt.Println("WiiSOAP 0.2.6 Kawauso\nReading the Config...")
// Check the Config.
configfile, err := os.Open("./config.xml")