added stun/turn config to config.yml

This commit is contained in:
LAX1DUDE 2022-07-17 23:49:05 -07:00
parent 82df3d0c46
commit 43eb2b2b38
6 changed files with 72 additions and 9 deletions

View File

@ -27,9 +27,11 @@ public interface ConfigurationAdapter {
Collection<String> getBlacklistURLs();
Collection<String> getBlacklistSimpleWhitelist();
Collection<String> getDisabledCommands();
Collection<String> getICEServers();
AuthServiceInfo getAuthSettings();
Map<String, Object> getMap();

View File

@ -19,7 +19,7 @@ public class Team {
private Set<String> players;
public Collection<String> getPlayers() {
return (Collection<String>) (Collection) Collections.unmodifiableSet((Set<?>) this.players);
return (Collection<String>) Collections.unmodifiableSet((Set<?>) this.players);
}
public void addPlayer(final String name) {

View File

@ -34,6 +34,7 @@ public class Configuration {
private boolean simpleWhitelistEnabled;
private boolean acceptBukkitConsoleCommandPacket;
private Collection<String> disabledCommands;
private Collection<String> iceServers;
public Configuration() {
this.timeout = 30000;
@ -67,6 +68,7 @@ public class Configuration {
this.simpleWhitelistEnabled = adapter.getBoolean("origin_blacklist_use_simple_whitelist", false);
this.acceptBukkitConsoleCommandPacket = adapter.getBoolean("accept_bukkit_console_command_packets", false);
this.disabledCommands = adapter.getDisabledCommands();
this.iceServers = adapter.getICEServers();
Preconditions.checkArgument(this.listeners != null && !this.listeners.isEmpty(), (Object) "No listeners defined.");
final Map<String, ServerInfo> newServers = adapter.getServers();
Preconditions.checkArgument(newServers != null && !newServers.isEmpty(), (Object) "No servers defined");
@ -151,4 +153,8 @@ public class Configuration {
return disabledCommands;
}
public Collection<String> getICEServers() {
return iceServers;
}
}

View File

@ -35,6 +35,8 @@ import java.io.FileInputStream;
import org.yaml.snakeyaml.DumperOptions;
import java.io.File;
import java.util.Map;
import java.util.Map.Entry;
import org.yaml.snakeyaml.Yaml;
import net.md_5.bungee.api.config.AuthServiceInfo;
@ -321,5 +323,52 @@ public class YamlConfig implements ConfigurationAdapter {
public Collection<String> getDisabledCommands() {
return this.get("disabled_commands", new ArrayList());
}
@Override
public Collection<String> getICEServers() {
Collection<String> ret = new ArrayList();
Collection<String> c = this.get("voice_stun_servers", null);
if(c == null) {
c = new ArrayList();
c.add("stun:openrelay.metered.ca:80");
c = this.get("voice_stun_servers", c);
}
ret.addAll(c);
Map<String, Object> turnServerList = this.get("voice_turn_servers", null);
if(turnServerList == null) {
turnServerList = new HashMap();
HashMap<String, Object> n = new HashMap();
n.put("url", "turn:openrelay.metered.ca:80");
n.put("username", "openrelayproject");
n.put("password", "openrelayproject");
turnServerList.put("openrelay1", n);
n = new HashMap();
n.put("url", "turn:openrelay.metered.ca:443");
n.put("username", "openrelayproject");
n.put("password", "openrelayproject");
turnServerList.put("openrelay2", n);
n = new HashMap();
n.put("url", "turn:openrelay.metered.ca:443?transport=tcp");
n.put("username", "openrelayproject");
n.put("password", "openrelayproject");
turnServerList.put("openrelay3", n);
turnServerList = this.get("voice_turn_servers", turnServerList);
}
for(Entry<String, Object> trn : turnServerList.entrySet()) {
Object o = trn.getValue();
if(o instanceof Map) {
Map<String, Object> o2 = (Map<String, Object>) o;
ret.add("" + o2.get("url") + ";" + o2.get("username") + ";" + o2.get("password"));
}
}
return ret;
}
}

View File

@ -1,5 +1,6 @@
package net.md_5.bungee.eaglercraft;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.UserConnection;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PluginMessageEvent;
@ -14,6 +15,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.Collection;
import java.util.Collections;
public class PluginEaglerVoice extends Plugin implements Listener {
@ -165,8 +167,11 @@ public class PluginEaglerVoice extends Plugin implements Listener {
DataOutputStream dos = new DataOutputStream(baos);
dos.write(VOICE_SIGNAL_ALLOWED);
dos.writeBoolean(voiceEnabled);
dos.write(0);
//dos.writeUTF("\"stun:stun.l.google.com:19302\""); // todo: add config controls for ICE servers!
Collection<String> servs = BungeeCord.getInstance().config.getICEServers();
dos.write(servs.size());
for(String str : servs) {
dos.writeUTF(str);
}
event.getPlayer().sendData("EAG|Voice", baos.toByteArray());
sendVoicePlayers(event.getPlayer().getName());
} catch (IOException ignored) { }

View File

@ -142,11 +142,12 @@ window.initializeVoiceClient = (() => {
setICEServers(urls) {
this.ICEServers.length = 0;
if (urls.length == 0) {
this.ICEServers = [ { urls: "stun:openrelay.metered.ca:80" }, { urls: "turn:openrelay.metered.ca:80", username: "openrelayproject", credential: "openrelayproject" }, { urls: "turn:openrelay.metered.ca:443", username: "openrelayproject", credential: "openrelayproject", }, { urls: "turn:openrelay.metered.ca:443?transport=tcp", username: "openrelayproject", credential: "openrelayproject" } ];
} else {
for(var i = 0; i < urls.length; ++i) {
this.ICEServers.push({ urls: urls[i] });
for(var i = 0; i < urls.length; ++i) {
var etr = urls[i].split(";");
if(etr.length == 1) {
this.ICEServers.push({ urls: etr[0] });
}else if(etr.length == 3) {
this.ICEServers.push({ urls: etr[0], username: etr[1], credential: etr[2] });
}
}
}