mirror of
https://wiilab.wiimart.org/wiimart/WiiSOAP
synced 2025-09-05 21:11:02 +02:00
commit
257a177992
@ -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.
|
||||
|
@ -1,8 +1,8 @@
|
||||
<Config>
|
||||
<Address>127.0.0.1:8080</Address>
|
||||
|
||||
<SQLAddress>127.0.0.1:3306</SQLAddress>
|
||||
<SQLUser>uwu</SQLUser>
|
||||
<SQLPass>owo</SQLPass>
|
||||
<SQLDB>wiisoap</SQLDB>
|
||||
<SQLPort>127.0.0.1:3306</SQLPort>
|
||||
</Config>
|
5
go.mod
Normal file
5
go.mod
Normal file
@ -0,0 +1,5 @@
|
||||
module github.com/Apfel/WiiSOAP
|
||||
|
||||
go 1.12
|
||||
|
||||
require github.com/go-sql-driver/mysql v1.4.1
|
7
go.sum
Normal file
7
go.sum
Normal file
@ -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=
|
56
main.go
56
main.go
@ -38,40 +38,40 @@ const (
|
||||
Header = `<?xml version="1.0" encoding="UTF-8"?>` + "\n"
|
||||
)
|
||||
|
||||
// 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)
|
||||
// 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())
|
||||
}
|
||||
}
|
||||
|
||||
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")
|
||||
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.SQLPort, CON.SQLDB))
|
||||
CheckError(err)
|
||||
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.
|
||||
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? 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
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user