Fix two exceptions and fix channel password support
This commit is contained in:
@@ -0,0 +1,51 @@
|
|||||||
|
package com.github.manevolent.ts3j.event;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* #%L
|
||||||
|
* TeamSpeak 3 Java API
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2014 Bert De Geyter
|
||||||
|
* %%
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.github.manevolent.ts3j.api.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class ChannelPermHintsEvent extends BaseEvent {
|
||||||
|
|
||||||
|
public ChannelPermHintsEvent(Map<String, String> map) {
|
||||||
|
super(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getChannelId() {
|
||||||
|
return getInt(ChannelProperty.CID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fire(TS3Listener listener) {
|
||||||
|
listener.onChannelPermHints(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFlags() {
|
||||||
|
return getInt("flags");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.github.manevolent.ts3j.event;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class ClientPermHintsEvent extends BaseEvent {
|
||||||
|
public ClientPermHintsEvent(Map<String, String> map) {
|
||||||
|
super(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fire(TS3Listener listener) {
|
||||||
|
listener.onClientPermHints(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getClientId() {
|
||||||
|
return getInt("clid");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPermId() {
|
||||||
|
return getInt("permid");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPermValue() {
|
||||||
|
return getInt("permvalue");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -83,6 +83,10 @@ public interface TS3Event {
|
|||||||
return new ClientChatClosedEvent(command.toMap());
|
return new ClientChatClosedEvent(command.toMap());
|
||||||
case "notifypermissionlist": // CLIENT
|
case "notifypermissionlist": // CLIENT
|
||||||
return new PermissionListEvent(command.toMap());
|
return new PermissionListEvent(command.toMap());
|
||||||
|
case "notifyclientpermhints": // CLIENT
|
||||||
|
return new ClientPermHintsEvent(command.toMap());
|
||||||
|
case "notifychannelpermhints": // CLIENT
|
||||||
|
return new ChannelPermHintsEvent(command.toMap());
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("unknown event: " + command.getName());
|
throw new IllegalArgumentException("unknown event: " + command.getName());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,4 +55,6 @@ public interface TS3Listener {
|
|||||||
default void onPermissionList(PermissionListEvent e) {}
|
default void onPermissionList(PermissionListEvent e) {}
|
||||||
default void onConnected(ConnectedEvent e) {}
|
default void onConnected(ConnectedEvent e) {}
|
||||||
default void onClientChatClosed(ClientChatClosedEvent e) {}
|
default void onClientChatClosed(ClientChatClosedEvent e) {}
|
||||||
|
default void onClientPermHints(ClientPermHintsEvent e) {}
|
||||||
|
default void onChannelPermHints(ChannelPermHintsEvent e) {}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -594,7 +594,6 @@ public abstract class AbstractTeamspeakClientSocket
|
|||||||
packet.readBody(packetBuffer);
|
packet.readBody(packetBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PacketKind kind = networkPacket.getHeader().getType().getKind();
|
PacketKind kind = networkPacket.getHeader().getType().getKind();
|
||||||
if (kind != null)
|
if (kind != null)
|
||||||
packetStatistics
|
packetStatistics
|
||||||
@@ -615,8 +614,7 @@ public abstract class AbstractTeamspeakClientSocket
|
|||||||
while (isReading()) {
|
while (isReading()) {
|
||||||
// De-spool spooled-up packets
|
// De-spool spooled-up packets
|
||||||
if (handlerBacklog.size() > 0) {
|
if (handlerBacklog.size() > 0) {
|
||||||
Packet packet = handlerBacklog.remove(0);
|
return handlerBacklog.remove(0);
|
||||||
return packet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -780,7 +778,8 @@ public abstract class AbstractTeamspeakClientSocket
|
|||||||
Packet reassembled;
|
Packet reassembled;
|
||||||
while ((reassembled = reassembly.next()) != null) {
|
while ((reassembled = reassembly.next()) != null) {
|
||||||
Ts3Debugging.debug("[PROTOCOL] REASSEMBLE " + reassembled.getHeader().getType().name() +
|
Ts3Debugging.debug("[PROTOCOL] REASSEMBLE " + reassembled.getHeader().getType().name() +
|
||||||
" id=" + reassembled.getHeader().getPacketId() + " len=" + reassembled.getSize());
|
" id=" + reassembled.getHeader().getPacketId() + " len=" + reassembled.getSize() +
|
||||||
|
" bodyType=" + reassembled.getBody().getClass().getSimpleName());
|
||||||
handlerBacklog.add(reassembled);
|
handlerBacklog.add(reassembled);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -934,6 +933,7 @@ public abstract class AbstractTeamspeakClientSocket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
Ts3Debugging.debug("Problem reading packet", e);
|
||||||
getExceptionHandler().accept(e);
|
getExceptionHandler().accept(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -25,9 +25,7 @@ import com.github.manevolent.ts3j.protocol.packet.handler.client.LocalClientHand
|
|||||||
import com.github.manevolent.ts3j.protocol.packet.handler.client.LocalClientHandlerRetrievingData;
|
import com.github.manevolent.ts3j.protocol.packet.handler.client.LocalClientHandlerRetrievingData;
|
||||||
import com.github.manevolent.ts3j.protocol.packet.statistics.PacketStatistics;
|
import com.github.manevolent.ts3j.protocol.packet.statistics.PacketStatistics;
|
||||||
import com.github.manevolent.ts3j.protocol.packet.transformation.InitPacketTransformation;
|
import com.github.manevolent.ts3j.protocol.packet.transformation.InitPacketTransformation;
|
||||||
import com.github.manevolent.ts3j.util.HighPrecisionTimer;
|
import com.github.manevolent.ts3j.util.*;
|
||||||
import com.github.manevolent.ts3j.util.Ts3Debugging;
|
|
||||||
import com.github.manevolent.ts3j.util.Pair;
|
|
||||||
|
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -448,6 +446,8 @@ public class LocalTeamspeakClientSocket
|
|||||||
|
|
||||||
if (awaitingCommandProcessor != null)
|
if (awaitingCommandProcessor != null)
|
||||||
awaitingCommandProcessor.process(client, singleCommand);
|
awaitingCommandProcessor.process(client, singleCommand);
|
||||||
|
else
|
||||||
|
Ts3Debugging.info("Dropping command, no awaiting processor: " + singleCommand.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1098,7 +1098,7 @@ public class LocalTeamspeakClientSocket
|
|||||||
Command command = new SingleCommand("clientmove", ProtocolRole.CLIENT);
|
Command command = new SingleCommand("clientmove", ProtocolRole.CLIENT);
|
||||||
|
|
||||||
command.add(new CommandSingleParameter("cid", Integer.toString(channelId)));
|
command.add(new CommandSingleParameter("cid", Integer.toString(channelId)));
|
||||||
if (password != null) command.add(new CommandSingleParameter("cpw", Integer.toString(channelId)));
|
if (password != null) command.add(new CommandSingleParameter("cpw", Ts3Crypt.hashPassword(password)));
|
||||||
command.add(new CommandSingleParameter("clid", Integer.toString(clientId)));
|
command.add(new CommandSingleParameter("clid", Integer.toString(clientId)));
|
||||||
|
|
||||||
executeCommand(command).complete();
|
executeCommand(command).complete();
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ import java.io.ByteArrayInputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.charset.*;
|
||||||
import java.security.*;
|
import java.security.*;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
|
|
||||||
public final class Ts3Crypt {
|
public final class Ts3Crypt {
|
||||||
static {
|
static {
|
||||||
@@ -312,6 +313,10 @@ public final class Ts3Crypt {
|
|||||||
return new LocalIdentity(publicKey, privateKey);
|
return new LocalIdentity(publicKey, privateKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String hashPassword(String password) {
|
||||||
|
return Base64.getEncoder().encodeToString(hash128(password.getBytes(StandardCharsets.UTF_8)));
|
||||||
|
}
|
||||||
|
|
||||||
public static final class SecureChannelParameters {
|
public static final class SecureChannelParameters {
|
||||||
private final byte[] fakeSignature;
|
private final byte[] fakeSignature;
|
||||||
private final byte[] ivStruct;
|
private final byte[] ivStruct;
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
package com.github.manevolent.ts3j;
|
package com.github.manevolent.ts3j;
|
||||||
|
|
||||||
|
import com.github.manevolent.ts3j.command.*;
|
||||||
|
import com.github.manevolent.ts3j.event.*;
|
||||||
import com.github.manevolent.ts3j.identity.LocalIdentity;
|
import com.github.manevolent.ts3j.identity.LocalIdentity;
|
||||||
import com.github.manevolent.ts3j.protocol.client.ClientConnectionState;
|
import com.github.manevolent.ts3j.protocol.client.ClientConnectionState;
|
||||||
import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket;
|
import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket;
|
||||||
import com.github.manevolent.ts3j.util.Ts3Debugging;
|
import com.github.manevolent.ts3j.util.Ts3Debugging;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
@@ -25,10 +28,11 @@ public class ServerConnectionTest {
|
|||||||
"teamlixo.net",
|
"teamlixo.net",
|
||||||
10000L
|
10000L
|
||||||
);
|
);
|
||||||
client.getChannels().get().forEach(x -> System.err.println(x.getTopic()));
|
|
||||||
|
|
||||||
assertEquals(client.getState(), ClientConnectionState.CONNECTED);
|
assertEquals(client.getState(), ClientConnectionState.CONNECTED);
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
|
||||||
client.setDescription("Heyo");
|
client.setDescription("Heyo");
|
||||||
|
|
||||||
client.subscribeAll();
|
client.subscribeAll();
|
||||||
|
|||||||
Reference in New Issue
Block a user