Search in sources :

Example 11 with INode

use of games.strategy.net.INode in project triplea by triplea-game.

the class LobbyGamePanel method getLobbyWatcherNodeForTableRow.

private INode getLobbyWatcherNodeForTableRow(final int selectedIndex) {
    final GameDescription description = gameTableModel.get(gameTable.convertRowIndexToModel(selectedIndex));
    final String hostedByName = description.getHostedBy().getName();
    return new Node((hostedByName.endsWith("_" + InGameLobbyWatcher.LOBBY_WATCHER_NAME) ? hostedByName : hostedByName + "_" + InGameLobbyWatcher.LOBBY_WATCHER_NAME), description.getHostedBy().getAddress(), description.getHostedBy().getPort());
}
Also used : INode(games.strategy.net.INode) Node(games.strategy.net.Node) GameDescription(games.strategy.engine.lobby.server.GameDescription)

Example 12 with INode

use of games.strategy.net.INode in project triplea by triplea-game.

the class LobbyGamePanel method bootPlayerInHeadlessHostBot.

private void bootPlayerInHeadlessHostBot() {
    final int selectedIndex = gameTable.getSelectedRow();
    if (selectedIndex == -1) {
        return;
    }
    final int result = JOptionPane.showConfirmDialog(null, "Are you sure you want to perform a remote boot player on this host?", "Remote Player Boot Headless Host Bot", JOptionPane.OK_CANCEL_OPTION);
    if (result != JOptionPane.OK_OPTION) {
        return;
    }
    final String playerToBeBooted = JOptionPane.showInputDialog(getTopLevelAncestor(), "Player Name To Be Booted?", "Player Name To Be Booted?", JOptionPane.QUESTION_MESSAGE);
    if (playerToBeBooted == null) {
        return;
    }
    final INode lobbyWatcherNode = getLobbyWatcherNodeForTableRow(selectedIndex);
    final IModeratorController controller = (IModeratorController) messengers.getRemoteMessenger().getRemote(AbstractModeratorController.getModeratorControllerName());
    final JLabel label = new JLabel("Enter Host Remote Access Password, (Leave blank for no password).");
    final JPasswordField passwordField = new JPasswordField();
    final JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(label, BorderLayout.NORTH);
    panel.add(passwordField, BorderLayout.CENTER);
    final int selectedOption = JOptionPane.showOptionDialog(getTopLevelAncestor(), panel, "Host Remote Access Password?", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null);
    if (selectedOption != JOptionPane.OK_OPTION || passwordField.getPassword() == null) {
        return;
    }
    final String password = new String(passwordField.getPassword());
    final String salt = controller.getHeadlessHostBotSalt(lobbyWatcherNode);
    final String hashedPassword = hashPassword(password, salt);
    final String response = controller.bootPlayerHeadlessHostBot(lobbyWatcherNode, playerToBeBooted, hashedPassword, salt);
    JOptionPane.showMessageDialog(null, (response == null ? "Successfully attempted to boot player (" + playerToBeBooted + ") on host" : "Failed: " + response));
}
Also used : JPanel(javax.swing.JPanel) INode(games.strategy.net.INode) IModeratorController(games.strategy.engine.lobby.server.IModeratorController) BorderLayout(java.awt.BorderLayout) JPasswordField(javax.swing.JPasswordField) JLabel(javax.swing.JLabel)

Example 13 with INode

use of games.strategy.net.INode in project triplea by triplea-game.

the class LobbyGamePanel method mutePlayerInHeadlessHostBot.

private void mutePlayerInHeadlessHostBot() {
    final int selectedIndex = gameTable.getSelectedRow();
    if (selectedIndex == -1) {
        return;
    }
    final int result = JOptionPane.showConfirmDialog(null, "Are you sure you want to perform a remote mute player on this host?", "Remote Player Mute Headless Host Bot", JOptionPane.OK_CANCEL_OPTION);
    if (result != JOptionPane.OK_OPTION) {
        return;
    }
    final String playerToBeMuted = JOptionPane.showInputDialog(getTopLevelAncestor(), "Player Name To Be Muted?", "Player Name To Be Muted?", JOptionPane.QUESTION_MESSAGE);
    if (playerToBeMuted == null) {
        return;
    }
    final Object minutes = JOptionPane.showInputDialog(getTopLevelAncestor(), "Minutes to Mute for?  (between 0 and 2880, choose zero to unmute [works only if players is in the host])", "Minutes to Mute for?", JOptionPane.QUESTION_MESSAGE, null, null, 10);
    if (minutes == null) {
        return;
    }
    final int min;
    try {
        min = Math.max(0, Math.min(60 * 24 * 2, Integer.parseInt((String) minutes)));
    } catch (final NumberFormatException e) {
        return;
    }
    final INode lobbyWatcherNode = getLobbyWatcherNodeForTableRow(selectedIndex);
    final IModeratorController controller = (IModeratorController) messengers.getRemoteMessenger().getRemote(AbstractModeratorController.getModeratorControllerName());
    final JLabel label = new JLabel("Enter Host Remote Access Password, (Leave blank for no password).");
    final JPasswordField passwordField = new JPasswordField();
    final JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(label, BorderLayout.NORTH);
    panel.add(passwordField, BorderLayout.CENTER);
    final int selectedOption = JOptionPane.showOptionDialog(getTopLevelAncestor(), panel, "Host Remote Access Password?", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null);
    if (selectedOption != JOptionPane.OK_OPTION || passwordField.getPassword() == null) {
        return;
    }
    final String password = new String(passwordField.getPassword());
    final String salt = controller.getHeadlessHostBotSalt(lobbyWatcherNode);
    final String hashedPassword = hashPassword(password, salt);
    final String response = controller.mutePlayerHeadlessHostBot(lobbyWatcherNode, playerToBeMuted, min, hashedPassword, salt);
    JOptionPane.showMessageDialog(null, (response == null ? "Successfully attempted to mute player (" + playerToBeMuted + ") on host" : "Failed: " + response));
}
Also used : JPanel(javax.swing.JPanel) INode(games.strategy.net.INode) IModeratorController(games.strategy.engine.lobby.server.IModeratorController) BorderLayout(java.awt.BorderLayout) JPasswordField(javax.swing.JPasswordField) JLabel(javax.swing.JLabel)

Example 14 with INode

use of games.strategy.net.INode in project triplea by triplea-game.

the class LobbyGamePanel method bootGame.

private void bootGame() {
    final int selectedIndex = gameTable.getSelectedRow();
    if (selectedIndex == -1) {
        return;
    }
    final int result = JOptionPane.showConfirmDialog(null, "Are you sure you want to disconnect the selected game?", "Remove Game From Lobby", JOptionPane.OK_CANCEL_OPTION);
    if (result != JOptionPane.OK_OPTION) {
        return;
    }
    final INode lobbyWatcherNode = getLobbyWatcherNodeForTableRow(selectedIndex);
    final IModeratorController controller = (IModeratorController) messengers.getRemoteMessenger().getRemote(AbstractModeratorController.getModeratorControllerName());
    controller.boot(lobbyWatcherNode);
    JOptionPane.showMessageDialog(null, "The game you selected has been disconnected from the lobby.");
}
Also used : INode(games.strategy.net.INode) IModeratorController(games.strategy.engine.lobby.server.IModeratorController)

Example 15 with INode

use of games.strategy.net.INode in project triplea by triplea-game.

the class ModeratorController method getHeadlessHostBotSalt.

@Override
public String getHeadlessHostBotSalt(final INode node) {
    assertUserIsAdmin();
    if (serverMessenger.getServerNode().equals(node)) {
        throw new IllegalStateException("Cannot do this for server node");
    }
    final INode modNode = MessageContext.getSender();
    final String mac = getNodeMacAddress(node);
    logger.info(String.format("Getting salt for Headless HostBot. Host: %s IP: %s Mac: %s Mod Username: %s Mod IP: %s Mod Mac: %s", node.getName(), node.getAddress().getHostAddress(), mac, modNode.getName(), modNode.getAddress().getHostAddress(), getNodeMacAddress(modNode)));
    final RemoteName remoteName = RemoteHostUtils.getRemoteHostUtilsName(node);
    final IRemoteHostUtils remoteHostUtils = (IRemoteHostUtils) allMessengers.getRemoteMessenger().getRemote(remoteName);
    return remoteHostUtils.getSalt();
}
Also used : RemoteName(games.strategy.engine.message.RemoteName) INode(games.strategy.net.INode)

Aggregations

INode (games.strategy.net.INode)46 IModeratorController (games.strategy.engine.lobby.server.IModeratorController)10 RemoteName (games.strategy.engine.message.RemoteName)8 BorderLayout (java.awt.BorderLayout)8 JLabel (javax.swing.JLabel)7 JPanel (javax.swing.JPanel)7 JPasswordField (javax.swing.JPasswordField)5 IServerMessenger (games.strategy.net.IServerMessenger)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Node (games.strategy.net.Node)3 Dimension (java.awt.Dimension)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)3 JComboBox (javax.swing.JComboBox)3 Chat (games.strategy.engine.chat.Chat)2 GameRunner (games.strategy.engine.framework.GameRunner)2 IGamePlayer (games.strategy.engine.gamePlayer.IGamePlayer)2