diff --git a/utils/xmltojson/README.md b/utils/xmltojson/README.md new file mode 100644 index 000000000..a8fec4a3a --- /dev/null +++ b/utils/xmltojson/README.md @@ -0,0 +1 @@ +Converts the old eqemu_config.xml to eqemu_config.json diff --git a/utils/xmltojson/build.bat b/utils/xmltojson/build.bat new file mode 100644 index 000000000..be0e60488 --- /dev/null +++ b/utils/xmltojson/build.bat @@ -0,0 +1,21 @@ +@echo off +setlocal +set name="xmltojson" + +echo Building Linux +set GOOS=linux +set GOARCH=amd64 +go build -o %name%-linux-x64 main.go +set GOARCH=386 +go build -o %name%-linux-x86 main.go +echo Building Windows +set GOOS=windows +set GOARCH=amd64 +go build -o %name%-windows-x64.exe main.go +set GOARCH=386 +go build -o %name%-windows-x86.exe main.go +echo Building OSX +REM set GOOS=darwin +REM set GOARCH=amd64 +REM go build -o %name%-osx-x64 main.go +endlocal \ No newline at end of file diff --git a/utils/xmltojson/build.sh b/utils/xmltojson/build.sh new file mode 100644 index 000000000..079822f14 --- /dev/null +++ b/utils/xmltojson/build.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e +export NAME="xmltojson" +echo Building Linux +GOOS=linux GOARCH=amd64 go build -o $NAME-linux-x64 main.go +GOOS=linux GOARCH=386 go build -o $NAME-linux-x86 main.go +echo Building Windows +GOOS=windows GOARCH=amd64 go build -o $NAME-windows-x64.exe main.go +GOOS=windows GOARCH=386 go build -o $NAME-windows-x86.exe main.go +#echo Building OSX +#GOOS=darwin GOARCH=amd64 go build -o $NAME-osx-x64 main.go \ No newline at end of file diff --git a/utils/xmltojson/eqemu_config.json b/utils/xmltojson/eqemu_config.json new file mode 100644 index 000000000..1703b208c --- /dev/null +++ b/utils/xmltojson/eqemu_config.json @@ -0,0 +1,71 @@ +{ + "server": { + "database": { + "port": "3306", + "username": "eqemu", + "password": "eqemupass", + "db": "eqemu", + "host": "mariadb" + }, + "qsdatabase": { + "host": "mariadb", + "port": "3306", + "username": "eqemu", + "password": "eqemupass", + "db": "eqemu" + }, + "webinterface": { + "port": "9081" + }, + "launcher": "", + "files": "", + "mailserver": { + "host": "", + "port": "7500" + }, + "chatserver": { + "host": "", + "port": "7500" + }, + "zones": { + "defaultstatus": "0", + "ports": { + "low": "7000", + "high": "7400" + } + }, + "directories": "", + "world": { + "key": "soif23oij423oij423ioj4", + "http": { + "port": "9080", + "enabled": "true", + "mimefile": "mime.types" + }, + "shortname": "deq", + "longname": "github.com/xackery/dockereq testing", + "loginserver1": { + "legacy": "1", + "host": "login.eqemulator.net", + "port": "5998", + "account": "", + "password": "" + }, + "loginserver2": { + "host": "mariadb", + "port": "5998", + "account": "", + "password": "" + }, + "tcp": { + "ip": "mariadb", + "port": "9001" + }, + "telnet": { + "ip": "mariadb", + "port": "9000", + "enabled": "true" + } + } + } +} diff --git a/utils/xmltojson/eqemu_config.xml b/utils/xmltojson/eqemu_config.xml new file mode 100644 index 000000000..d5a060c00 --- /dev/null +++ b/utils/xmltojson/eqemu_config.xml @@ -0,0 +1,75 @@ + + + + deq + github.com/xackery/dockereq testing + + + + 1 + login.eqemulator.net + 5998 + + + + + mariadb + 5998 + + + + + + + + + + soif23oij423oij423ioj4 + + + + + + + 7500 + + + + + 7500 + + + + 0 + + + + + + mariadb + 3306 + eqemu + eqemupass + eqemu + + + + mariadb + 3306 + eqemu + eqemupass + eqemu + + + + 9081 + + + + + + + + + + diff --git a/utils/xmltojson/main.go b/utils/xmltojson/main.go new file mode 100644 index 000000000..65dd052f5 --- /dev/null +++ b/utils/xmltojson/main.go @@ -0,0 +1,46 @@ +package main + +import ( + "bytes" + "encoding/json" + "fmt" + "io/ioutil" + "os" + "strings" + + xj "github.com/xackery/goxml2json" +) + +func main() { + var err error + var data []byte + var sData string + var buf *bytes.Buffer + var buf2 bytes.Buffer + xj.SetAttributePrefix("") + + if data, err = ioutil.ReadFile("eqemu_config.xml"); err != nil { + fmt.Println("Failed to open eqemu_config.xml:", err.Error()) + os.Exit(1) + } + + //detect malformed xml in eqemuconfig + sData = strings.Replace(string(data), "", "", 1) + + //convert xml to json + if buf, err = xj.Convert(strings.NewReader(sData)); err != nil { + fmt.Println("Failed to process eqemu_config.xml:", err.Error()) + os.Exit(1) + } + + //prettyprint + if err = json.Indent(&buf2, buf.Bytes(), "", "\t"); err != nil { + fmt.Println("Failed to encode json:", err.Error()) + os.Exit(1) + } + + if err = ioutil.WriteFile("eqemu_config.json", buf2.Bytes(), 0744); err != nil { + fmt.Println("Failed to write eqemu_config.json:", err.Error()) + os.Exit(1) + } +} diff --git a/utils/xmltojson/xmltojson-linux-x64 b/utils/xmltojson/xmltojson-linux-x64 new file mode 100644 index 000000000..c2e3e805b Binary files /dev/null and b/utils/xmltojson/xmltojson-linux-x64 differ diff --git a/utils/xmltojson/xmltojson-linux-x86 b/utils/xmltojson/xmltojson-linux-x86 new file mode 100644 index 000000000..8c1783c0a Binary files /dev/null and b/utils/xmltojson/xmltojson-linux-x86 differ diff --git a/utils/xmltojson/xmltojson-windows-x64 b/utils/xmltojson/xmltojson-windows-x64 new file mode 100644 index 000000000..9c598dcff Binary files /dev/null and b/utils/xmltojson/xmltojson-windows-x64 differ diff --git a/utils/xmltojson/xmltojson-windows-x86 b/utils/xmltojson/xmltojson-windows-x86 new file mode 100644 index 000000000..f25ae2a3c Binary files /dev/null and b/utils/xmltojson/xmltojson-windows-x86 differ