Skip to content

Commit 0ee2249

Browse files
committed
first
1 parent 31580fa commit 0ee2249

File tree

15 files changed

+792
-5
lines changed

15 files changed

+792
-5
lines changed

.gitattributes

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/workflows/ghcr-publish.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Docker
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
env:
8+
# Use docker.io for Docker Hub if empty
9+
REGISTRY: ghcr.io
10+
# github.repository as <account>/<repo>
11+
IMAGE_NAME: ${{ github.repository }}
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
# This is used to complete the identity challenge
20+
# with sigstore/fulcio when running outside of PRs.
21+
id-token: write
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
# Workaround: https://github.com/docker/build-push-action/issues/461
28+
- name: Setup Docker buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
# Login against a Docker registry
32+
# https://github.com/docker/login-action
33+
- name: Log into registry ${{ env.REGISTRY }}
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ${{ env.REGISTRY }}
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
# Extract metadata (tags, labels) for Docker
41+
# https://github.com/docker/metadata-action
42+
- name: Extract Docker metadata
43+
id: meta
44+
uses: docker/metadata-action@v5
45+
with:
46+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
47+
48+
# Build and push Docker image with Buildx
49+
# https://github.com/docker/build-push-action
50+
- name: Build and push Docker image
51+
id: build-and-push
52+
uses: docker/build-push-action@v5
53+
with:
54+
context: .
55+
push: ${{ github.event_name != 'pull_request' }}
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# If you prefer the allow list template instead of the deny list, see community template:
2-
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
3-
#
41
# Binaries for programs and plugins
52
*.exe
63
*.exe~
@@ -23,3 +20,6 @@ go.work.sum
2320

2421
# env file
2522
.env
23+
24+
# data directory
25+
data/

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM golang:1.24.4-alpine AS builder
2+
3+
WORKDIR /app
4+
5+
COPY go.mod go.sum ./
6+
7+
RUN go mod download
8+
9+
COPY . ./
10+
11+
RUN CGO_ENABLED=0 go build -o tailscale_fwdr -ldflags="-w -s" ./.
12+
13+
FROM gcr.io/distroless/static
14+
15+
WORKDIR /app
16+
17+
COPY --from=builder /app/tailscale_fwdr /usr/local/bin/tailscale_fwdr
18+
19+
ENTRYPOINT ["/usr/local/bin/tailscale_fwdr"]

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## Tailscale Forwarder
2+
3+
Tailscale Forwarder is a TCP proxy that allows you to connect through a Tailscale machine to the configured target address and port pair.
4+
5+
This allows you to connect to Railway services that are not accessible from the internet, for example, locking down access to your database to only those who are on your Tailscale network.
6+
7+
This also solves for the issue that you can only run one Tailscale subnet router per Tailscale account.
8+
9+
## Usage
10+
11+
1. Generate a Tailscale auth key.
12+
13+
Make sure `Reusable` is enabled.
14+
15+
2. Deploy the Tailscale Forwarder service into your pre-existing Railway project.
16+
17+
Set the `TS_AUTHKEY` environment variable to the auth key you generated in step 1.
18+
19+
Set your first connection mapping, example:
20+
21+
`CONNECTION_MAPPING_01=5432:${{Postgres.RAILWAY_PRIVATE_DOMAIN}}:${{Postgres.PGPORT}}`
22+
23+
The format is `<Source Port>:<Target Host>:<Target Port>`.
24+
25+
Note: You can set multiple connection mappings by incrementing the `CONNECTION_MAPPING_` prefix.
26+
27+
3. Get the machine's hostname.
28+
29+
You should see a new machine in the dashboard with the format `<Project Name>-<Environment Name>-<Service Name>`, copy this hostname.
30+
31+
4. Use the machine's hostname in your connection string.
32+
33+
Example: `postgresql://postgres:<Postgres Password>@<Tailscale Forwarder Hostname>:<Source Port From Desired Connection Mapping (5432)>/railway`
34+
35+
While that example is for a PostgreSQL connection string, you can use the same `<Tailscale Forwarder Hostname>:<Source Port From Desired Connection Mapping (5432)>` format to connect to any service that listens on a TCP port, that you have setup a connection mapping for.
36+
37+
## Configuration
38+
39+
| Environment Variable | Required | Default Value | Description |
40+
| ------------------------ | :------: | ----------------------------------------------------------------------------------- | ------------------------------------------ |
41+
| `TS_AUTHKEY` | Yes | - | Tailscale auth key. |
42+
| `TS_HOSTNAME` | Yes | `${{RAILWAY_PROJECT_NAME}}-${{RAILWAY_ENVIRONMENT_NAME}}-${{RAILWAY_SERVICE_NAME}}` | Hostname to use for the Tailscale machine. |
43+
| `CONNECTION_MAPPING_[n]` | Yes | - | |

go.mod

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
module main
2+
3+
go 1.24.4
4+
5+
require (
6+
github.com/caarlos0/env/v10 v10.0.0
7+
golang.org/x/sync v0.15.0
8+
tailscale.com v1.84.3
9+
)
10+
11+
require (
12+
filippo.io/edwards25519 v1.1.0 // indirect
13+
github.com/akutz/memconn v0.1.0 // indirect
14+
github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa // indirect
15+
github.com/aws/aws-sdk-go-v2 v1.36.0 // indirect
16+
github.com/aws/aws-sdk-go-v2/config v1.29.5 // indirect
17+
github.com/aws/aws-sdk-go-v2/credentials v1.17.58 // indirect
18+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.27 // indirect
19+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.31 // indirect
20+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.31 // indirect
21+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.2 // indirect
22+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.2 // indirect
23+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.12 // indirect
24+
github.com/aws/aws-sdk-go-v2/service/ssm v1.44.7 // indirect
25+
github.com/aws/aws-sdk-go-v2/service/sso v1.24.14 // indirect
26+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.13 // indirect
27+
github.com/aws/aws-sdk-go-v2/service/sts v1.33.13 // indirect
28+
github.com/aws/smithy-go v1.22.2 // indirect
29+
github.com/coder/websocket v1.8.12 // indirect
30+
github.com/coreos/go-iptables v0.7.1-0.20240112124308-65c67c9f46e6 // indirect
31+
github.com/dblohm7/wingoes v0.0.0-20240119213807-a09d6be7affa // indirect
32+
github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e // indirect
33+
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
34+
github.com/gaissmai/bart v0.18.0 // indirect
35+
github.com/go-json-experiment/json v0.0.0-20250223041408-d3c622f1b874 // indirect
36+
github.com/go-ole/go-ole v1.3.0 // indirect
37+
github.com/godbus/dbus/v5 v5.1.1-0.20230522191255-76236955d466 // indirect
38+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
39+
github.com/google/btree v1.1.2 // indirect
40+
github.com/google/go-cmp v0.6.0 // indirect
41+
github.com/google/nftables v0.2.1-0.20240414091927-5e242ec57806 // indirect
42+
github.com/google/uuid v1.6.0 // indirect
43+
github.com/gorilla/csrf v1.7.3 // indirect
44+
github.com/gorilla/securecookie v1.1.2 // indirect
45+
github.com/hdevalence/ed25519consensus v0.2.0 // indirect
46+
github.com/illarion/gonotify/v3 v3.0.2 // indirect
47+
github.com/jmespath/go-jmespath v0.4.0 // indirect
48+
github.com/jsimonetti/rtnetlink v1.4.0 // indirect
49+
github.com/klauspost/compress v1.17.11 // indirect
50+
github.com/mdlayher/genetlink v1.3.2 // indirect
51+
github.com/mdlayher/netlink v1.7.3-0.20250113171957-fbb4dce95f42 // indirect
52+
github.com/mdlayher/sdnotify v1.0.0 // indirect
53+
github.com/mdlayher/socket v0.5.0 // indirect
54+
github.com/miekg/dns v1.1.58 // indirect
55+
github.com/mitchellh/go-ps v1.0.0 // indirect
56+
github.com/prometheus-community/pro-bing v0.4.0 // indirect
57+
github.com/safchain/ethtool v0.3.0 // indirect
58+
github.com/tailscale/certstore v0.1.1-0.20231202035212-d3fa0460f47e // indirect
59+
github.com/tailscale/go-winio v0.0.0-20231025203758-c4f33415bf55 // indirect
60+
github.com/tailscale/goupnp v1.0.1-0.20210804011211-c64d0f06ea05 // indirect
61+
github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a // indirect
62+
github.com/tailscale/netlink v1.1.1-0.20240822203006-4d49adab4de7 // indirect
63+
github.com/tailscale/peercred v0.0.0-20250107143737-35a0c7bd7edc // indirect
64+
github.com/tailscale/web-client-prebuilt v0.0.0-20250124233751-d4cd19a26976 // indirect
65+
github.com/tailscale/wireguard-go v0.0.0-20250304000100-91a0587fb251 // indirect
66+
github.com/vishvananda/netns v0.0.4 // indirect
67+
github.com/x448/float16 v0.8.4 // indirect
68+
go4.org/mem v0.0.0-20240501181205-ae6ca9944745 // indirect
69+
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
70+
golang.org/x/crypto v0.37.0 // indirect
71+
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac // indirect
72+
golang.org/x/mod v0.23.0 // indirect
73+
golang.org/x/net v0.36.0 // indirect
74+
golang.org/x/sys v0.32.0 // indirect
75+
golang.org/x/term v0.31.0 // indirect
76+
golang.org/x/text v0.24.0 // indirect
77+
golang.org/x/time v0.10.0 // indirect
78+
golang.org/x/tools v0.30.0 // indirect
79+
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
80+
golang.zx2c4.com/wireguard/windows v0.5.3 // indirect
81+
gvisor.dev/gvisor v0.0.0-20250205023644-9414b50a5633 // indirect
82+
)

0 commit comments

Comments
 (0)