# infinite-noodle

`infinite-noodle` is a small Go service that combines:

- a web UI for viewing configured TCP proxies
- a Bitcask-backed data store for persisted proxy definitions
- a TCP proxy runner powered by `inet.af/tcpproxy`

This README is written for working in a GitHub Codespace.

## What It Does

Each "noodle" is a TCP forwarding rule with:

- a listen port
- a destination host
- a destination port
- an up/down state

When the app starts, it loads saved noodles from the local database and starts any active proxy routes. It also serves a basic web UI for listing and deleting them.

## Current State

The project is functional enough to:

- start the web app
- load stored proxy definitions from `./infinite.db`
- run active TCP proxies
- delete existing noodles from the UI

What is not wired up yet:

- the add row in the UI is present, but create/save is not implemented
- there is no REST API for creating noodles
- proxy routing is TCP only in the current code path

## Running In A Codespace

This repo expects a Go toolchain to be available in the Codespace. If it is missing, install or add Go first.

Start the app:

```bash
go run ./cmd/infinite-noodle
```

Default runtime settings:

- host: `0.0.0.0`
- web UI port: `7878`
- database path: `./infinite.db`

Open the app in the browser from the forwarded port for `7878`.

You can also override the defaults:

```bash
go run ./cmd/infinite-noodle -host 0.0.0.0 -port 7878 -data ./infinite.db
```

Available flags:

- `-host`: host/interface to bind the web server to
- `-port`: web server port
- `-data`: path to the Bitcask database directory
- `-test`: seeds the database with sample noodles on startup

## Codespaces Port Notes

In Codespaces, you will usually need to forward:

- `7878` for the web UI
- any listen ports used by active noodles

Example:

- if a noodle listens on `5555`, forward port `5555`
- if it proxies to another service running inside the Codespace on `6666`, that destination only needs forwarding if you also want direct browser or external access to it

## Quick Local Proxy Demo

The repo includes simple Python test scripts in [`test/server.py`](/data/project/go/src/infinite-noodle/test/server.py) and [`test/client.py`](/data/project/go/src/infinite-noodle/test/client.py).

Typical flow:

1. Run the app with `go run ./cmd/infinite-noodle`
2. Start the test echo server on `127.0.0.1:6666`
3. Ensure the database contains a noodle that listens on `5555` and forwards to `127.0.0.1:6666`
4. Run the test client, which connects to `127.0.0.1:5555`

Because create is not implemented in the UI yet, you currently need to seed or insert noodle records another way.

## Building Binaries

The repo includes [`build.sh`](/data/project/go/src/infinite-noodle/build.sh), which builds binaries for:

- Linux amd64
- macOS arm64
- macOS amd64
- Windows arm64
- Windows amd64

Run:

```bash
sh build.sh
```

Artifacts are written under `./target/`.

## Important Files

- [`cmd/infinite-noodle/main.go`](/data/project/go/src/infinite-noodle/cmd/infinite-noodle/main.go): binary entrypoint and CLI flags
- [`internal/app/app.go`](/data/project/go/src/infinite-noodle/internal/app/app.go): app startup, HTTP server, and proxy lifecycle
- [`internal/noodle/database.go`](/data/project/go/src/infinite-noodle/internal/noodle/database.go): Bitcask storage layer
- [`internal/web/handlers.go`](/data/project/go/src/infinite-noodle/internal/web/handlers.go): HTML handlers
- [`internal/assets/templates/index.html`](/data/project/go/src/infinite-noodle/internal/assets/templates/index.html): UI template

## Verification Note

The reorganized project layout was verified with `go test ./...` and `go build ./...` in this workspace.
