diff --git a/eaglercraftbungee/src/main/java/net/md_5/bungee/api/config/ConfigurationAdapter.java b/eaglercraftbungee/src/main/java/net/md_5/bungee/api/config/ConfigurationAdapter.java index f284ab3..c919e34 100644 --- a/eaglercraftbungee/src/main/java/net/md_5/bungee/api/config/ConfigurationAdapter.java +++ b/eaglercraftbungee/src/main/java/net/md_5/bungee/api/config/ConfigurationAdapter.java @@ -27,9 +27,11 @@ public interface ConfigurationAdapter { Collection getBlacklistURLs(); Collection getBlacklistSimpleWhitelist(); - + Collection getDisabledCommands(); + Collection getICEServers(); + AuthServiceInfo getAuthSettings(); Map getMap(); diff --git a/eaglercraftbungee/src/main/java/net/md_5/bungee/api/score/Team.java b/eaglercraftbungee/src/main/java/net/md_5/bungee/api/score/Team.java index 333c1cf..091469b 100644 --- a/eaglercraftbungee/src/main/java/net/md_5/bungee/api/score/Team.java +++ b/eaglercraftbungee/src/main/java/net/md_5/bungee/api/score/Team.java @@ -19,7 +19,7 @@ public class Team { private Set players; public Collection getPlayers() { - return (Collection) (Collection) Collections.unmodifiableSet((Set) this.players); + return (Collection) Collections.unmodifiableSet((Set) this.players); } public void addPlayer(final String name) { diff --git a/eaglercraftbungee/src/main/java/net/md_5/bungee/config/Configuration.java b/eaglercraftbungee/src/main/java/net/md_5/bungee/config/Configuration.java index ee4a7e3..c913e4b 100644 --- a/eaglercraftbungee/src/main/java/net/md_5/bungee/config/Configuration.java +++ b/eaglercraftbungee/src/main/java/net/md_5/bungee/config/Configuration.java @@ -34,6 +34,7 @@ public class Configuration { private boolean simpleWhitelistEnabled; private boolean acceptBukkitConsoleCommandPacket; private Collection disabledCommands; + private Collection 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 newServers = adapter.getServers(); Preconditions.checkArgument(newServers != null && !newServers.isEmpty(), (Object) "No servers defined"); @@ -151,4 +153,8 @@ public class Configuration { return disabledCommands; } + public Collection getICEServers() { + return iceServers; + } + } diff --git a/eaglercraftbungee/src/main/java/net/md_5/bungee/config/YamlConfig.java b/eaglercraftbungee/src/main/java/net/md_5/bungee/config/YamlConfig.java index 2fb2175..66857c1 100644 --- a/eaglercraftbungee/src/main/java/net/md_5/bungee/config/YamlConfig.java +++ b/eaglercraftbungee/src/main/java/net/md_5/bungee/config/YamlConfig.java @@ -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 getDisabledCommands() { return this.get("disabled_commands", new ArrayList()); } + + @Override + public Collection getICEServers() { + Collection ret = new ArrayList(); + + Collection 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 turnServerList = this.get("voice_turn_servers", null); + if(turnServerList == null) { + turnServerList = new HashMap(); + HashMap 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 trn : turnServerList.entrySet()) { + Object o = trn.getValue(); + if(o instanceof Map) { + Map o2 = (Map) o; + ret.add("" + o2.get("url") + ";" + o2.get("username") + ";" + o2.get("password")); + } + } + + return ret; + } } diff --git a/eaglercraftbungee/src/main/java/net/md_5/bungee/eaglercraft/PluginEaglerVoice.java b/eaglercraftbungee/src/main/java/net/md_5/bungee/eaglercraft/PluginEaglerVoice.java index 443ef09..ed82955 100644 --- a/eaglercraftbungee/src/main/java/net/md_5/bungee/eaglercraft/PluginEaglerVoice.java +++ b/eaglercraftbungee/src/main/java/net/md_5/bungee/eaglercraft/PluginEaglerVoice.java @@ -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 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) { } diff --git a/javascript/eagswebrtc.js b/javascript/eagswebrtc.js index 1361c4d..e287bff 100644 --- a/javascript/eagswebrtc.js +++ b/javascript/eagswebrtc.js @@ -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] }); } } }