forked from Hithomelabs/CFTunnels
Compare commits
57 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5fe2d96f42 | |||
| 33682a4425 | |||
| 5b8735bf58 | |||
| fe591b8af0 | |||
| b7c6149fb7 | |||
| bdb4c77ac3 | |||
| 5307ba0307 | |||
| 6262c84535 | |||
| 8720810c46 | |||
| 66fbfc5d69 | |||
| cd4b2ae2d8 | |||
| 1980b49272 | |||
| 38753791d7 | |||
| 40a536ddcf | |||
| 2b0e0eb9c4 | |||
| d7cda65f21 | |||
| 5760f9e714 | |||
| 05214000af | |||
| c24abc76be | |||
| 856748edb7 | |||
| 7203877b27 | |||
| 27576d6023 | |||
| c045dae894 | |||
| 4afeb9f6b2 | |||
| 0bc90d5d77 | |||
| 80b55fd993 | |||
| 61df434e0d | |||
| cc64b7c748 | |||
| df2a50d356 | |||
| c6ded4a74d | |||
| 36050aec95 | |||
| ccc65aef8d | |||
| 3742fb53af | |||
| 3bf981ac05 | |||
| 005863c998 | |||
| 1cd63d6d3d | |||
| f6bd7573a6 | |||
| b66ba60028 | |||
| 8f1f6e4f99 | |||
| 5fb59032cb | |||
| 196cf74a72 | |||
| ebd65ccbbe | |||
| c5d01ece01 | |||
| ec7d3299df | |||
| 6cd3524ca0 | |||
| 8bc84a3202 | |||
| 87f779450d | |||
| 620b9f2788 | |||
| 4483bf5a1b | |||
| 882b127818 | |||
| 585dd26a7b | |||
| d3f0797e33 | |||
| c3726d8e3e | |||
| 27457eb4a7 | |||
| 8fe909196a | |||
| a5df219e50 | |||
| a6c74d4443 |
4
.env.example
Normal file
4
.env.example
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
CLOUDFLARE_ACCOUNT_ID="<cloudflare account id>"
|
||||||
|
CLOUDFLARE_API_KEY="<cloudflare account key>"
|
||||||
|
CLOUDFLARE_EMAIL="<cloudflare email>"
|
||||||
|
ENV="<deployment env>"
|
||||||
20
.gitea/workflows/test_build.yml
Normal file
20
.gitea/workflows/test_build.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
name: sample gradle build and test
|
||||||
|
run-name: Build started by $ {{gitea.actor}}
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [test]
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: JDK setup
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: 'zulu'
|
||||||
|
java-version: '17'
|
||||||
|
- name: Validate Gradle Wrapper
|
||||||
|
uses: gradle/actions/wrapper-validation@v3
|
||||||
|
- name: Gradle build
|
||||||
|
run: ./gradlew build --info
|
||||||
64
.gitea/workflows/test_image_build_push.yml
Normal file
64
.gitea/workflows/test_image_build_push.yml
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
name: sample gradle build and test
|
||||||
|
run-name: Build started by $ {{gitea.actor}}
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [test]
|
||||||
|
jobs:
|
||||||
|
tag:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
new_version: ${{ steps.new_version.outputs.new_version }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Get new version
|
||||||
|
id: new_version
|
||||||
|
run: |
|
||||||
|
VERSION=$(git describe --tags --abbrev=0)
|
||||||
|
echo ${VERSION}
|
||||||
|
MAJOR=$(echo ${VERSION} | cut -d "." -f 1)
|
||||||
|
MINOR=$(echo ${VERSION} | cut -d "." -f 2)
|
||||||
|
PATCH=$(echo ${VERSION} | cut -d "." -f 3)
|
||||||
|
NEW_PATCH=$(( ${PATCH} + 1))
|
||||||
|
echo ${NEW_PATCH}
|
||||||
|
echo "new_version=$(echo "${MAJOR}.${MINOR}.${NEW_PATCH}")" >> $GITHUB_OUTPUT
|
||||||
|
build_tag_push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: tag
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: JDK setup
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: 'zulu'
|
||||||
|
java-version: '17'
|
||||||
|
- name: Validate Gradle Wrapper
|
||||||
|
uses: gradle/actions/wrapper-validation@v3
|
||||||
|
- name: Create and push tag
|
||||||
|
run: |
|
||||||
|
echo "NEW_VERSION=${{ needs.tag.outputs.new_version }}"
|
||||||
|
git config --global user.name "${{gitea.actor}}"
|
||||||
|
git config --global user.email "${{ gitea.actor }}@users.noreply.github.com"
|
||||||
|
git tag -a ${{ needs.tag.outputs.new_version }} -m "Pushing new version ${{ needs.tag.outputs.new_version }}"
|
||||||
|
git push origin ${{ needs.tag.outputs.new_version }}
|
||||||
|
- name: Log in to Gitea Docker Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: 'http://192.168.0.100:8928'
|
||||||
|
username: hitanshu
|
||||||
|
password: ${{ secrets.TOKEN }}
|
||||||
|
- name: Gradle build
|
||||||
|
run: ./gradlew bootBuildImage --imageName=192.168.0.100:8928/hithomelabs/cftunnels:${{ needs.tag.outputs.new_version }}
|
||||||
|
- name: Tag image as test
|
||||||
|
run: docker tag 192.168.0.100:8928/hithomelabs/cftunnels:${{ needs.tag.outputs.new_version }} 192.168.0.100:8928/hithomelabs/cftunnels:test
|
||||||
|
- name: Push to Gitea Registry
|
||||||
|
run: |
|
||||||
|
docker push 192.168.0.100:8928/hithomelabs/cftunnels:test
|
||||||
|
docker push 192.168.0.100:8928/hithomelabs/cftunnels:${{ needs.tag.outputs.new_version }}
|
||||||
@ -5,7 +5,7 @@ meta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get {
|
get {
|
||||||
url: http://localhost8080/cloudflare/tunnels
|
url: {{base_url}}/cloudflare/tunnels
|
||||||
body: none
|
body: none
|
||||||
auth: none
|
auth: none
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ meta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get {
|
get {
|
||||||
url: http://localhost:8080/cloudflare/tunnel/{{tunnel_id}}
|
url: {{base_url}}/cloudflare/tunnel/{{tunnel_id}}
|
||||||
body: none
|
body: none
|
||||||
auth: none
|
auth: none
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,8 +4,16 @@ meta {
|
|||||||
seq: 2
|
seq: 2
|
||||||
}
|
}
|
||||||
|
|
||||||
post {
|
put {
|
||||||
url: http://localhost:8080/cloudflare/tunnel/50df9101-f625-4618-b7c5-100338a57124
|
url: {{base_url}}/cloudflare/tunnel/{{tunnel_id}}/add
|
||||||
body: none
|
body: json
|
||||||
auth: none
|
auth: none
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body:json {
|
||||||
|
{
|
||||||
|
"service": "http://192.168.0.100:3457",
|
||||||
|
"hostname": "random.hithomelabs.com",
|
||||||
|
"originRequest": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -5,7 +5,15 @@ meta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
put {
|
put {
|
||||||
url: http://localhost:8080/cloudflare/tunnel/50df9101-f625-4618-b7c5-100338a57124/add
|
url: {{base_url}}/cloudflare/tunnel/{{tunnel_id}}/delete
|
||||||
body: none
|
body: json
|
||||||
auth: none
|
auth: none
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body:json {
|
||||||
|
{
|
||||||
|
"service": "http://192.168.0.100:6000",
|
||||||
|
"hostname": "random.hithomelabs.com",
|
||||||
|
"originRequest": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
4
CFTunnels/environments/CFTunnels Local.bru
Normal file
4
CFTunnels/environments/CFTunnels Local.bru
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
vars {
|
||||||
|
tunnel_id: 50df9101-f625-4618-b7c5-100338a57124
|
||||||
|
base_url: http://localhost:8080
|
||||||
|
}
|
||||||
@ -1,3 +1,4 @@
|
|||||||
vars {
|
vars {
|
||||||
tunnel_id: 50df9101-f625-4618-b7c5-100338a57124
|
tunnel_id: 50df9101-f625-4618-b7c5-100338a57124
|
||||||
|
base_url: https://testcf.hithomelabs.com
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,12 +13,16 @@ java {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
systemProperty 'spring.profiles.active', 'test'
|
||||||
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.0.3'
|
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.8.5'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||||
|
|||||||
12
docker-compose.yaml
Normal file
12
docker-compose.yaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: gitea.hithomelabs.com/hithomelabs/cftunnels:${ENV}
|
||||||
|
container_name: cftunnels_${ENV}
|
||||||
|
environment:
|
||||||
|
- CLOUDFLARE_ACCOUNT_ID=${CLOUDFLARE_ACCOUNT_ID}
|
||||||
|
- CLOUDFLARE_API_KEY=${CLOUDFLARE_API_KEY}
|
||||||
|
- CLOUDFLARE_EMAIL=${CLOUDFLARE_EMAIL}
|
||||||
|
- ENV=${ENV}
|
||||||
|
ports:
|
||||||
|
- 5002:8080
|
||||||
|
restart: unless-stopped
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
package com.hithomelabs.CFTunnels.Config;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
import io.swagger.v3.oas.models.servers.Server;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class OpenApiConfig {
|
||||||
|
|
||||||
|
@Value("${api.baseUrl}")
|
||||||
|
private String baseUrl;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public OpenAPI openAPI(){
|
||||||
|
Server httpsServer = new Server().url(baseUrl);
|
||||||
|
OpenAPI openApi = new OpenAPI();
|
||||||
|
ArrayList<Server> servers = new ArrayList<>();
|
||||||
|
servers.add(httpsServer);
|
||||||
|
openApi.setServers(servers);
|
||||||
|
return openApi;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,6 +8,16 @@ public class Ingress {
|
|||||||
private String service;
|
private String service;
|
||||||
private String hostname;
|
private String hostname;
|
||||||
private Map<String, Object> originRequest;
|
private Map<String, Object> originRequest;
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPath(String path) {
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean deleteByHostName(List<Ingress> ingressList, String toBeDeleted){
|
public static boolean deleteByHostName(List<Ingress> ingressList, String toBeDeleted){
|
||||||
return ingressList.removeIf(ingress -> ingress.getHostname() != null && ingress.getHostname().equals(toBeDeleted));
|
return ingressList.removeIf(ingress -> ingress.getHostname() != null && ingress.getHostname().equals(toBeDeleted));
|
||||||
|
|||||||
1
src/main/resources/application-local.properties
Normal file
1
src/main/resources/application-local.properties
Normal file
@ -0,0 +1 @@
|
|||||||
|
api.baseUrl=http://localhost:8080
|
||||||
1
src/main/resources/application-prod.properties
Normal file
1
src/main/resources/application-prod.properties
Normal file
@ -0,0 +1 @@
|
|||||||
|
api.baseUrl=https://cftunnels.hithomelabs.com
|
||||||
1
src/main/resources/application-test.properties
Normal file
1
src/main/resources/application-test.properties
Normal file
@ -0,0 +1 @@
|
|||||||
|
api.baseUrl=https://testcf.hithomelabs.com
|
||||||
@ -2,3 +2,4 @@ spring.application.name=CFTunnels
|
|||||||
cloudflare.accountId=${CLOUDFLARE_ACCOUNT_ID}
|
cloudflare.accountId=${CLOUDFLARE_ACCOUNT_ID}
|
||||||
cloudflare.apiKey=${CLOUDFLARE_API_KEY}
|
cloudflare.apiKey=${CLOUDFLARE_API_KEY}
|
||||||
cloudflare.email=${CLOUDFLARE_EMAIL}
|
cloudflare.email=${CLOUDFLARE_EMAIL}
|
||||||
|
spring.profiles.active=${ENV}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user