use of com.biglybt.core.logging.LogAlert in project BiglyBT by BiglySoftware.
the class SESecurityManagerImpl method checkKeyStoreHasEntry.
protected boolean checkKeyStoreHasEntry() {
File f = new File(keystore_name);
if (!f.exists()) {
Logger.logTextResource(new LogAlert(LogAlert.UNREPEATABLE, LogAlert.AT_ERROR, "Security.keystore.empty"), new String[] { keystore_name });
return (false);
}
try {
KeyStore key_store = loadKeyStore();
Enumeration enumx = key_store.aliases();
if (!enumx.hasMoreElements()) {
Logger.logTextResource(new LogAlert(LogAlert.UNREPEATABLE, LogAlert.AT_ERROR, "Security.keystore.empty"), new String[] { keystore_name });
return (false);
}
} catch (Throwable e) {
Logger.logTextResource(new LogAlert(LogAlert.UNREPEATABLE, LogAlert.AT_ERROR, "Security.keystore.corrupt"), new String[] { keystore_name });
return (false);
}
return (true);
}
use of com.biglybt.core.logging.LogAlert in project BiglyBT by BiglySoftware.
the class AEProxyImpl method acceptLoop.
protected void acceptLoop(ServerSocketChannel ssc) {
long successfull_accepts = 0;
long failed_accepts = 0;
while (!destroyed) {
try {
SocketChannel socket_channel = ssc.accept();
successfull_accepts++;
if (!(allow_external_access || socket_channel.socket().getInetAddress().isLoopbackAddress())) {
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, LogEvent.LT_WARNING, "AEProxy: incoming connection from '" + socket_channel.socket().getInetAddress() + "' - closed as not local"));
socket_channel.close();
} else {
try {
socket_channel.configureBlocking(false);
socket_channel.socket().setTcpNoDelay(true);
} catch (Throwable e) {
socket_channel.close();
throw (e);
}
AEProxyConnectionImpl processor = new AEProxyConnectionImpl(this, socket_channel, proxy_handler);
if (!processor.isClosed()) {
boolean added = false;
try {
this_mon.enter();
if (!destroyed) {
added = true;
processors.add(processor);
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, "AEProxy: active processors = " + processors.size()));
}
} finally {
this_mon.exit();
}
if (!added) {
processor.close();
} else {
read_selector.register(socket_channel, this, processor);
}
}
}
} catch (Throwable e) {
if (!destroyed) {
failed_accepts++;
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, "AEProxy: listener failed on port " + port, e));
if (failed_accepts > 100 && successfull_accepts == 0) {
// looks like its not going to work...
// some kind of socket problem
Logger.logTextResource(new LogAlert(LogAlert.UNREPEATABLE, LogAlert.AT_ERROR, "Network.alert.acceptfail"), new String[] { "" + port, "TCP" });
break;
}
}
}
}
}
use of com.biglybt.core.logging.LogAlert in project BiglyBT by BiglySoftware.
the class ClientPortClashHandler method check.
protected void check(ClientInstance instance) {
if (instance == my_instance) {
return;
}
InetAddress my_ext = my_instance.getExternalAddress();
InetAddress other_ext = instance.getExternalAddress();
if (my_ext.isLoopbackAddress() || other_ext.isLoopbackAddress() || my_ext.equals(other_ext)) {
String warning = null;
int my_tcp = my_instance.getTCPListenPort();
if (my_tcp != 0 && my_tcp != last_warned_tcp && my_tcp == instance.getTCPListenPort()) {
warning = "TCP " + my_tcp;
last_warned_tcp = my_tcp;
}
int my_udp = my_instance.getUDPListenPort();
int my_udp2 = my_instance.getUDPNonDataListenPort();
int other_udp = instance.getUDPListenPort();
int other_udp2 = instance.getUDPNonDataListenPort();
if (my_udp != 0 && my_udp != last_warned_udp && (my_udp == other_udp || my_udp == other_udp2)) {
warning = (warning == null ? "" : (warning + ", ")) + "UDP " + my_udp;
last_warned_udp = my_udp;
}
if (my_udp != my_udp2 && my_udp2 != 0 && my_udp2 != last_warned_udp2 && (my_udp2 == other_udp || my_udp2 == other_udp2)) {
warning = (warning == null ? "" : (warning + ", ")) + "UDP " + my_udp2;
last_warned_udp2 = my_udp2;
}
if (warning != null) {
Logger.logTextResource(new LogAlert(true, LogAlert.AT_WARNING, "azinstancehandler.alert.portclash"), new String[] { warning, String.valueOf(RandomUtils.LISTEN_PORT_MIN), String.valueOf(RandomUtils.LISTEN_PORT_MAX) });
}
}
}
use of com.biglybt.core.logging.LogAlert in project BiglyBT by BiglySoftware.
the class IncomingSocketChannelManager method start.
private void start() {
try {
this_mon.enter();
if (tcp_listen_port < 0 || tcp_listen_port > 65535 || tcp_listen_port == Constants.INSTANCE_PORT) {
String msg = "Invalid incoming TCP listen port configured, " + tcp_listen_port + ". Port reset to default. Please check your config!";
Debug.out(msg);
Logger.log(new LogAlert(LogAlert.UNREPEATABLE, LogAlert.AT_ERROR, msg));
tcp_listen_port = RandomUtils.generateRandomNetworkListenPort();
COConfigurationManager.setParameter(port_config_key, tcp_listen_port);
}
if (COConfigurationManager.getBooleanParameter(port_enable_config_key)) {
last_non_local_connection_time = COConfigurationManager.getLongParameter("network.tcp.port." + tcp_listen_port + ".last.nonlocal.incoming", 0);
if (last_non_local_connection_time > SystemTime.getCurrentTime()) {
last_non_local_connection_time = SystemTime.getCurrentTime();
}
if (serverSelectors.length == 0) {
InetSocketAddress address;
InetAddress[] bindAddresses = getEffectiveBindAddresses();
List tempSelectors = new ArrayList(bindAddresses.length);
listenFailCounts = new int[bindAddresses.length];
for (int i = 0; i < bindAddresses.length; i++) {
InetAddress bindAddress = bindAddresses[i];
if (!NetworkAdmin.getSingleton().hasIPV6Potential(true) && bindAddress instanceof Inet6Address)
continue;
if (bindAddress != null)
address = new InetSocketAddress(bindAddress, tcp_listen_port);
else
address = new InetSocketAddress(tcp_listen_port);
VirtualServerChannelSelector serverSelector;
if (bindAddresses.length == 1)
serverSelector = VirtualServerChannelSelectorFactory.createBlocking(address, so_rcvbuf_size, selectListener);
else
serverSelector = VirtualServerChannelSelectorFactory.createNonBlocking(address, so_rcvbuf_size, selectListener);
serverSelector.start();
tempSelectors.add(serverSelector);
}
if (tempSelectors.size() == 0)
Logger.log(new LogAlert(true, LogAlert.AT_WARNING, MessageText.getString("network.bindError")));
serverSelectors = (VirtualServerChannelSelector[]) tempSelectors.toArray(new VirtualServerChannelSelector[tempSelectors.size()]);
}
} else {
Logger.log(new LogEvent(LOGID, "Not starting TCP listener on port " + tcp_listen_port + " as protocol disabled"));
}
} finally {
this_mon.exit();
}
}
use of com.biglybt.core.logging.LogAlert in project BiglyBT by BiglySoftware.
the class PairingManagerImpl method setLastServerError.
protected void setLastServerError(String error) {
String last_error = param_last_error.getValue();
if (error == null) {
error = "";
}
if (!last_error.equals(error)) {
param_last_error.setValue(error);
if (error.contains("generate a new one")) {
Logger.log(new LogAlert(true, LogAlert.AT_WARNING, "The pairing access code is invalid.\n\nCreate a new one via Tools->Options->Connection->Pairing or disable the pairing feature."));
}
fireChanged();
}
}
Aggregations