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> getBlacklistURLs();
Collection<String> getBlacklistSimpleWhitelist(); Collection<String> getBlacklistSimpleWhitelist();
Collection<String> getDisabledCommands(); Collection<String> getDisabledCommands();
Collection<String> getICEServers();
AuthServiceInfo getAuthSettings(); AuthServiceInfo getAuthSettings();
Map<String, Object> getMap(); Map<String, Object> getMap();

View File

@ -19,7 +19,7 @@ public class Team {
private Set<String> players; private Set<String> players;
public Collection<String> getPlayers() { 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) { public void addPlayer(final String name) {

View File

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

View File

@ -35,6 +35,8 @@ import java.io.FileInputStream;
import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.DumperOptions;
import java.io.File; import java.io.File;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.Yaml;
import net.md_5.bungee.api.config.AuthServiceInfo; import net.md_5.bungee.api.config.AuthServiceInfo;
@ -321,5 +323,52 @@ public class YamlConfig implements ConfigurationAdapter {
public Collection<String> getDisabledCommands() { public Collection<String> getDisabledCommands() {
return this.get("disabled_commands", new ArrayList()); 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; package net.md_5.bungee.eaglercraft;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.UserConnection; import net.md_5.bungee.UserConnection;
import net.md_5.bungee.api.event.PlayerDisconnectEvent; import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.event.PluginMessageEvent;
@ -14,6 +15,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
public class PluginEaglerVoice extends Plugin implements Listener { public class PluginEaglerVoice extends Plugin implements Listener {
@ -165,8 +167,11 @@ public class PluginEaglerVoice extends Plugin implements Listener {
DataOutputStream dos = new DataOutputStream(baos); DataOutputStream dos = new DataOutputStream(baos);
dos.write(VOICE_SIGNAL_ALLOWED); dos.write(VOICE_SIGNAL_ALLOWED);
dos.writeBoolean(voiceEnabled); dos.writeBoolean(voiceEnabled);
dos.write(0); Collection<String> servs = BungeeCord.getInstance().config.getICEServers();
//dos.writeUTF("\"stun:stun.l.google.com:19302\""); // todo: add config controls for ICE servers! dos.write(servs.size());
for(String str : servs) {
dos.writeUTF(str);
}
event.getPlayer().sendData("EAG|Voice", baos.toByteArray()); event.getPlayer().sendData("EAG|Voice", baos.toByteArray());
sendVoicePlayers(event.getPlayer().getName()); sendVoicePlayers(event.getPlayer().getName());
} catch (IOException ignored) { } } catch (IOException ignored) { }

View File

@ -142,11 +142,12 @@ window.initializeVoiceClient = (() => {
setICEServers(urls) { setICEServers(urls) {
this.ICEServers.length = 0; this.ICEServers.length = 0;
if (urls.length == 0) { for(var i = 0; i < urls.length; ++i) {
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" } ]; var etr = urls[i].split(";");
} else { if(etr.length == 1) {
for(var i = 0; i < urls.length; ++i) { this.ICEServers.push({ urls: etr[0] });
this.ICEServers.push({ urls: urls[i] }); }else if(etr.length == 3) {
this.ICEServers.push({ urls: etr[0], username: etr[1], credential: etr[2] });
} }
} }
} }