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!";
}
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();
}
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);
}
Aggregations