Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Added ini configuration (#103)
Browse files Browse the repository at this point in the history
* improved file structure

* fixed stupid ts issue

* added ini structs

* INI

* switched int32 to int before its too late

* set duplicates correctly

* improvements

* moved everything to ini 🎉

* added startup warning

* added failsafe

* Update helpers.go

* Update server_controller_werr.go

* added a way load ini from ini file instead from json

* Update Administration.tsx

* added port back

#96 (comment)
  • Loading branch information
JensvandeWiel authored Nov 10, 2023
1 parent 4cb2a40 commit 487ba3c
Show file tree
Hide file tree
Showing 14 changed files with 1,206 additions and 248 deletions.
5 changes: 5 additions & 0 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ function App() {

}, []);

useEffect(() => {
EventsOn("reloadServers", getServers)
return () => EventsOff("reloadServers")
}, []);

//events
useEffect(() => {
EventsOn("serverSaved", getServers)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/InstallUpdater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function InstallUpdater({setServ, serv, onInstalled}: Props) {
const [installerModalOpen, setInstallerModalOpen] = useState(false)
const {addAlert} = useAlert()
function onServerPathClicked() {
OpenDirectoryDialog().then((val) => setServ((p) => ({ ...p, serverPath: val })))
OpenDirectoryDialog().then((val) => setServ((p) => ({ ...p, serverPath: val, convertValues: p.convertValues })))
}

function onStartInstallButtonClicked() {
Expand Down
40 changes: 38 additions & 2 deletions frontend/src/pages/Server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export const Server = ({id, className}: Props) => {
const [isInstalled, setIsInstalled] = useState(false)
const [serverStatus, setServerStatus] = useState(false)
const [forceStopModalOpen, setForceStopModalOpen] = useState(false)
const [startModalOpen, setStartModalOpen] = useState(false)

const [updaterModalOpen, setUpdaterModalOpen] = useState(false)
const {addAlert} = useAlert()

Expand Down Expand Up @@ -86,6 +88,15 @@ export const Server = ({id, className}: Props) => {
}
}, [serv]);

useEffect(() => {
EventsOn("reloadServers", () => {
if (id !== undefined) {
GetServer(id).then((s) => {setServ(s)}).catch((reason) => console.error(reason))
}
})
return () => EventsOff("reloadServers")
}, []);

//endregion

function onServerStartButtonClicked() {
Expand Down Expand Up @@ -147,7 +158,7 @@ export const Server = ({id, className}: Props) => {
{isInstalled? (<Tabs size="sm" className={'flex h-full w-full overflow-y-auto'}>
<div className={'h-16 flex w-full'}>
<div className="flex items-center">
<Input value={serv?.serverAlias} onChange={(e) => setServ((p) => ({ ...p, serverAlias: e.target.value }))}/>
<Input value={serv?.serverAlias} onChange={(e) => setServ((p) => ({ ...p, serverAlias: e.target.value, convertValues: p.convertValues }))}/>
<Tooltip title={"Open server install directory"}>
<IconButton className="text-lg font-bold ml-2" onClick={() => BrowserOpenURL("file:///" + serv.serverPath)}><IconExternalLink/></IconButton>
</Tooltip>
Expand All @@ -156,7 +167,7 @@ export const Server = ({id, className}: Props) => {

<div className={'ml-auto my-auto mr-8'}>
<ButtonGroup aria-label="outlined primary button group">
<Button color={'success'} variant="solid" disabled={serverStatus} onClick={onServerStartButtonClicked}>Start</Button>
<Button color={'success'} variant="solid" disabled={serverStatus} onClick={() => {serv?.useIniConfig? startServer() : setStartModalOpen(true)}}>Start</Button>
<Button color={'danger'} variant="solid" disabled={!serverStatus} onClick={onServerStopButtonClicked}>Stop</Button>
<Button color={'danger'} variant="solid" disabled={!serverStatus} onClick={() => setForceStopModalOpen(true)}>Force stop</Button>
</ButtonGroup>
Expand All @@ -182,6 +193,31 @@ export const Server = ({id, className}: Props) => {
</DialogActions>
</ModalDialog>
</Modal>
<Modal open={startModalOpen} onClose={() => setStartModalOpen(false)}>
<ModalDialog variant="outlined" role="alertdialog">
<DialogTitle>
<IconAlertCircleFilled/>
Confirmation
</DialogTitle>
<Divider />
<DialogContent>
Are you sure you want to start the server? This action will overwrite ini files in the server directory!<br/>
</DialogContent>
<DialogActions>
<Button variant="solid" color="success" onClick={() => {setStartModalOpen(false); onServerStartButtonClicked()}}>
Start
</Button>

<Button color="primary" onClick={() => setStartModalOpen(false)}>
Cancel
</Button>
<Button variant="plain" color="neutral" onClick={() => BrowserOpenURL("https://github.com/JensvandeWiel/ArkAscendedServerManager/wiki/Custom-Configuration")}>
More Info
</Button>

</DialogActions>
</ModalDialog>
</Modal>
</div>
</div>
<TabList className={'w-full'}>
Expand Down
25 changes: 21 additions & 4 deletions frontend/src/pages/server/Administration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
FormLabel,
Input, Modal,
ModalDialog,
TabPanel,
TabPanel, Tooltip,
Typography
} from "@mui/joy";
import React, {useState} from "react";
Expand Down Expand Up @@ -151,6 +151,7 @@ export function Administration({setServ, serv, onServerFilesDeleted}: Props) {
</DialogActions>
</ModalDialog>
</Modal>

<Button color='neutral' onClick={() => {
setShowServerCommandModalOpen(true)
return GetServerStartupCommand(serv.id)
Expand All @@ -169,16 +170,32 @@ export function Administration({setServ, serv, onServerFilesDeleted}: Props) {

<div className={'space-x-4 w-full flex'}>
<div className={'inline-block'}>
<Checkbox label="Disable update on server start" checked={serv?.disableUpdateOnStart} onChange={(e) => setServ((p) => ({ ...p, disableUpdateOnStart: e.target.checked }))} /><br/>
<Checkbox label="Disable update on server start" checked={serv?.disableUpdateOnStart} onChange={(e) => setServ((p) => ({ ...p, disableUpdateOnStart: e.target.checked, convertValues: p.convertValues }))} /><br/>
{/*<Checkbox label="Restart server on server quit" checked={serv?.restartOnServerQuit} onChange={(e) => setServ((p) => ({ ...p, restartOnServerQuit: e.target.checked }))} />*/}

<FormLabel>Custom server "dash" arguments (only use args like: -EnableIdlePlayerKick -ForceAllowCaveFlyers)</FormLabel>
<Input value={serv?.extraDashArgs} onChange={(e) => setServ((p) => ({ ...p, extraDashArgs: e.target.value }))}></Input>
<Input value={serv?.extraDashArgs} onChange={(e) => setServ((p) => ({ ...p, extraDashArgs: e.target.value, convertValues: p.convertValues }))}></Input>
<FormLabel>Custom server "questionmark" arguments (only use args like: ?PreventSpawnAnimations=true?PreventTribeAlliances=true)</FormLabel>
<Input value={serv?.extraQuestionmarkArguments} onChange={(e) => setServ((p) => ({ ...p, extraQuestionmarkArguments: e.target.value }))}></Input>
<Input value={serv?.extraQuestionmarkArguments} onChange={(e) => setServ((p) => ({ ...p, extraQuestionmarkArguments: e.target.value, convertValues: p.convertValues }))}></Input>
</div>
</div>
</Card>
<Card variant="soft" className={''}>
<Typography level="title-md">
Extra Settings
</Typography>
<Divider className={'mx-2'}/>

<div className={'space-x-4 w-full flex'}>
<div className={'inline-block'}>
<Tooltip title={"Loads server config form ini first instead of json"}>
<Checkbox label="Use ini config (only reloads on server start) (not recommended)" checked={serv?.useIniConfig} onChange={(e) => setServ((p) => ({ ...p, useIniConfig: e.target.checked, convertValues: p.convertValues }))} />

</Tooltip>
</div>
</div>
</Card>

</TabPanel>
);
}
17 changes: 9 additions & 8 deletions frontend/src/pages/server/General.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ export function General({serv, setServ}: Props) {
*/}

<FormLabel>Server Name:</FormLabel>
<Input className={'w-2/3'} required value={serv?.serverName} onChange={(e) => setServ((p) => ({ ...p, serverName: e.target.value }))} ></Input>
<Input className={'w-2/3'} required value={serv?.serverName} onChange={(e) => setServ((p) => ({ ...p, serverName: e.target.value, convertValues: p.convertValues }))} ></Input>
<div className={'space-x-4 w-full flex'}>
<div className={'inline-block'}>
<FormLabel>Server Password:</FormLabel>
<PasswordInput value={serv?.serverPassword} disabled={true} onChange={(e) => setServ((p) => ({ ...p, serverPassword: e.target.value }))} ></PasswordInput>
<PasswordInput value={serv?.serverPassword} disabled={true} onChange={(e) => setServ((p) => ({ ...p, serverPassword: e.target.value, convertValues: p.convertValues }))} ></PasswordInput>
</div>
<div className={'inline-block'}>
<FormLabel>Admin Password:</FormLabel>
<PasswordInput value={serv?.adminPassword} onChange={(e) => setServ((p) => ({ ...p, adminPassword: e.target.value }))} ></PasswordInput>
<PasswordInput value={serv?.adminPassword} onChange={(e) => setServ((p) => ({ ...p, adminPassword: e.target.value, convertValues: p.convertValues }))} ></PasswordInput>
</div>
<div className={'inline-block'}>
<FormLabel>Spectator Password:</FormLabel>
<PasswordInput value={serv?.spectatorPassword} disabled={true} onChange={(e) => setServ((p) => ({ ...p, spectatorPassword: e.target.value }))} ></PasswordInput>
<PasswordInput value={serv?.spectatorPassword} disabled={true} onChange={(e) => setServ((p) => ({ ...p, spectatorPassword: e.target.value, convertValues: p.convertValues }))} ></PasswordInput>
</div>
</div>
</Card>
Expand All @@ -87,7 +87,8 @@ export function General({serv, setServ}: Props) {
prevState =>{
return{
...prevState,
ipAddress: newValue?? "0.0.0.0"
ipAddress: newValue?? "0.0.0.0",
convertValues: prevState.convertValues
}
}
)
Expand All @@ -100,19 +101,19 @@ export function General({serv, setServ}: Props) {
<div className={'space-x-4 w-11/12'}>
<div className={'w-32 inline-block'}>
<FormLabel>Server Port:</FormLabel>
<Input className={''} type={'number'} required value={serv?.serverPort} onChange={(e) => (parseInt(e.target.value) >= 1 && parseInt(e.target.value) <= 65535) ? setServ((p) => ({ ...p, serverPort: parseInt(e.target.value), peerPort: parseInt(e.target.value) + 1 })) : null} ></Input>
<Input className={''} type={'number'} required value={serv?.serverPort} onChange={(e) => (parseInt(e.target.value) >= 1 && parseInt(e.target.value) <= 65535) ? setServ((p) => ({ ...p, serverPort: parseInt(e.target.value), peerPort: parseInt(e.target.value) + 1, convertValues: p.convertValues })) : null} ></Input>
</div>
<div className={'w-32 inline-block'}>
<FormLabel>Peer Port:</FormLabel>
<Input className={''} disabled type={'number'} value={serv.peerPort} ></Input>
</div>
<div className={'w-32 inline-block'}>
<FormLabel>Query Port:</FormLabel>
<Input className={''} type={'number'} value={serv?.queryPort} onChange={(e) => (parseInt(e.target.value) >= 1 && parseInt(e.target.value) <= 65535) ? setServ((p) => ({ ...p, queryPort: parseInt(e.target.value)})) : null}></Input>
<Input className={''} type={'number'} value={serv?.queryPort} onChange={(e) => (parseInt(e.target.value) >= 1 && parseInt(e.target.value) <= 65535) ? setServ((p) => ({ ...p, queryPort: parseInt(e.target.value), convertValues: p.convertValues})) : null}></Input>
</div>
<div className={'w-32 inline-block'}>
<FormLabel>RCON Port:</FormLabel>
<Input className={''} value={serv?.rconPort} onChange={(e) => (parseInt(e.target.value) >= 1 && parseInt(e.target.value) <= 65535) ? setServ((p) => ({ ...p, rconPort: parseInt(e.target.value)})) : null} type={'number'}></Input >
<Input className={''} value={serv?.rconPort} onChange={(e) => (parseInt(e.target.value) >= 1 && parseInt(e.target.value) <= 65535) ? setServ((p) => ({ ...p, rconPort: parseInt(e.target.value), convertValues: p.convertValues})) : null} type={'number'}></Input >
</div>
</div>
</Card>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/server/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export function Settings({setServ, serv}: Props) {
<div className={'space-x-4 w-full flex'}>
<div className={'inline-block'}>
<FormLabel>Mods (e.g.: modid1,modid2,modid3) (for now you need to set "ACTIVEMODS" to ini manually)</FormLabel>
<Input className={"w-[60vw]"} value={serv?.mods} onChange={(e) => setServ((p) => ({ ...p, mods: e.target.value }))}></Input>
<Input className={"w-[60vw]"} value={serv?.mods} onChange={(e) => setServ((p) => ({ ...p, mods: e.target.value, convertValues: p.convertValues }))}></Input>
<FormLabel>Player limit</FormLabel>
<Input className={"w-3/12"} value={serv?.maxPlayers} type={"number"} onChange={(e) => {
if (parseInt(e.target.value) > 0) {
setServ((p) => ({...p, maxPlayers: parseInt(e.target.value)}))
setServ((p) => ({...p, maxPlayers: parseInt(e.target.value), convertValues: p.convertValues}))
}}}></Input>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.18

require (
github.com/adrg/xdg v0.4.0
github.com/go-ini/ini v1.67.0
github.com/gorcon/rcon v1.3.4
github.com/hashicorp/go-version v1.6.0
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3IS
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorcon/rcon v1.3.4 h1:TExNhWI2mJlqpCg49vajUgznvEZbEzQWKujY1Sy+/AY=
github.com/gorcon/rcon v1.3.4/go.mod h1:46+oSXgPwlRAkcAPStkNnIL1dlcxJweKVNWshy3hDJI=
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf h1:WfD7VjIE6z8dIvMsI4/s+1qr5EL+zoIGev1BQj1eoJ8=
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf/go.mod h1:hyb9oH7vZsitZCiBt0ZvifOrB+qc8PS5IiilCIb87rg=
github.com/gorcon/rcon v1.3.4 h1:TExNhWI2mJlqpCg49vajUgznvEZbEzQWKujY1Sy+/AY=
github.com/gorcon/rcon v1.3.4/go.mod h1:46+oSXgPwlRAkcAPStkNnIL1dlcxJweKVNWshy3hDJI=
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck=
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
github.com/jensvandewiel/gosteamcmd v0.1.2 h1:NHichoj0v3GvSVN2Fn36dSOLosHAytpaKnLnDHTMQPI=
Expand Down
Loading

0 comments on commit 487ba3c

Please sign in to comment.