Skip to content

Tale152/vpn_keep_alive

Repository files navigation

Java Gradle Docker GitHub Actions

GitHub last commit GitHub release (latest by date including pre-releases) GitHub Release Date GitHub commits since latest release (by date)

vpn_keep_alive

Simple program to perform periodic http GET requests; this simple project was born out of frustration at work since Pulse Secure VPN disconnects if, after a while, no traffic happens between my computer and something behind the VPN.

Why not using a simple script you might ask? Company policies prevent me from doing that for security reasons, so I needed to be a little more creative.

Whether you also need to keep a VPN alive or you just need to periodically perform periodic http GET requests, that's the solution for you.

Table of contents

How to run the project

Here there is a list of various ways of running this project.

Every run method requires two arguments:

  • URL: the url that will be contacted when the http GET is performed
    (e.g. : https://www.google.com)
  • INTERVAL_MILLISECONDS: the amount of time (expressed in milliseconds) between one http GET request and the next one
  • (e.g. : 600000, which is 10 minutes)

You might need (depending on which method you choose):

  • Docker
  • Java 8
  • Gradle

Run the Docker image

Here you can find a Docker Hub repository containing working Docker images for this project.

Run it once

Assuming you want to call the container "vpn_keep_alive", run this command to execute the application:

docker run -e URL=<URL> -e INTERVAL=<INTERVAL_MILLISECONDS> --name vpn_keep_alive alessandrotalmi/vpn_keep_alive

Autostart

I personally let Docker autostart on my system boot and, by launching this command just once (note the "--restart=always" parameter, I don't need to think about it ever again:

docker run -e URL=<URL> -e INTERVAL=<INTERVAL_MILLISECONDS> --restart=always --name vpn_keep_alive alessandrotalmi/vpn_keep_alive

Run the standalone JAR

You can find the latest standalone jar in the releases of this repository; for every release, a new jar file will be published, changing the file name according to the release's version itself.
In this example I will use the v0.1.0, with the jar file named vpn_keep_alive_v0.1.0.jar.

Once you have downloaded the jar file, navigate to the directory where you stored it and launch the command:

java -jar .\vpn_keep_alive_v0.1.0.jar <URL> <INTERVAL_MILLISECONDS> 

Compile it yourself

If you want to get your hands dirty, clone the repository and, once you have placed yourself in the project's directory, run the following command:

.\gradlew build  

this will create a standalone jar named "vpn_keep_alive.jar" inside the directory app/build/libs; you can then run the jar file the same way as previously described.

If you simply want to run the project, just execute this command:

.\gradlew run --args='<URL> <INTERVAL_MILLISECONDS>'  

If, on the other hand, you want to build your own Docker image, just use the regular Docker image creation commands and then run the image remembering to add the aguments as previously described.

Future development ideas

I organized the code to easily add a GUI if this project needs to be used by someone that is not very confident when using the command line.

I might change the implementation from Java to Kotlin just to make practice with the language.

If you want to add something to the project, feel free to create a fork and create a pull request :D !

How to create a new release

If you fork this repository and you would like to create your own releases, you first need to create some Repository Secrets that will be used by the GitHub actions to automate the process:

  • DOCKERHUB_USERNAME: your Docker Hub username
  • DOCKERHUB_PASSWORD: your Docker Hub password These credentials will be used to publish a working Docker image on your Docker Hub profile.

You also need to grant write permissions to the repository's GITHUB_TOKEN in order to allow the creation of an automatic release.

Check the files in .github/workflows to manipulate what happens when you trigger the pipeline.

Once you satisfy the previous requirements, if you want to create a new release set master as your current branch and run:

git tag -a v<VERSION> -m "<RELEASE NOTES>" 

to create a new tag for the release and then run:

git push origin --tags

to push the new tag.
This will trigger the repository's actions that will create a new release (with a standalone jar attached) and publish a new Docker image on your Docker Hub profile.

About

Simple program to perform periodic http GET requests

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published