Skip to content

Commit

Permalink
initial version 0.1.0-SNAPSHOT
Browse files Browse the repository at this point in the history
  • Loading branch information
de-luxe committed Aug 10, 2016
0 parents commit f380647
Show file tree
Hide file tree
Showing 13 changed files with 728 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE.md
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015-2016 by luxe - https://github.com/de-luxe - BURST-LUXE-RED2-G6JW-H4HG5

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.
16 changes: 16 additions & 0 deletions README.md
@@ -0,0 +1,16 @@
# burstcoin-network-observer
Simple webpage ... that refreshes every few seconds and shows the current miningInfo of given wallets/pools.

Features:
- Checks all given pools/wallets for their current state
- Easy to run with included standalone tomcat server.

Requirements:
- java8

Setup:
- edit 'observer.properties' (e.g. rename observer.default.properties)
- edit templates/index.html within *-jar archive -> use your domain for refresh url!!!!! (quick and dirty)



8 changes: 8 additions & 0 deletions observer.default.properties
@@ -0,0 +1,8 @@
# port for network server
burstcoin.network.serverPort=1111
burstcoin.network.referenceWalletServer=http://localhost:8125
burstcoin.network.compareWalletServers=http://pool.burstcoin.de,http://178.62.39.204:8121,http://pool.burstcoin.biz,http://pool.burst-team.us,http://pool.burstcoin.it,http://pool.burstcoin.eu,http://util.burst-team.us:8080,http://burst.ninja,http://burstpool.ddns.net:8080,http://burstcoinpool.devip.xyz:8080




66 changes: 66 additions & 0 deletions pom.xml
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
</parent>

<name>burstcoin-network</name>
<groupId>burstcoin</groupId>
<artifactId>burstcoin-network-observer</artifactId>
<version>0.1.0-SNAPSHOT</version>

<properties>
<java.version>1.8</java.version>
<main.basedir>${basedir}/../..</main.basedir>
</properties>

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-client</artifactId>
<version>${jetty.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
102 changes: 102 additions & 0 deletions src/main/java/burstcoin/network/Observer.java
@@ -0,0 +1,102 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 by luxe - https://github.com/de-luxe - BURST-LUXE-RED2-G6JW-H4HG5
*
* 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.
*
*/

package burstcoin.network;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.HashMap;
import java.util.Map;

@SpringBootApplication
@EnableScheduling
public class Observer
{
private static Log LOG = LogFactory.getLog(Observer.class);

@Bean
protected ServletContextListener listener()
{
return new ServletContextListener()
{
@Override
public void contextInitialized(ServletContextEvent sce)
{
LOG.info("ServletContext initialized");
}

@Override
public void contextDestroyed(ServletContextEvent sce)
{
LOG.info("ServletContext destroyed");
}
};
}

@Bean
public HttpClient httpClient()
{
HttpClient client = new HttpClient(new SslContextFactory(true));
try
{
client.start();
}
catch(Exception e)
{
e.printStackTrace();
}
return client;
}

@Bean
public ObjectMapper objectMapper()
{
return new ObjectMapper();
}

public static void main(String[] args)
throws Exception
{
LOG.info("Starting the engines ... please wait!");

// overwritten by application.properties
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("server.port", ObserverProperties.getServerPort());

new SpringApplicationBuilder(Observer.class)
.properties(properties)
.build(args)
.run();
}


}
144 changes: 144 additions & 0 deletions src/main/java/burstcoin/network/ObserverProperties.java
@@ -0,0 +1,144 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 by luxe - https://github.com/de-luxe - BURST-LUXE-RED2-G6JW-H4HG5
*
* 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.
*
*/

package burstcoin.network;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;

public class ObserverProperties
{
private static final Logger LOG = LoggerFactory.getLogger(ObserverProperties.class);
private static final String STRING_LIST_PROPERTY_DELIMITER = ",";
private static final Properties PROPS = new Properties();

static
{
try
{
PROPS.load(new FileInputStream(System.getProperty("user.dir") + "/observer.properties"));
}
catch(IOException e)
{
LOG.error(e.getMessage());
}
}

private static String referenceWalletServer;
private static String serverPort;
private static List<String> compareWalletServers;
private static Integer connectionTimeout;


public static String getServerPort()
{
if(serverPort == null)
{
serverPort = asString("burstcoin.network.serverPort", "8080");
}
return serverPort;
}

public static String getReferenceWalletServer()
{
if(referenceWalletServer == null)
{
referenceWalletServer = asString("burstcoin.network.referenceWalletServer", "http://localhost:8125");
}
return referenceWalletServer;
}

public static List<String> getCompareWalletServers()
{
if(compareWalletServers == null)
{
compareWalletServers = asStringList("burstcoin.network.compareWalletServers", new ArrayList<>());
if(compareWalletServers.isEmpty())
{
LOG.error("Error: property 'burstcoin.network.compareWalletServers' required! ");
}
}

return compareWalletServers;
}

public static long getConnectionTimeout()
{
if(connectionTimeout == null)
{
connectionTimeout = asInteger("connectionTimeout", 12000);
}
return connectionTimeout;
}


private static int asInteger(String key, int defaultValue)
{
String integerProperty = PROPS.containsKey(key) ? String.valueOf(PROPS.getProperty(key)) : null;
Integer value = null;
if(!StringUtils.isEmpty(integerProperty))
{
try
{
value = Integer.valueOf(integerProperty);
}
catch(NumberFormatException e)
{
LOG.error("value of property: '" + key + "' should be a numeric (int) value.");
}
}
return value != null ? value : defaultValue;
}

private static List<String> asStringList(String key, List<String> defaultValue)
{
String stringListProperty = PROPS.containsKey(key) ? String.valueOf(PROPS.getProperty(key)) : null;
List<String> value = null;
if(!StringUtils.isEmpty(stringListProperty))
{
try
{
value = Arrays.asList(stringListProperty.trim().split(STRING_LIST_PROPERTY_DELIMITER));
}
catch(NullPointerException | NumberFormatException e)
{
LOG.error("property: '" + key + "' value should be 'string(s)' separated by '" + STRING_LIST_PROPERTY_DELIMITER + "' (comma).");
}
}

return value != null ? value : defaultValue;
}

private static String asString(String key, String defaultValue)
{
String value = PROPS.containsKey(key) ? String.valueOf(PROPS.getProperty(key)) : defaultValue;
return StringUtils.isEmpty(value) ? defaultValue : value;
}
}

0 comments on commit f380647

Please sign in to comment.