mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 10:31:29 +00:00
Added xmltojson
This commit is contained in:
parent
ec00daa5be
commit
9296f2bdc5
1
utils/xmltojson/README.md
Normal file
1
utils/xmltojson/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
Converts the old eqemu_config.xml to eqemu_config.json
|
||||||
21
utils/xmltojson/build.bat
Normal file
21
utils/xmltojson/build.bat
Normal file
@ -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
|
||||||
11
utils/xmltojson/build.sh
Normal file
11
utils/xmltojson/build.sh
Normal file
@ -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
|
||||||
71
utils/xmltojson/eqemu_config.json
Normal file
71
utils/xmltojson/eqemu_config.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
75
utils/xmltojson/eqemu_config.xml
Normal file
75
utils/xmltojson/eqemu_config.xml
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<server>
|
||||||
|
<world>
|
||||||
|
<shortname>deq</shortname>
|
||||||
|
<longname>github.com/xackery/dockereq testing</longname>
|
||||||
|
|
||||||
|
|
||||||
|
<loginserver1>
|
||||||
|
<legacy>1</legacy>
|
||||||
|
<host>login.eqemulator.net</host>
|
||||||
|
<port>5998</port>
|
||||||
|
<account></account>
|
||||||
|
<password></password>
|
||||||
|
</loginserver1>
|
||||||
|
<loginserver2>
|
||||||
|
<host>mariadb</host>
|
||||||
|
<port>5998</port>
|
||||||
|
<account></account>
|
||||||
|
<password></password>
|
||||||
|
</loginserver2>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<tcp ip="mariadb" port="9001"/>
|
||||||
|
<telnet ip="mariadb" port="9000" enabled="true"/>
|
||||||
|
|
||||||
|
<key>soif23oij423oij423ioj4</key>
|
||||||
|
|
||||||
|
<http port="9080" enabled="true" mimefile="mime.types" />
|
||||||
|
</world>
|
||||||
|
|
||||||
|
<chatserver>
|
||||||
|
<host></host>
|
||||||
|
<port>7500</port>
|
||||||
|
</chatserver>
|
||||||
|
|
||||||
|
<mailserver>
|
||||||
|
<host></host>
|
||||||
|
<port>7500</port>
|
||||||
|
</mailserver>
|
||||||
|
|
||||||
|
<zones>
|
||||||
|
<defaultstatus>0</defaultstatus>
|
||||||
|
|
||||||
|
<ports low="7000" high="7400"/>
|
||||||
|
</zones>
|
||||||
|
|
||||||
|
<database>
|
||||||
|
<host>mariadb</host>
|
||||||
|
<port>3306</port>
|
||||||
|
<username>eqemu</username>
|
||||||
|
<password>eqemupass</password>
|
||||||
|
<db>eqemu</db>
|
||||||
|
</database>
|
||||||
|
|
||||||
|
<qsdatabase>
|
||||||
|
<host>mariadb</host>
|
||||||
|
<port>3306</port>
|
||||||
|
<username>eqemu</username>
|
||||||
|
<password>eqemupass</password>
|
||||||
|
<db>eqemu</db>
|
||||||
|
</qsdatabase>
|
||||||
|
|
||||||
|
<webinterface>
|
||||||
|
<port>9081</port>
|
||||||
|
</webinterface>
|
||||||
|
|
||||||
|
<launcher>
|
||||||
|
</launcher>
|
||||||
|
|
||||||
|
<files>
|
||||||
|
</files>
|
||||||
|
<directories>
|
||||||
|
</directories>
|
||||||
|
</server>
|
||||||
46
utils/xmltojson/main.go
Normal file
46
utils/xmltojson/main.go
Normal file
@ -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), "<?xml version=\"1.0\">", "<?xml version=\"1.0\"?>", 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
utils/xmltojson/xmltojson-linux-x64
Normal file
BIN
utils/xmltojson/xmltojson-linux-x64
Normal file
Binary file not shown.
BIN
utils/xmltojson/xmltojson-linux-x86
Normal file
BIN
utils/xmltojson/xmltojson-linux-x86
Normal file
Binary file not shown.
BIN
utils/xmltojson/xmltojson-windows-x64
Normal file
BIN
utils/xmltojson/xmltojson-windows-x64
Normal file
Binary file not shown.
BIN
utils/xmltojson/xmltojson-windows-x86
Normal file
BIN
utils/xmltojson/xmltojson-windows-x86
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user