Skip to content

Releases: FlareBot/WebHookDistributor

Authorization header is persistent (oops)

05 Mar 21:06
Compare
Choose a tag to compare
1.0.1.3

Make sure the authorization is sent if present

1.0.1.2

05 Mar 20:48
704407f
Compare
Choose a tag to compare
Let's try this

1.0.1.1

05 Mar 20:37
60eb5e0
Compare
Choose a tag to compare
OOps

Safety measures

27 Feb 20:52
Compare
Choose a tag to compare

This release pushes some safety measures which can be used to better verify the sender of the WebHook. This introduces two new methods to Event, getAuthorization() and getIP(). getAuthorization() is to get the Authorization header (null if it doesn't have one) and getIP() is to return the IP which sent the request.

Usage:

public void onWebHookReceive(WebHookReceiveEvent e){
    if (e.getAuthorization() != null && e.getAuthorization().equals("secretKey1337")) {
        LoggerFactory.getLogger(Example.class).info(String.format("Received webhook from %s, data: %s",
                e.getSender().toString(), e.getPayload().toString()));
    } else
        LoggerFactory.getLogger(Example.class)
                .warn(String.format("Received webhook with invalid authorization from %s pretending to be %s",
                        e.getIP(), e.getSender().toString()));
}

Base release

25 Feb 20:23
9c26b60
Compare
Choose a tag to compare

Start of the WebHookDistributor system. Full implementation client and server side. Code below as an example of client side.

For server just build and use.

Example class:

import org.slf4j.LoggerFactory;
import stream.flarebot.webhook_distributor.WebHookDistributor;
import stream.flarebot.webhook_distributor.WebHookDistributorBuilder;
import stream.flarebot.webhook_distributor.WebHookListener;
import stream.flarebot.webhook_distributor.events.WebHookReceiveEvent;

public class Example {

    public static void main(String[] args) {
    	// This will say that the server is located at "https://cool-webhooks.flarebot.stream", the service is called "example" and the port for this service is '8181'.
        WebHookDistributor distributor = new WebHookDistributorBuilder("https://cool-webhooks.flarebot.stream", "example", 8181)
        	// This will add the listener which is defined below.
                .addEventListener(new Listener())
                // This is the starting retry time, when connection to the server fails it will use this value first and double each failed attempt.
                .setStartingRetryTime(500)
                // The amount of connection attempts to make to the server before giving up.
                .setMaxConnectionAttempts(5)
                .build();
		// Start listening to WebHooks from the server.
        distributor.start();
    }

    private static class Listener extends WebHookListener {

        public void onWebHookReceive(WebHookReceiveEvent e){
            LoggerFactory.getLogger(Example.class).info(String.format("Received webhook from %s, data: %s",
                    e.getSender().toString(), e.getPayload().toString()));
        }
    }
}