mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-03-08 11:29:19 +01:00
REMOTE: Added possibility to change target IP of remote API (#943)
This commit is contained in:
@ -7,12 +7,18 @@ import { isRemoteFileApiConnectionLive, newRemoteFileApiConnection } from "../..
|
|||||||
|
|
||||||
export const RemoteAPIPage = (): React.ReactElement => {
|
export const RemoteAPIPage = (): React.ReactElement => {
|
||||||
const [remoteFileApiPort, setRemoteFileApiPort] = useState(Settings.RemoteFileApiPort);
|
const [remoteFileApiPort, setRemoteFileApiPort] = useState(Settings.RemoteFileApiPort);
|
||||||
|
const [remoteFileApiAddress, setRemoteFileApiAddress] = useState(Settings.RemoteFileApiAddress);
|
||||||
|
|
||||||
function handleRemoteFileApiPortChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
function handleRemoteFileApiPortChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
||||||
setRemoteFileApiPort(Number(event.target.value));
|
setRemoteFileApiPort(Number(event.target.value));
|
||||||
Settings.RemoteFileApiPort = Number(event.target.value);
|
Settings.RemoteFileApiPort = Number(event.target.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleRemoteFileApiAddressChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
||||||
|
setRemoteFileApiAddress(String(event.target.value));
|
||||||
|
Settings.RemoteFileApiAddress = String(event.target.value);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GameOptionsPage title="Remote API">
|
<GameOptionsPage title="Remote API">
|
||||||
<Typography>
|
<Typography>
|
||||||
@ -31,7 +37,27 @@ export const RemoteAPIPage = (): React.ReactElement => {
|
|||||||
<Tooltip
|
<Tooltip
|
||||||
title={
|
title={
|
||||||
<Typography>
|
<Typography>
|
||||||
This port number is used to connect to a Remote API port, please ensure that it matches with your Remote API
|
This address is used to connect to a Remote API, please ensure that it matches with your Remote API address.
|
||||||
|
Default localhost.
|
||||||
|
</Typography>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<TextField
|
||||||
|
key={"remoteAPIAddress"}
|
||||||
|
InputProps={{
|
||||||
|
startAdornment: <Typography>Address: </Typography>,
|
||||||
|
}}
|
||||||
|
value={remoteFileApiAddress}
|
||||||
|
onChange={handleRemoteFileApiAddressChange}
|
||||||
|
placeholder="localhost"
|
||||||
|
size={"medium"}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
<br />
|
||||||
|
<Tooltip
|
||||||
|
title={
|
||||||
|
<Typography>
|
||||||
|
This port number is used to connect to a Remote API, please ensure that it matches with your Remote API
|
||||||
server port. Set to 0 to disable the feature.
|
server port. Set to 0 to disable the feature.
|
||||||
</Typography>
|
</Typography>
|
||||||
}
|
}
|
||||||
@ -44,13 +70,15 @@ export const RemoteAPIPage = (): React.ReactElement => {
|
|||||||
Port:
|
Port:
|
||||||
</Typography>
|
</Typography>
|
||||||
),
|
),
|
||||||
endAdornment: <Button onClick={newRemoteFileApiConnection}>Connect</Button>,
|
|
||||||
}}
|
}}
|
||||||
value={remoteFileApiPort}
|
value={remoteFileApiPort}
|
||||||
onChange={handleRemoteFileApiPortChange}
|
onChange={handleRemoteFileApiPortChange}
|
||||||
placeholder="12525"
|
placeholder="12525"
|
||||||
|
size={"medium"}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
<br />
|
||||||
|
<Button onClick={newRemoteFileApiConnection}>Connect</Button>
|
||||||
</GameOptionsPage>
|
</GameOptionsPage>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -5,8 +5,11 @@ let server: Remote;
|
|||||||
|
|
||||||
export function newRemoteFileApiConnection(): void {
|
export function newRemoteFileApiConnection(): void {
|
||||||
if (server) server.stopConnection();
|
if (server) server.stopConnection();
|
||||||
if (Settings.RemoteFileApiPort === 0) return;
|
if (Settings.RemoteFileApiPort === 0 || Settings.RemoteFileApiPort > 65535) return;
|
||||||
server = new Remote("localhost", Settings.RemoteFileApiPort);
|
server = new Remote(
|
||||||
|
Settings.RemoteFileApiAddress === "" ? "localhost" : Settings.RemoteFileApiAddress,
|
||||||
|
Settings.RemoteFileApiPort,
|
||||||
|
);
|
||||||
server.startConnection();
|
server.startConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,8 @@ export const Settings = {
|
|||||||
MaxPortCapacity: 50,
|
MaxPortCapacity: 50,
|
||||||
/** Limit the number of entries in the terminal. */
|
/** Limit the number of entries in the terminal. */
|
||||||
MaxTerminalCapacity: 500,
|
MaxTerminalCapacity: 500,
|
||||||
|
/** IP address the Remote File API client will try to connect to. Default localhost . */
|
||||||
|
RemoteFileApiAddress: "localhost",
|
||||||
/** Port the Remote File API client will try to connect to. 0 to disable. */
|
/** Port the Remote File API client will try to connect to. 0 to disable. */
|
||||||
RemoteFileApiPort: 0,
|
RemoteFileApiPort: 0,
|
||||||
/** Whether to save the game when the player saves any file. */
|
/** Whether to save the game when the player saves any file. */
|
||||||
|
Reference in New Issue
Block a user