Search in sources :

Example 6 with IServerMessenger

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

the class HeadlessGameServer method remoteMutePlayer.

public String remoteMutePlayer(final String playerName, final int minutes, final String hashedPassword, final String salt) {
    final String password = System.getProperty(LOBBY_GAME_SUPPORT_PASSWORD, "");
    if (password.equals(GameRunner.NO_REMOTE_REQUESTS_ALLOWED)) {
        return "Host not accepting remote requests!";
    }
    final String localPassword = System.getProperty(LOBBY_GAME_SUPPORT_PASSWORD, "");
    // (48 hours max)
    final Instant expire = Instant.now().plus(Duration.ofMinutes(Math.min(60 * 24 * 2, minutes)));
    if (hashPassword(localPassword, salt).equals(hashedPassword)) {
        new Thread(() -> {
            if (getServerModel() == null) {
                return;
            }
            final IServerMessenger messenger = getServerModel().getMessenger();
            if (messenger == null) {
                return;
            }
            final Set<INode> nodes = messenger.getNodes();
            if (nodes == null) {
                return;
            }
            try {
                for (final INode node : nodes) {
                    final String realName = node.getName().split(" ")[0];
                    final String ip = node.getAddress().getHostAddress();
                    final String mac = messenger.getPlayerMac(node.getName());
                    if (realName.equals(playerName)) {
                        System.out.println("Remote Mute of Player: " + playerName);
                        messenger.notifyUsernameMutingOfPlayer(realName, expire);
                        messenger.notifyIpMutingOfPlayer(ip, expire);
                        messenger.notifyMacMutingOfPlayer(mac, expire);
                        return;
                    }
                }
            } catch (final Exception e) {
                logger.log(Level.SEVERE, "Failed to notify mute of player", e);
            }
        }).start();
        return null;
    }
    System.out.println("Attempted remote mute player with invalid password.");
    return "Invalid password!";
}
Also used : INode(games.strategy.net.INode) Set(java.util.Set) HashSet(java.util.HashSet) Instant(java.time.Instant) IServerMessenger(games.strategy.net.IServerMessenger)

Example 7 with IServerMessenger

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

the class ServerSetupPanel method createComponents.

private void createComponents() {
    final IServerMessenger messenger = model.getMessenger();
    final Color backGround = new JTextField().getBackground();
    portField = new JTextField("" + messenger.getLocalNode().getPort());
    portField.setEnabled(true);
    portField.setEditable(false);
    portField.setBackground(backGround);
    portField.setColumns(6);
    addressField = new JTextField(messenger.getLocalNode().getAddress().getHostAddress());
    addressField.setEnabled(true);
    addressField.setEditable(false);
    addressField.setBackground(backGround);
    addressField.setColumns(20);
    nameField = new JTextField(messenger.getLocalNode().getName());
    nameField.setEnabled(true);
    nameField.setEditable(false);
    nameField.setBackground(backGround);
    nameField.setColumns(20);
    info = new JPanel();
    networkPanel = new JPanel();
}
Also used : JPanel(javax.swing.JPanel) Color(java.awt.Color) IServerMessenger(games.strategy.net.IServerMessenger) JTextField(javax.swing.JTextField)

Example 8 with IServerMessenger

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

the class ChatController method deactivate.

// clean up
public void deactivate() {
    pingThread.shutdown();
    synchronized (mutex) {
        final IChatChannel chatter = getChatBroadcaster();
        for (final INode node : chatters.keySet()) {
            version++;
            chatter.speakerRemoved(node, version);
        }
        remoteMessenger.unregisterRemote(getChatControlerRemoteName(chatName));
    }
    ((IServerMessenger) messenger).removeConnectionChangeListener(connectionChangeListener);
}
Also used : INode(games.strategy.net.INode) IServerMessenger(games.strategy.net.IServerMessenger)

Aggregations

IServerMessenger (games.strategy.net.IServerMessenger)8 INode (games.strategy.net.INode)5 Instant (java.time.Instant)3 UnifiedMessenger (games.strategy.engine.message.unifiedmessenger.UnifiedMessenger)2 Node (games.strategy.net.Node)2 HashSet (java.util.HashSet)2 ClientLogger (games.strategy.debug.ClientLogger)1 ClientContext (games.strategy.engine.ClientContext)1 GameStepListener (games.strategy.engine.data.events.GameStepListener)1 LOBBY_GAME_COMMENTS (games.strategy.engine.framework.CliProperties.LOBBY_GAME_COMMENTS)1 LOBBY_GAME_HOSTED_BY (games.strategy.engine.framework.CliProperties.LOBBY_GAME_HOSTED_BY)1 LOBBY_HOST (games.strategy.engine.framework.CliProperties.LOBBY_HOST)1 LOBBY_PORT (games.strategy.engine.framework.CliProperties.LOBBY_PORT)1 SERVER_PASSWORD (games.strategy.engine.framework.CliProperties.SERVER_PASSWORD)1 TRIPLEA_PORT (games.strategy.engine.framework.CliProperties.TRIPLEA_PORT)1 GameRunner (games.strategy.engine.framework.GameRunner)1 IGame (games.strategy.engine.framework.IGame)1 HeadlessGameServer (games.strategy.engine.framework.headlessGameServer.HeadlessGameServer)1 GameSelectorModel (games.strategy.engine.framework.startup.mc.GameSelectorModel)1 GameDescription (games.strategy.engine.lobby.server.GameDescription)1